diff --git a/relight/mainwindow.cpp b/relight/mainwindow.cpp index 39b98f5f..52c1090d 100644 --- a/relight/mainwindow.cpp +++ b/relight/mainwindow.cpp @@ -871,6 +871,7 @@ void MainWindow::loadLP(QString lp) { project.images[i].direction = directions[i]; } } + void MainWindow::saveLPs() { int count = 1; QString basename = "sphere"; diff --git a/relight/parameter.cpp b/relight/parameter.cpp index c598b296..3487dfe9 100644 --- a/relight/parameter.cpp +++ b/relight/parameter.cpp @@ -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; } diff --git a/relightlab/css/style.qss b/relightlab/css/style.qss index 1ed641e5..87f9727f 100644 --- a/relightlab/css/style.qss +++ b/relightlab/css/style.qss @@ -6,6 +6,7 @@ QPushButton.large { padding-left:12px; padding-top:8px; padding-bottom:8px; + max-width:200px; } @@ -18,6 +19,3 @@ QLabel.recent:hover{ background-color: palette(mid); } -QFrame#lights_choice QPushButton { - padding:20px -} diff --git a/relightlab/homeframe.cpp b/relightlab/homeframe.cpp index 2e50710c..e6738662 100644 --- a/relightlab/homeframe.cpp +++ b/relightlab/homeframe.cpp @@ -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("

RelightLab

"); titleLabel->setMinimumWidth(200); leftColumnLayout->addWidget(titleLabel); @@ -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("

Recent projects:

"); + leftColumnLayout->addSpacing(20); leftColumnLayout->addWidget(recentLabel); @@ -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); @@ -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); diff --git a/relightlab/lightsframe.cpp b/relightlab/lightsframe.cpp index 0469aefd..71e82bc2 100644 --- a/relightlab/lightsframe.cpp +++ b/relightlab/lightsframe.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include Card::Card(QString title, QString subtitle, QWidget *parent): QFrame(parent) { setFrameShape(QFrame::StyledPanel); @@ -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); @@ -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); @@ -42,18 +57,16 @@ QFrame *LightsFrame::createLightsChoice() { buttons->addStretch(1); Card *lp = new Card("LP", "

Load a file (.lp) containging the light directions.

"); - + 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", "

Identify one or more reflective spheres

"); 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", "

Select a preconfigure dome

"); connect(dome, SIGNAL(clicked()), this, SLOT(showDome())); - dome->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - buttons->addWidget(dome, 0); + buttons->addWidget(dome, 1); buttons->addStretch(1); @@ -61,26 +74,71 @@ QFrame *LightsFrame::createLightsChoice() { 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("

LP light directions

"); + 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("

Sphere light directions

"); + content->addWidget(title); +} + +void SphereFrame::init() { +} + +DomeFrame::DomeFrame(QWidget *parent): QFrame(parent) { + QVBoxLayout *content = new QVBoxLayout(this); + this->setLayout(content); + + QLabel *title = new QLabel("

Dome light directions

"); + content->addWidget(title); } + +void DomeFrame::init() { +} + diff --git a/relightlab/lightsframe.h b/relightlab/lightsframe.h index e0bc7151..796f86c1 100644 --- a/relightlab/lightsframe.h +++ b/relightlab/lightsframe.h @@ -3,32 +3,61 @@ #include +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 diff --git a/relightlab/relightapp.cpp b/relightlab/relightapp.cpp index 70a4f977..f48060fe 100644 --- a/relightlab/relightapp.cpp +++ b/relightlab/relightapp.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -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"); @@ -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(); diff --git a/relightlab/relightlab.pro b/relightlab/relightlab.pro index c7466d29..3a388ff7 100644 --- a/relightlab/relightlab.pro +++ b/relightlab/relightlab.pro @@ -1,4 +1,4 @@ -QT += widgets svg +QT += widgets CONFIG += c++11 #TODO: this might be needed in CMake @@ -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 \ diff --git a/src/project.h b/src/project.h index 34907068..bdef8cdd 100644 --- a/src/project.h +++ b/src/project.h @@ -58,6 +58,7 @@ class Project { void load(QString filename); void save(QString filename); //throws QString on error void saveLP(QString filename, std::vector &directions); //throws QString on error + void loadLP(QString filename); void computeDirections(); void computePixelSize();