Skip to content

Commit

Permalink
lp loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Feb 5, 2024
1 parent 2035ed3 commit 6b6126e
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 52 deletions.
1 change: 1 addition & 0 deletions relight/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ void MainWindow::loadLP(QString lp) {
project.images[i].direction = directions[i];
}
}

void MainWindow::saveLPs() {
int count = 1;
QString basename = "sphere";
Expand Down
3 changes: 3 additions & 0 deletions relight/parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ QStringList Parameter::arguments() {
break;
case TMP_FILE: //Script will fill it in.
break;
default:
throw "parameter type not supported";
break;
}
return list;
}
4 changes: 1 addition & 3 deletions relightlab/css/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ QPushButton.large {
padding-left:12px;
padding-top:8px;
padding-bottom:8px;
max-width:200px;
}


Expand All @@ -18,6 +19,3 @@ QLabel.recent:hover{
background-color: palette(mid);
}

QFrame#lights_choice QPushButton {
padding:20px
}
14 changes: 7 additions & 7 deletions relightlab/homeframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ HomeFrame::HomeFrame() {

//setStyleSheet(".home { background:red; padding-top:100px }");
QHBoxLayout *contentLayout = new QHBoxLayout(this);
contentLayout->addStretch();
contentLayout->addStretch(1);

// Left column
QVBoxLayout *leftColumnLayout = new QVBoxLayout();

// Title label
QLabel *titleLabel = new QLabel("RelightLab");
titleLabel->setFont(QFont("Arial", 16, QFont::Bold));
QLabel *titleLabel = new QLabel("<h1>RelightLab</h1>");
titleLabel->setMinimumWidth(200);

leftColumnLayout->addWidget(titleLabel);
Expand All @@ -42,7 +41,8 @@ HomeFrame::HomeFrame() {
setDefaultAction(open_project, qRelightApp->action("open_project"));
leftColumnLayout->addWidget(open_project);

QLabel *recentLabel = new QLabel("Recent projects:");
QLabel *recentLabel = new QLabel("<h2>Recent projects:</h2>");
leftColumnLayout->addSpacing(20);
leftColumnLayout->addWidget(recentLabel);


Expand All @@ -56,7 +56,7 @@ HomeFrame::HomeFrame() {
leftColumnLayout->addStretch();

// Add columns to the content layout
contentLayout->addLayout(leftColumnLayout);
contentLayout->addLayout(leftColumnLayout, 2);

// Right column
QTextBrowser *browser = new QTextBrowser(this);
Expand All @@ -66,9 +66,9 @@ HomeFrame::HomeFrame() {
file.open(QIODevice::ReadOnly);
browser->setText(file.readAll());
browser->setMinimumWidth(400);
contentLayout->addWidget(browser);
contentLayout->addWidget(browser, 2);

contentLayout->addStretch();
contentLayout->addStretch(1);

// Set layout margins and spacing
contentLayout->setContentsMargins(20, 20, 20, 20);
Expand Down
104 changes: 81 additions & 23 deletions relightlab/lightsframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <QButtonGroup>
#include <QPushButton>
#include <QLabel>
#include <QDebug>
#include <QFileDialog>

Card::Card(QString title, QString subtitle, QWidget *parent): QFrame(parent) {
setFrameShape(QFrame::StyledPanel);
Expand All @@ -15,7 +17,7 @@ Card::Card(QString title, QString subtitle, QWidget *parent): QFrame(parent) {
QObject::connect(button, SIGNAL(clicked()), this, SLOT(click()));
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

setStyleSheet("QPushButton { font-size: 24px; }");
setStyleSheet("QPushButton { font-size: 24px; padding:20px}");

layout->addWidget(button);
layout->addSpacing(30);
Expand All @@ -25,11 +27,24 @@ Card::Card(QString title, QString subtitle, QWidget *parent): QFrame(parent) {
}

LightsFrame::LightsFrame() {
this->addWidget(createLightsChoice());
addWidget(createChoiceFrame());
lp = new LpFrame();
addWidget(lp);
sphere = new SphereFrame();
addWidget(sphere);
dome = new DomeFrame();
addWidget(dome);
}
QFrame *LightsFrame::createLightsChoice() {

void LightsFrame::init() {
lp->init();
sphere->init();
dome->init();
}

QFrame *LightsFrame::createChoiceFrame() {
QFrame *lights_choice = new QFrame();
lights_choice->setObjectName("lights_choice");
//lights_choice->setObjectName("lights_choice");

QVBoxLayout *content = new QVBoxLayout(lights_choice);

Expand All @@ -42,45 +57,88 @@ QFrame *LightsFrame::createLightsChoice() {
buttons->addStretch(1);

Card *lp = new Card("LP", "<p>Load a file (.lp) containging the light directions.</p>");

connect(lp, SIGNAL(clicked()), this, SLOT(showLp()));
buttons->addWidget(lp, 1);

QPushButton *sphere =new QPushButton("Sphere:\n identify reflective spheres");
Card *sphere = new Card("Sphere", "<p>Identify one or more reflective spheres</p>");
connect(sphere, SIGNAL(clicked()), this, SLOT(showSphere()));
sphere->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
buttons->addWidget(sphere, 0);
buttons->addWidget(sphere, 1);

QPushButton *dome = new QPushButton("Dome:\n select a preconfigured dome");
Card *dome = new Card("Dome", "<p>Select a preconfigure dome</p>");
connect(dome, SIGNAL(clicked()), this, SLOT(showDome()));
dome->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
buttons->addWidget(dome, 0);
buttons->addWidget(dome, 1);

buttons->addStretch(1);

content->addStretch(2);
return lights_choice;
}

QFrame *LightsFrame::createLp() {
QFrame *lp_frame = new QFrame();
return lp_frame;
void LightsFrame::showChoice() {

setCurrentIndex(0);
}
void LightsFrame::showLp() {
setCurrentWidget(lp);
}

QFrame *LightsFrame::createSphere() {
QFrame *sphere_frame = new QFrame();
return sphere_frame;
void LightsFrame::showSphere() {
setCurrentIndex(2);
}

QFrame *LightsFrame::createDome() {
QFrame *dome_frame = new QFrame();
return dome_frame;
void LightsFrame::showDome() {
setCurrentIndex(3);
}

void LightsFrame::showLp() {


LpFrame::LpFrame(QWidget *parent): QFrame(parent) {
QVBoxLayout *content = new QVBoxLayout(this);
content->setContentsMargins(31, 31, 31, 31);
this->setLayout(content);

QLabel *title = new QLabel("<h2>LP light directions</h2>");
content->addWidget(title);
content->addSpacing(30);
QHBoxLayout *filebox = new QHBoxLayout();
QPushButton *load = new QPushButton("Load LP file...");
connect(load, SIGNAL(clicked()), this, SLOT(loadLP()));
load->setMaximumWidth(300);
filebox->addWidget(load);
QLabel *filename = new QLabel();
filebox->addWidget(filename);

content->addLayout(filebox);
content->addStretch();
}

void LightsFrame::showSphere() {
void LpFrame::init() {
}

void LightsFrame::showDome() {
void LpFrame::loadLP() {

QFileDialog::getOpenFileName(this, "Load an LP file", )
}

SphereFrame::SphereFrame(QWidget *parent): QFrame(parent) {
QVBoxLayout *content = new QVBoxLayout(this);
this->setLayout(content);

QLabel *title = new QLabel("<h2>Sphere light directions</h2>");
content->addWidget(title);
}

void SphereFrame::init() {
}

DomeFrame::DomeFrame(QWidget *parent): QFrame(parent) {
QVBoxLayout *content = new QVBoxLayout(this);
this->setLayout(content);

QLabel *title = new QLabel("<h2>Dome light directions</h2>");
content->addWidget(title);
}

void DomeFrame::init() {
}

55 changes: 42 additions & 13 deletions relightlab/lightsframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,61 @@

#include <QStackedWidget>

class QLabel;

class Card: public QFrame {
Q_OBJECT
public:
Card(QString title, QString subtitle, QWidget *parent = nullptr);
public slots:
void click() { emit clicked(); }
signals:
void clicked();
};

class LpFrame: public QFrame {
Q_OBJECT
public:
LpFrame(QWidget *parent = nullptr);
void init();
void loadLP(QString filename);
public slots:
void loadLP();
private:
QLabel *filename;
};

class SphereFrame: public QFrame {
public:
SphereFrame(QWidget *parent = nullptr);
void init();
};

class DomeFrame: public QFrame {
public:
DomeFrame(QWidget *parent = nullptr);
void init();
};

class LightsFrame: public QStackedWidget {
Q_OBJECT
public:
LightsFrame();

public slots:
void init();
void showChoice();
void showLp();
void showSphere();
void showDome();

private:
QFrame *createLightsChoice();
QFrame *createLp();
QFrame *createSphere();
QFrame *createDome();
QFrame *createChoiceFrame();
LpFrame *lp = nullptr;
SphereFrame *sphere = nullptr;
DomeFrame *dome = nullptr;
};

class Card: public QFrame {
Q_OBJECT
public:
Card(QString title, QString subtitle, QWidget *parent = nullptr);
public slots:
void click() { emit clicked(); }
signals:
void clicked();
};


#endif // LIGHTSFRAME_H
13 changes: 12 additions & 1 deletion relightlab/relightapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QStyleFactory>
#include <QStyle>
#include <QAction>
#include <QMessageBox>

#include <QDebug>

Expand Down Expand Up @@ -84,7 +85,7 @@ RelightApp::RelightApp(int &argc, char **argv): QApplication(argc, argv) {
}

void RelightApp::run() {
qDebug() << QSettings().allKeys();
//qDebug() << "Settings: " << QSettings().allKeys();
bool dark = QSettings().value("dark", false).toBool();
if(dark) {
QIcon::setThemeName("dark");
Expand Down Expand Up @@ -136,6 +137,16 @@ void RelightApp::newProject() {
QMessageBox::critical(mainwindow, "Resolution problem", "Not all of the images in the folder have the same resolution,\nyou might need to fix this problem manually.");
}

QStringList img_ext;
img_ext << "*.lp";
QStringList lps = QDir(dir).entryList(img_ext);
if(lps.size() > 0) {
int answer = QMessageBox::question(this, "Found an .lp file: " + lps[0], "Do you wish to load " + lps[0] + "?", QMessageBox::Yes, QMessageBox::No);
if(answer != QMessageBox::No)
loadLP(lps[0]);
}


qRelightApp->project() = project;

mainwindow->initInterface();
Expand Down
6 changes: 1 addition & 5 deletions relightlab/relightlab.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += widgets svg
QT += widgets
CONFIG += c++11

#TODO: this might be needed in CMake
Expand Down Expand Up @@ -63,10 +63,6 @@ qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

FORMS += \
form.ui \
reform.ui

HEADERS += \
../relight/parameter.h \
../relight/processqueue.h \
Expand Down
1 change: 1 addition & 0 deletions src/project.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Project {
void load(QString filename);
void save(QString filename); //throws QString on error
void saveLP(QString filename, std::vector<Vector3f> &directions); //throws QString on error
void loadLP(QString filename);
void computeDirections();
void computePixelSize();

Expand Down

0 comments on commit 6b6126e

Please sign in to comment.