Skip to content

Commit 70753c6

Browse files
committed
missing spherical light recomputation
1 parent 03cba0a commit 70753c6

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

relightlab/domepanel.cpp

+25-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
DomePanel::DomePanel(QWidget *parent): QFrame(parent) {
2121

22-
// setContentsMargins(10, 10, 10, 10);
22+
// setContentsMargins(10, 10, 10, 10);
2323
QHBoxLayout *content = new QHBoxLayout(this);
2424
//content->setHorizontalSpacing(20);
2525

@@ -92,18 +92,36 @@ void DomePanel::loadDomeFile(QString path) {
9292
loadLP(path);
9393
if(path.endsWith(".dome"))
9494
loadDome(path);
95-
// dome_list->clearSelection();
95+
// dome_list->clearSelection();
9696
}
9797

9898
void DomePanel::exportDome() {
99-
QString filename = QFileDialog::getSaveFileName(this, "Select a dome file", qRelightApp->lastProjectDir(), "*.dome");
99+
QString filename = QFileDialog::getSaveFileName(this, "Select a dome file", qRelightApp->lastProjectDir(), "*.dome *.lp");
100100
if(filename.isNull())
101101
return;
102-
if(!filename.endsWith(".dome"))
103-
filename += ".dome";
104-
//TODO Basic checks, label is a problem (use filename!
102+
105103
Dome &dome = qRelightApp->project().dome;
106-
dome.save(filename);
104+
105+
if(filename.endsWith(".lp")) {
106+
try {
107+
qRelightApp->project().saveLP(filename, dome.directions);
108+
} catch(QString error) {
109+
QMessageBox::critical(this, "Failed to save the .lp file", error);
110+
return;
111+
}
112+
113+
} else {
114+
115+
if(!filename.endsWith(".dome"))
116+
filename += ".dome";
117+
118+
try {
119+
dome.save(filename);
120+
} catch(QString error) {
121+
QMessageBox::critical(this, "Failed to save the .dome file", error);
122+
return;
123+
}
124+
}
107125
qRelightApp->addDome(filename);
108126
}
109127

src/dome.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Dome {
4949
void fromSpheres(std::vector<Sphere *> &spheres, Lens &lens);
5050
void updateSphereDirections();
5151
void parseLP(const QString &lp_path);
52+
//TODO: move savelp here from project
53+
//void saveLP(const QString &lp_path);
5254
void load(const QString &filename);
5355
void save(const QString &filename);
5456
size_t lightsCount() { return directions.size(); }

src/imageset.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ bool ImageSet::initFromProject(QJsonObject &obj, const QString &filename) {
8888

8989
void ImageSet::initFromDome(Dome &dome) {
9090
light3d = dome.lightConfiguration != Dome::DIRECTIONAL;
91+
9192
assert(image_width != 0);
9293
pixel_size = dome.imageWidth / image_width;
9394
switch(dome.lightConfiguration) {
9495
case Dome::DIRECTIONAL:
9596
setLights(dome.directions, dome.lightConfiguration);
9697
break;
97-
case Dome::SPHERICAL:
98+
case Dome::SPHERICAL:
99+
dome.updateSphereDirections();
98100
setLights(dome.positionsSphere, dome.lightConfiguration);
99101
break;
100102
case Dome::LIGHTS3D:

0 commit comments

Comments
 (0)