Skip to content

Commit 52f4c1e

Browse files
committed
Images can now be 'hidden' from the RTI and normals
without lp adjusting or sphere recomputation.
1 parent e29d65d commit 52f4c1e

17 files changed

+276
-152
lines changed

relight-cli/rtibuilder.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ void RtiBuilder::savePixel(Color3f *p, int side, const QString &file) {
167167
*/
168168

169169
bool RtiBuilder::init(std::function<bool(QString stage, int percent)> *_callback) {
170+
171+
if(imageset.lights1.size() != size_t(imageset.images.size()))
172+
throw QString("Number of lights in dome needs to be equal to the number of images");
173+
170174
if((type == PTM || type == HSH || type == SH || type == H) && (colorspace == MRGB || colorspace == MYCC)) {
171175
error = "PTM and HSH do not support MRGB";
172176
return false;
Loading
+1
Loading
Loading
+1
Loading

relightlab/imagegrid.cpp

+34-17
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,39 @@
1313
#include <iostream>
1414
using namespace std;
1515

16-
ImageThumb::ImageThumb(QImage img, const QString& text, bool skip, QWidget* parent): QWidget(parent) {
16+
ImageThumb::ImageThumb(QImage img, const QString& text, bool skip, bool visible, QWidget* parent): QWidget(parent) {
1717

1818
QVBoxLayout* layout = new QVBoxLayout(this);
19+
{
20+
QLabel *label = new QLabel;
21+
label->setPixmap(QPixmap::fromImage(img));
22+
layout->addWidget(label);
23+
}
24+
{
25+
QHBoxLayout *checkline = new QHBoxLayout;
26+
layout->addLayout(checkline);
27+
{
28+
skipbox = new QCheckBox(text);
29+
skipbox->setChecked(!skip);
30+
connect(skipbox, SIGNAL(stateChanged(int)), this, SIGNAL(skipChanged(int)));
31+
checkline->addWidget(skipbox);
32+
}
33+
{
34+
visibleicon = new QLabel();
35+
visibleicon->setPixmap(QIcon::fromTheme(visible ?"eye":"eye-off").pixmap(20, 20));
36+
checkline->addWidget(visibleicon);
37+
38+
}
1939

20-
QLabel *label = new QLabel;
21-
label->setPixmap(QPixmap::fromImage(img));
22-
layout->addWidget(label);
23-
24-
QCheckBox *checkbox = new QCheckBox(text);
25-
26-
checkbox->setChecked(!skip);
27-
connect(checkbox, SIGNAL(stateChanged(int)), this, SIGNAL(skipChanged(int)));
28-
layout->addWidget(checkbox);
29-
40+
}
3041
layout->setSpacing(5);
3142
layout->setContentsMargins(5, 5, 5, 5);
3243
}
3344

34-
void ImageThumb::setSkipped(bool skip) {
35-
findChild<QCheckBox *>()->setChecked(!skip);
45+
void ImageThumb::setSkipped(bool skip, bool visible) {
46+
skipbox->setChecked(!skip);
47+
visibleicon->setPixmap(QIcon::fromTheme(visible ?"eye":"eye-off").pixmap(20, 20));
48+
3649
}
3750

3851
void ImageThumb::setThumbnail(QImage thumb) {
@@ -63,7 +76,7 @@ void ImageGrid::init() {
6376
QImage thumbnail = thumbnails[i];
6477
Image &image = project.images[i];
6578
QFileInfo info(image.filename);
66-
ImageThumb *thumb = new ImageThumb(thumbnail, info.fileName(), image.skip);
79+
ImageThumb *thumb = new ImageThumb(thumbnail, info.fileName(), image.skip, image.visible);
6780
connect(thumb, &ImageThumb::skipChanged, [this, i, &image](int state){
6881
image.skip = (state==0);
6982
this->emit skipChanged(i, image.skip);
@@ -72,9 +85,13 @@ void ImageGrid::init() {
7285
}
7386
}
7487

75-
void ImageGrid::setSkipped(int image, bool skip) {
76-
ImageThumb *thumb = dynamic_cast<ImageThumb *>(flowlayout->itemAt(image)->widget());
77-
thumb->setSkipped(skip);
88+
void ImageGrid::setSkipped(int img_number, bool skip) {
89+
auto &images = qRelightApp->project().images;
90+
assert(img_number >= 0 && img_number < images.size());
91+
Image &img = images[img_number];
92+
93+
ImageThumb *thumb = dynamic_cast<ImageThumb *>(flowlayout->itemAt(img_number)->widget());
94+
thumb->setSkipped(img.skip, img.visible);
7895
}
7996

8097
void ImageGrid::updateThumbnail(int pos) {

relightlab/imagegrid.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66

77

88
class FlowLayout;
9+
class QCheckBox;
10+
class QLabel;
911

1012

1113
class ImageThumb : public QWidget {
1214
Q_OBJECT
1315
public:
14-
ImageThumb(QImage img, const QString& text, bool skip, QWidget* parent = nullptr);
15-
void setSkipped(bool skip);
16+
ImageThumb(QImage img, const QString& text, bool skip, bool visible, QWidget* parent = nullptr);
17+
void setSkipped(bool skip, bool visible);
1618
void setThumbnail(QImage thumb);
1719
signals:
1820
void skipChanged(int state);
1921

20-
22+
private:
23+
QCheckBox *skipbox = nullptr;
24+
QLabel *visibleicon = nullptr;
2125
};
2226

2327

relightlab/imagelist.cpp

+59-1
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,37 @@
22
#include "relightapp.h"
33

44
#include <QFileInfo>
5+
#include <QStyledItemDelegate>
56
#include <assert.h>
67

8+
class RightDelegate : public QStyledItemDelegate {
9+
public:
10+
explicit RightDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
11+
12+
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override {
13+
QStyleOptionViewItem myOpt(option);
14+
myOpt.decorationPosition = QStyleOptionViewItem::Right;
15+
QStyledItemDelegate::paint(painter, myOpt, index);
16+
}
17+
};
18+
19+
720
void ImageList::init() {
21+
setItemDelegate(new RightDelegate(this));
822
setSelectionMode(QAbstractItemView::ExtendedSelection);
923

1024
Project &project = qRelightApp->project();
1125
clear();
1226
int count =0;
27+
setIconSize(QSize(icon_size, icon_size));
28+
1329
for(Image &img: project.images) {
1430
QFileInfo info(img.filename);
1531
QListWidgetItem *item = new QListWidgetItem(QString("%1 - %2").arg(count+1).arg(info.fileName()));
1632
item->setData(Qt::UserRole, count);
1733
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1834
item->setCheckState(img.skip? Qt::Unchecked : Qt::Checked);
35+
item->setIcon(QIcon::fromTheme(img.visible ? "eye" : "eye-off"));
1936
addItem(item);
2037
count++;
2138
}
@@ -37,5 +54,46 @@ void ImageList::verifyItem(QListWidgetItem *item) {
3754

3855
void ImageList::setSkipped(int img_number, bool skip) {
3956
QListWidgetItem *item = this->item(img_number);
40-
item->setCheckState(skip? Qt::Unchecked : Qt::Checked);
57+
auto &images = qRelightApp->project().images;
58+
assert(img_number >= 0 && img_number < images.size());
59+
Image &img = images[img_number];
60+
61+
item->setCheckState(img.skip? Qt::Unchecked : Qt::Checked);
62+
item->setIcon(QIcon::fromTheme(img.visible ? "eye" : "eye-off"));
4163
}
64+
65+
void ImageList::mousePressEvent(QMouseEvent *event) {
66+
QListWidgetItem *item = itemAt(event->pos());
67+
if (item) {
68+
69+
QRect itemRect = visualItemRect(item);
70+
71+
// Setup QStyleOptionViewItem
72+
QStyleOptionViewItem option;
73+
option.initFrom(this);
74+
option.state = QStyle::State_Enabled;
75+
option.viewItemPosition = QStyleOptionViewItem::Middle;
76+
option.features = QStyleOptionViewItem::HasCheckIndicator;
77+
option.rect = itemRect;
78+
79+
// 1. Get checkbox rect using QStyleOptionViewItem
80+
QRect checkboxRect = style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &option, this);
81+
82+
checkboxRect.moveTopLeft(itemRect.topLeft());
83+
QRect iconRect(itemRect.right() - 20, itemRect.center().y() - 8, icon_size, 16);
84+
85+
if (iconRect.contains(event->pos())) {
86+
87+
88+
int img_number = item->data(Qt::UserRole).toInt();
89+
auto &images = qRelightApp->project().images;
90+
assert(img_number >= 0 && img_number < images.size());
91+
Image &img = images[img_number];
92+
img.visible = !img.visible;
93+
94+
item->setIcon(QIcon::fromTheme(img.visible ? "eye" : "eye-off"));
95+
emit skipChanged(img_number, img.skip);
96+
}
97+
}
98+
QListWidget::mousePressEvent(event);
99+
}

relightlab/imagelist.h

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class ImageList: public QListWidget {
77
Q_OBJECT
88
public:
9+
int icon_size = 16;
910
ImageList(QWidget *parent = nullptr): QListWidget(parent) {}
1011

1112
void init();
@@ -16,6 +17,9 @@ public slots:
1617

1718
signals:
1819
void skipChanged(int image, bool skip);
20+
21+
protected:
22+
void mousePressEvent(QMouseEvent *event) override ;
1923
};
2024

2125
#endif // IMAGELIST_H

relightlab/normalstask.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ void NormalsTask::initFromProject(Project &project) {
5555
imageset.width = imageset.image_width = project.lens.width;
5656
imageset.height = imageset.image_height = project.lens.height;
5757

58-
imageset.images = project.getImages();
59-
imageset.initImages(project.dir.absolutePath().toStdString().c_str());
60-
imageset.initFromDome(project.dome);
61-
assert(imageset.lights().size() == imageset.images.size());
58+
imageset.initFromProject(project);
6259
imageset.setCrop(project.crop, project.offsets);
6360

6461
pixelSize = project.pixelSize;
6562
}
63+
6664
void NormalsTask::setParameters(NormalsParameters &param) {
6765
parameters = param;
6866
label = parameters.summary();

0 commit comments

Comments
 (0)