Skip to content

Commit

Permalink
missing spherical light recomputation
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Jan 10, 2025
1 parent 03cba0a commit 70753c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
32 changes: 25 additions & 7 deletions relightlab/domepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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

// setContentsMargins(10, 10, 10, 10);
// setContentsMargins(10, 10, 10, 10);
QHBoxLayout *content = new QHBoxLayout(this);
//content->setHorizontalSpacing(20);

Expand Down Expand Up @@ -92,18 +92,36 @@ void DomePanel::loadDomeFile(QString path) {
loadLP(path);
if(path.endsWith(".dome"))
loadDome(path);
// dome_list->clearSelection();
// dome_list->clearSelection();
}

void DomePanel::exportDome() {
QString filename = QFileDialog::getSaveFileName(this, "Select a dome file", qRelightApp->lastProjectDir(), "*.dome");
QString filename = QFileDialog::getSaveFileName(this, "Select a dome file", qRelightApp->lastProjectDir(), "*.dome *.lp");
if(filename.isNull())
return;
if(!filename.endsWith(".dome"))
filename += ".dome";
//TODO Basic checks, label is a problem (use filename!

Dome &dome = qRelightApp->project().dome;
dome.save(filename);

if(filename.endsWith(".lp")) {
try {
qRelightApp->project().saveLP(filename, dome.directions);
} catch(QString error) {
QMessageBox::critical(this, "Failed to save the .lp file", error);
return;
}

} else {

if(!filename.endsWith(".dome"))
filename += ".dome";

try {
dome.save(filename);
} catch(QString error) {
QMessageBox::critical(this, "Failed to save the .dome file", error);
return;
}
}
qRelightApp->addDome(filename);
}

Expand Down
2 changes: 2 additions & 0 deletions src/dome.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Dome {
void fromSpheres(std::vector<Sphere *> &spheres, Lens &lens);
void updateSphereDirections();
void parseLP(const QString &lp_path);
//TODO: move savelp here from project
//void saveLP(const QString &lp_path);
void load(const QString &filename);
void save(const QString &filename);
size_t lightsCount() { return directions.size(); }
Expand Down
4 changes: 3 additions & 1 deletion src/imageset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ bool ImageSet::initFromProject(QJsonObject &obj, const QString &filename) {

void ImageSet::initFromDome(Dome &dome) {
light3d = dome.lightConfiguration != Dome::DIRECTIONAL;

assert(image_width != 0);
pixel_size = dome.imageWidth / image_width;
switch(dome.lightConfiguration) {
case Dome::DIRECTIONAL:
setLights(dome.directions, dome.lightConfiguration);
break;
case Dome::SPHERICAL:
case Dome::SPHERICAL:
dome.updateSphereDirections();
setLights(dome.positionsSphere, dome.lightConfiguration);
break;
case Dome::LIGHTS3D:
Expand Down

0 comments on commit 70753c6

Please sign in to comment.