Skip to content

Commit 6b6126e

Browse files
committed
lp loading.
1 parent 2035ed3 commit 6b6126e

9 files changed

+149
-52
lines changed

relight/mainwindow.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ void MainWindow::loadLP(QString lp) {
871871
project.images[i].direction = directions[i];
872872
}
873873
}
874+
874875
void MainWindow::saveLPs() {
875876
int count = 1;
876877
QString basename = "sphere";

relight/parameter.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ QStringList Parameter::arguments() {
2727
break;
2828
case TMP_FILE: //Script will fill it in.
2929
break;
30+
default:
31+
throw "parameter type not supported";
32+
break;
3033
}
3134
return list;
3235
}

relightlab/css/style.qss

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ QPushButton.large {
66
padding-left:12px;
77
padding-top:8px;
88
padding-bottom:8px;
9+
max-width:200px;
910
}
1011

1112

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

21-
QFrame#lights_choice QPushButton {
22-
padding:20px
23-
}

relightlab/homeframe.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ HomeFrame::HomeFrame() {
2020

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

2525
// Left column
2626
QVBoxLayout *leftColumnLayout = new QVBoxLayout();
2727

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

3332
leftColumnLayout->addWidget(titleLabel);
@@ -42,7 +41,8 @@ HomeFrame::HomeFrame() {
4241
setDefaultAction(open_project, qRelightApp->action("open_project"));
4342
leftColumnLayout->addWidget(open_project);
4443

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

4848

@@ -56,7 +56,7 @@ HomeFrame::HomeFrame() {
5656
leftColumnLayout->addStretch();
5757

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

6161
// Right column
6262
QTextBrowser *browser = new QTextBrowser(this);
@@ -66,9 +66,9 @@ HomeFrame::HomeFrame() {
6666
file.open(QIODevice::ReadOnly);
6767
browser->setText(file.readAll());
6868
browser->setMinimumWidth(400);
69-
contentLayout->addWidget(browser);
69+
contentLayout->addWidget(browser, 2);
7070

71-
contentLayout->addStretch();
71+
contentLayout->addStretch(1);
7272

7373
// Set layout margins and spacing
7474
contentLayout->setContentsMargins(20, 20, 20, 20);

relightlab/lightsframe.cpp

+81-23
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <QButtonGroup>
66
#include <QPushButton>
77
#include <QLabel>
8+
#include <QDebug>
9+
#include <QFileDialog>
810

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

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

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

2729
LightsFrame::LightsFrame() {
28-
this->addWidget(createLightsChoice());
30+
addWidget(createChoiceFrame());
31+
lp = new LpFrame();
32+
addWidget(lp);
33+
sphere = new SphereFrame();
34+
addWidget(sphere);
35+
dome = new DomeFrame();
36+
addWidget(dome);
2937
}
30-
QFrame *LightsFrame::createLightsChoice() {
38+
39+
void LightsFrame::init() {
40+
lp->init();
41+
sphere->init();
42+
dome->init();
43+
}
44+
45+
QFrame *LightsFrame::createChoiceFrame() {
3146
QFrame *lights_choice = new QFrame();
32-
lights_choice->setObjectName("lights_choice");
47+
//lights_choice->setObjectName("lights_choice");
3348

3449
QVBoxLayout *content = new QVBoxLayout(lights_choice);
3550

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

4459
Card *lp = new Card("LP", "<p>Load a file (.lp) containging the light directions.</p>");
45-
60+
connect(lp, SIGNAL(clicked()), this, SLOT(showLp()));
4661
buttons->addWidget(lp, 1);
4762

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

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

5871
buttons->addStretch(1);
5972

6073
content->addStretch(2);
6174
return lights_choice;
6275
}
6376

64-
QFrame *LightsFrame::createLp() {
65-
QFrame *lp_frame = new QFrame();
66-
return lp_frame;
77+
void LightsFrame::showChoice() {
78+
79+
setCurrentIndex(0);
80+
}
81+
void LightsFrame::showLp() {
82+
setCurrentWidget(lp);
6783
}
6884

69-
QFrame *LightsFrame::createSphere() {
70-
QFrame *sphere_frame = new QFrame();
71-
return sphere_frame;
85+
void LightsFrame::showSphere() {
86+
setCurrentIndex(2);
7287
}
7388

74-
QFrame *LightsFrame::createDome() {
75-
QFrame *dome_frame = new QFrame();
76-
return dome_frame;
89+
void LightsFrame::showDome() {
90+
setCurrentIndex(3);
7791
}
7892

79-
void LightsFrame::showLp() {
93+
94+
95+
LpFrame::LpFrame(QWidget *parent): QFrame(parent) {
96+
QVBoxLayout *content = new QVBoxLayout(this);
97+
content->setContentsMargins(31, 31, 31, 31);
98+
this->setLayout(content);
99+
100+
QLabel *title = new QLabel("<h2>LP light directions</h2>");
101+
content->addWidget(title);
102+
content->addSpacing(30);
103+
QHBoxLayout *filebox = new QHBoxLayout();
104+
QPushButton *load = new QPushButton("Load LP file...");
105+
connect(load, SIGNAL(clicked()), this, SLOT(loadLP()));
106+
load->setMaximumWidth(300);
107+
filebox->addWidget(load);
108+
QLabel *filename = new QLabel();
109+
filebox->addWidget(filename);
110+
111+
content->addLayout(filebox);
112+
content->addStretch();
80113
}
81114

82-
void LightsFrame::showSphere() {
115+
void LpFrame::init() {
83116
}
84117

85-
void LightsFrame::showDome() {
118+
void LpFrame::loadLP() {
119+
120+
QFileDialog::getOpenFileName(this, "Load an LP file", )
121+
}
122+
123+
SphereFrame::SphereFrame(QWidget *parent): QFrame(parent) {
124+
QVBoxLayout *content = new QVBoxLayout(this);
125+
this->setLayout(content);
126+
127+
QLabel *title = new QLabel("<h2>Sphere light directions</h2>");
128+
content->addWidget(title);
129+
}
130+
131+
void SphereFrame::init() {
132+
}
133+
134+
DomeFrame::DomeFrame(QWidget *parent): QFrame(parent) {
135+
QVBoxLayout *content = new QVBoxLayout(this);
136+
this->setLayout(content);
137+
138+
QLabel *title = new QLabel("<h2>Dome light directions</h2>");
139+
content->addWidget(title);
86140
}
141+
142+
void DomeFrame::init() {
143+
}
144+

relightlab/lightsframe.h

+42-13
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,61 @@
33

44
#include <QStackedWidget>
55

6+
class QLabel;
7+
8+
class Card: public QFrame {
9+
Q_OBJECT
10+
public:
11+
Card(QString title, QString subtitle, QWidget *parent = nullptr);
12+
public slots:
13+
void click() { emit clicked(); }
14+
signals:
15+
void clicked();
16+
};
17+
18+
class LpFrame: public QFrame {
19+
Q_OBJECT
20+
public:
21+
LpFrame(QWidget *parent = nullptr);
22+
void init();
23+
void loadLP(QString filename);
24+
public slots:
25+
void loadLP();
26+
private:
27+
QLabel *filename;
28+
};
29+
30+
class SphereFrame: public QFrame {
31+
public:
32+
SphereFrame(QWidget *parent = nullptr);
33+
void init();
34+
};
35+
36+
class DomeFrame: public QFrame {
37+
public:
38+
DomeFrame(QWidget *parent = nullptr);
39+
void init();
40+
};
41+
642
class LightsFrame: public QStackedWidget {
743
Q_OBJECT
844
public:
945
LightsFrame();
1046

1147
public slots:
48+
void init();
49+
void showChoice();
1250
void showLp();
1351
void showSphere();
1452
void showDome();
1553

1654
private:
17-
QFrame *createLightsChoice();
18-
QFrame *createLp();
19-
QFrame *createSphere();
20-
QFrame *createDome();
55+
QFrame *createChoiceFrame();
56+
LpFrame *lp = nullptr;
57+
SphereFrame *sphere = nullptr;
58+
DomeFrame *dome = nullptr;
2159
};
2260

23-
class Card: public QFrame {
24-
Q_OBJECT
25-
public:
26-
Card(QString title, QString subtitle, QWidget *parent = nullptr);
27-
public slots:
28-
void click() { emit clicked(); }
29-
signals:
30-
void clicked();
31-
};
3261

3362

3463
#endif // LIGHTSFRAME_H

relightlab/relightapp.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QStyleFactory>
1111
#include <QStyle>
1212
#include <QAction>
13+
#include <QMessageBox>
1314

1415
#include <QDebug>
1516

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

8687
void RelightApp::run() {
87-
qDebug() << QSettings().allKeys();
88+
//qDebug() << "Settings: " << QSettings().allKeys();
8889
bool dark = QSettings().value("dark", false).toBool();
8990
if(dark) {
9091
QIcon::setThemeName("dark");
@@ -136,6 +137,16 @@ void RelightApp::newProject() {
136137
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.");
137138
}
138139

140+
QStringList img_ext;
141+
img_ext << "*.lp";
142+
QStringList lps = QDir(dir).entryList(img_ext);
143+
if(lps.size() > 0) {
144+
int answer = QMessageBox::question(this, "Found an .lp file: " + lps[0], "Do you wish to load " + lps[0] + "?", QMessageBox::Yes, QMessageBox::No);
145+
if(answer != QMessageBox::No)
146+
loadLP(lps[0]);
147+
}
148+
149+
139150
qRelightApp->project() = project;
140151

141152
mainwindow->initInterface();

relightlab/relightlab.pro

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
QT += widgets svg
1+
QT += widgets
22
CONFIG += c++11
33

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

66-
FORMS += \
67-
form.ui \
68-
reform.ui
69-
7066
HEADERS += \
7167
../relight/parameter.h \
7268
../relight/processqueue.h \

src/project.h

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Project {
5858
void load(QString filename);
5959
void save(QString filename); //throws QString on error
6060
void saveLP(QString filename, std::vector<Vector3f> &directions); //throws QString on error
61+
void loadLP(QString filename);
6162
void computeDirections();
6263
void computePixelSize();
6364

0 commit comments

Comments
 (0)