Skip to content

Commit 8026256

Browse files
committed
debug normalsframe and minor bugfix
1 parent d676f34 commit 8026256

16 files changed

+110
-68
lines changed

relightlab/alignframe.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ void AlignFrame::clear() {
4040

4141
void AlignFrame::init() {
4242
for(Align *align: qRelightApp->project().aligns) {
43-
AlignRow * row = addAlign(align);
44-
// row->detectHighlights(false);
43+
addAlign(align);
4544
}
4645
}
4746

@@ -59,8 +58,7 @@ void AlignFrame::newAlign() {
5958
return;
6059
}
6160
qRelightApp->project().aligns.push_back(align);
62-
AlignRow *row = addAlign(align);
63-
//row->detectHighlights();
61+
addAlign(align);
6462
}
6563

6664
AlignRow *AlignFrame::addAlign(Align *align) {

relightlab/brdfframe.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "brdfframe.h"
2+
3+
#include <QVBoxLayout>
4+
5+
//export various planes.
6+
7+
BrdfFrame::BrdfFrame(QWidget *parent): QFrame(parent) {
8+
QVBoxLayout *content = new QVBoxLayout(this);
9+
10+
content->addSpacing(10);
11+
}

relightlab/brdfframe.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef BRDFFRAME_H
2+
#define BRDFFRAME_H
3+
4+
#include <QFrame>
5+
6+
class BrdfFrame: public QFrame {
7+
Q_OBJECT
8+
public:
9+
BrdfFrame(QWidget *parent = nullptr);
10+
void clear();
11+
void init();
12+
13+
public slots:
14+
15+
16+
private:
17+
};
18+
19+
#endif // BRDFFRAME_H

relightlab/domepanel.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,19 @@ void DomePanel::exportDome() {
110110

111111
void DomePanel::loadLP(QString path) {
112112
std::vector<QString> filenames;
113-
dome.lightConfiguration = Dome::DIRECTIONAL;
113+
std::vector<Eigen::Vector3f> directions;
114114

115115
try {
116-
parseLP(path, dome.directions, filenames);
116+
parseLP(path, directions, filenames);
117+
qRelightApp->project().validateDome(directions.size());
118+
117119
} catch(QString error) {
118120
QMessageBox::critical(this, "Loading .lp file failed", error);
119121
return;
120122
}
123+
124+
dome.lightConfiguration = Dome::DIRECTIONAL;
125+
dome.directions = directions;
121126
QFileInfo info(path);
122127
dome.label = info.filePath();
123128
qRelightApp->addDome(path);
@@ -129,12 +134,16 @@ void DomePanel::loadLP(QString path) {
129134

130135
void DomePanel::loadDome(QString path) {
131136
float imageWidth = dome.imageWidth;
137+
Dome new_dome;
132138
try {
133-
dome.load(path);
139+
new_dome.load(path);
140+
qRelightApp->project().validateDome(new_dome.directions.size());
141+
134142
} catch (QString error) {
135143
QMessageBox::critical(this, "Loading .dome file failed", error);
136144
return;
137145
}
146+
dome = new_dome;
138147

139148
QFileInfo info(path);
140149
dome.label = info.filePath();

relightlab/mainwindow.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void MainWindow::init() {
143143
lights_frame->init();
144144
crop_frame->init();
145145
rti_frame->init();
146+
normals_frame->init();
146147
}
147148

148149
void MainWindow::showHelp() {

relightlab/metadataframe.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "metadataframe.h"
2+
3+
#include <QVBoxLayout>
4+
5+
MetadataFrame::MetadataFrame(QWidget *parent): QFrame(parent) {
6+
QVBoxLayout *content = new QVBoxLayout;
7+
8+
}

relightlab/metadataframe.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef METADATAFRAME_H
2+
#define METADATAFRAME_H
3+
4+
#include <QFrame>
5+
6+
class MetadataFrame: public QFrame {
7+
public:
8+
MetadataFrame(QWidget *parent = nullptr);
9+
void clear();
10+
void init();
11+
12+
};
13+
14+
#endif // METADATAFRAME_H

relightlab/normalsframe.cpp

+5-46
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ NormalsFrame::NormalsFrame(QWidget *parent): QFrame(parent) {
2626
content->addWidget(source_row = new NormalsSourceRow(parameters, this));
2727
content->addWidget(flatten_row = new NormalsFlattenRow(parameters, this));
2828
content->addWidget(surface_row = new NormalsSurfaceRow(parameters, this));
29+
content->addWidget(export_row = new NormalsExportRow(parameters, this));
2930

3031

3132
{
@@ -66,53 +67,10 @@ NormalsFrame::NormalsFrame(QWidget *parent): QFrame(parent) {
6667

6768

6869
content->addStretch();
70+
}
6971

70-
return;
71-
content->addWidget(jpg = new QRadioButton("JPEG: normalmap"));
72-
content->addWidget(png = new QRadioButton("PNG: normalmap"));
73-
{
74-
QButtonGroup *group = new QButtonGroup(this);
75-
group->addButton(jpg);
76-
group->addButton(png);
77-
jpg->setChecked(true);
78-
}
79-
80-
content->addWidget(new QLabel("<h2>Flatten normals</h2>"));
81-
content->addWidget(radial = new QCheckBox("Radial"));
82-
content->addWidget(fourier = new QCheckBox("Fourier"));
83-
{
84-
QHBoxLayout *fourier_layout = new QHBoxLayout;
85-
86-
fourier_layout->addWidget(new HelpLabel("Fourier image percent: ", "normals/flatten"));
87-
fourier_layout->addWidget(fourier_radius = new QSpinBox);
88-
fourier_radius->setRange(0, 100);
89-
90-
content->addLayout(fourier_layout);
91-
}
92-
93-
content->addSpacing(30);
94-
content->addWidget(new QLabel("<h2>Export 3D surface</h2>"));
95-
content->addSpacing(30);
96-
{
97-
QHBoxLayout *discontinuity_layout = new QHBoxLayout;
98-
99-
discontinuity_layout->addWidget(new HelpLabel("Disconitnuity parameter:", "normals/disconituity"));
100-
discontinuity_layout->addWidget(discontinuity = new QDoubleSpinBox);
101-
discontinuity->setRange(0.0, 4.0);
102-
discontinuity->setValue(2.0);
103-
content->addLayout(discontinuity_layout);
104-
}
105-
106-
content->addWidget(tif = new QCheckBox("TIF: depthmap"));
107-
content->addWidget(ply = new QCheckBox("PLY: mesh"));
108-
109-
110-
QPushButton *save = new QPushButton("Export");
111-
content->addWidget(save);
112-
113-
connect(save, SIGNAL(clicked()), this, SLOT(save()));
114-
115-
content->addStretch();
72+
void NormalsFrame::init() {
73+
export_row->suggestPath();
11674
}
11775

11876
void NormalsFrame::save() {
@@ -124,6 +82,7 @@ void NormalsFrame::save() {
12482

12583
NormalsTask *task = new NormalsTask();
12684
task->parameters = parameters;
85+
task->output = parameters.path;
12786
task->initFromProject(qRelightApp->project());
12887

12988
ProcessQueue &queue = ProcessQueue::instance();

relightlab/normalsframe.h

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class NormalsFrame: public QFrame {
2121

2222
public slots:
2323
void save();
24+
void init();
2425

2526
signals:
2627
void processStarted();

relightlab/normalsplan.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ NormalsSourceRow::NormalsSourceRow(NormalsParameters &_parameters, QFrame *paren
2323
label->help->setId("normals/normalmap");
2424

2525
compute = new QLabelButton("Compute", "Compute normals from images");
26+
2627
file = new QLabelButton("Normalmap", "Loat a normalmap image.");
2728
buttons->addWidget(compute, 0, Qt::AlignCenter);
2829

@@ -47,11 +48,14 @@ NormalsSourceRow::NormalsSourceRow(NormalsParameters &_parameters, QFrame *paren
4748

4849
group->addButton(compute);
4950
group->addButton(file);
51+
52+
setComputeSource(parameters.compute);
5053
}
5154

5255

53-
void NormalsSourceRow::setComputeSource(bool compute) {
54-
parameters.compute = compute;
56+
void NormalsSourceRow::setComputeSource(bool build) {
57+
parameters.compute = build;
58+
compute->setChecked(build);
5559
}
5660

5761

@@ -97,6 +101,8 @@ NormalsFlattenRow::NormalsFlattenRow(NormalsParameters &_parameters, QFrame *par
97101
group->addButton(none);
98102
group->addButton(radial);
99103
group->addButton(fourier);
104+
105+
setFlattenMethod(parameters.flatMethod);
100106
}
101107

102108
void NormalsFlattenRow::setFlattenMethod(FlatMethod method) {
@@ -171,6 +177,8 @@ NormalsSurfaceRow::NormalsSurfaceRow(NormalsParameters &_parameters, QFrame *par
171177
group->addButton(none);
172178
group->addButton(bni);
173179
group->addButton(assm);
180+
181+
setSurfaceMethod(parameters.surface_integration);
174182
}
175183

176184
void NormalsSurfaceRow::setSurfaceMethod(SurfaceIntegration surface) {
@@ -231,9 +239,11 @@ void NormalsExportRow::selectOutput() {
231239
setPath(output);
232240
}
233241

242+
234243
void NormalsExportRow::suggestPath() {
235244
QDir input = qRelightApp->project().dir;
236245
input.cdUp();
237246
QString filename = input.filePath("normals");
238247
setPath(filename);
239248
}
249+

relightlab/normalsplan.h

-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,3 @@ public slots:
7373
QLineEdit *path_edit;
7474
};
7575

76-

relightlab/processqueue.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ProcessQueue::removeTask(Task *a) {
8888
if(index < 0)
8989
return;
9090

91-
Task *task = queue.takeAt(index);
91+
queue.takeAt(index);
9292
emit update();
9393
}
9494

@@ -98,7 +98,7 @@ void ProcessQueue::removeTask(int id) {
9898
if(index < 0)
9999
return;
100100

101-
Task *task = queue.takeAt(index);
101+
queue.takeAt(index);
102102
//processqueue is never the owner!
103103
//delete task;
104104
emit update();

relightlab/relightapp.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,13 @@ void RelightApp::newProject() {
204204
QStringList lps = QDir(dir).entryList(img_ext);
205205
if(lps.size() > 0) {
206206
int answer = QMessageBox::question(mainwindow, "Found an .lp file: " + lps[0], "Do you wish to load " + lps[0] + "?", QMessageBox::Yes, QMessageBox::No);
207-
if(answer != QMessageBox::No)
208-
m_project.loadLP(lps[0]);
207+
if(answer != QMessageBox::No) {
208+
try {
209+
m_project.loadLP(lps[0]);
210+
} catch(QString error) {
211+
QMessageBox::critical(mainwindow, "Could not load the .lp file", error);
212+
}
213+
}
209214
}
210215
}
211216

relightlab/relightlab.pro

+6-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ SOURCES += main.cpp \
110110
../src/bni_normal_integration.cpp \
111111
scaleframe.cpp \
112112
planrow.cpp \
113-
normalsplan.cpp
113+
normalsplan.cpp \
114+
brdfframe.cpp \
115+
metadataframe.cpp
114116

115117
RESOURCES += \
116118
res.qrc
@@ -194,7 +196,9 @@ HEADERS += \
194196
scaleframe.h \
195197
../src/flatnormals.h \
196198
planrow.h \
197-
normalsplan.h
199+
normalsplan.h \
200+
brdfframe.h \
201+
metadataframe.h
198202

199203
FORMS +=
200204

src/project.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,7 @@ void Project::loadLP(QString filename) {
551551

552552

553553
parseLP(filename, directions, filenames); //might throw an error.
554-
555-
if(size() != filenames.size()) {
556-
throw QString("The folder contains %1 images, the .lp file specify %2 images.\n"
557-
"You might have some extraneous images, or just loading the wrong .lp file.")
558-
.arg(size()).arg(filenames.size());
559-
}
554+
validateDome(filenames.size());
560555

561556
vector<Vector3f> ordered_dir(directions.size());
562557
bool success = true;
@@ -688,3 +683,11 @@ void Project::computeDirections() {
688683
}
689684
needs_saving = true;
690685
}
686+
687+
void Project::validateDome(size_t n_lights) {
688+
if(size() != n_lights) {
689+
throw QString("The folder contains %1 images, the .lp file specify %2 images.\n"
690+
"You might have some extraneous images, or just loading the wrong .lp file.")
691+
.arg(size()).arg(n_lights);
692+
}
693+
}

src/project.h

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class Project {
110110
}
111111
return -1;
112112
}
113+
void validateDome(size_t n_lights); //throw an error in case the number of lights is not consistent.
113114

114115
};
115116

0 commit comments

Comments
 (0)