1
1
#include " rtiframe.h"
2
+ #include " rtiplan.h"
2
3
#include " helpbutton.h"
3
4
#include " relightapp.h"
4
- #include " rticard.h"
5
- #include " flowlayout.h"
6
- #include " rtiplan.h"
7
- #include " rtirow.h"
8
5
#include " rtirecents.h"
9
- #include " rtiframe.h"
10
6
#include " qlabelbutton.h"
11
- # include " rtitask.h "
7
+
12
8
13
9
#include " processqueue.h"
14
10
25
21
#include < QScrollArea>
26
22
#include < QFileDialog>
27
23
28
- # include " rtiplan.h "
24
+
29
25
30
26
31
27
RtiFrame::RtiFrame (QWidget *parent): QFrame(parent) {
@@ -36,118 +32,81 @@ RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) {
36
32
37
33
content->addWidget (recents = new RtiRecents);
38
34
39
- content->addWidget (rti_plan = new RtiPlan, 1 );
40
- connect (rti_plan, SIGNAL (exportRti ()), this , SLOT (exportRti ()));
41
- return ;
35
+ basis_row = new RtiBasisRow (parameters, this );
36
+ colorspace_row = new RtiColorSpaceRow (parameters, this );
37
+ planes_row = new RtiPlanesRow (parameters, this );
38
+ format_row = new RtiFormatRow (parameters, this );
39
+ quality_row = new RtiQualityRow (parameters, this );
40
+ layout_row = new RtiWebLayoutRow (parameters, this );
41
+ export_row = new RtiExportRow (parameters, this );
42
42
43
- QScrollArea *area = new QScrollArea;
44
- area->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
45
- area->setWidgetResizable (true );
46
- content->addWidget (area, 1 );
47
43
48
- QWidget *widget = new QWidget;
49
- area->setWidget (widget);
44
+ content->addWidget (basis_row);
45
+ content->addWidget (colorspace_row);
46
+ content->addWidget (planes_row);
47
+ content->addWidget (format_row);
48
+ content->addWidget (quality_row);
49
+ content->addWidget (layout_row);
50
+ content->addWidget (export_row);
50
51
51
52
52
- FlowLayout *sample_layout = new FlowLayout (area->widget ());
53
-
54
- sample_layout->addWidget (new RtiCard (Rti::PTM, Rti::LRGB, 9 , 0 ));
55
- sample_layout->addWidget (new RtiCard (Rti::PTM, Rti::RGB, 18 , 0 ));
56
- sample_layout->addWidget (new RtiCard (Rti::HSH, Rti::RGB, 27 , 0 ));
57
53
54
+ connect (basis_row, &RtiBasisRow::basisChanged, this , &RtiFrame::basisChanged);
55
+ connect (colorspace_row, &RtiColorSpaceRow::colorspaceChanged, this , &RtiFrame::colorspaceChanged);
56
+ connect (planes_row, &RtiPlanesRow::nplanesChanged, this , &RtiFrame::nplanesChanged);
57
+ connect (format_row, &RtiFormatRow::formatChanged, this , &RtiFrame::formatChanged);
58
+ connect (layout_row, &RtiWebLayoutRow::layoutChanged, this , &RtiFrame::layoutChanged);
59
+ connect (quality_row, &RtiQualityRow::qualityChanged, this , &RtiFrame::qualityChanged);
58
60
59
- sample_layout-> addWidget ( new RtiCard (Rti::RBF, Rti::MRGB, 18 , 0 ));
60
- sample_layout-> addWidget ( new RtiCard (Rti::BILINEAR, Rti::MRGB, 18 , 0 )) ;
61
+ {
62
+ QHBoxLayout *save_row = new QHBoxLayout ;
61
63
64
+ {
65
+ QLabel *label = new QLabel (" " );
66
+ label->setFixedWidth (200 );
67
+ save_row->addWidget (label, 0 , Qt::AlignLeft);
68
+ }
69
+ save_row->addStretch (1 );
62
70
71
+ {
72
+ QFrame *buttons_frame = new QFrame;
73
+ buttons_frame->setMinimumWidth (860 );
63
74
64
- /*
65
- QGroupBox *model = new QGroupBox("Model");
66
- content->addWidget(model);
67
- QVBoxLayout *model_layout = new QVBoxLayout(model);
68
- model_layout->addWidget(new HelpRadio("Polynomial Texture Maps (PTM)", "rti/ptm"));
69
- model_layout->addWidget(new HelpRadio("HemiSpherical Harmonics (HSH)", "rti/hsh"));
70
- model_layout->addWidget(new HelpRadio("Radial Basis Functions (RBF)", "rti/rbf"));
71
- model_layout->addWidget(new HelpRadio("Bilinear sampling (BNL)", "rti/bln"));
72
- model_layout->addWidget(new HelpRadio("Neural network", "rti/neural"));
73
-
74
- QGroupBox *colorspace= new QGroupBox("Colorspace");
75
- content->addWidget(colorspace);
76
- QVBoxLayout *colorspace_layout = new QVBoxLayout(colorspace);
77
- colorspace_layout->addWidget(new HelpRadio("RGB", "rti/rgb"));
78
- colorspace_layout->addWidget(new HelpRadio("LRGB", "rti/lrgb"));
79
- colorspace_layout->addWidget(new HelpRadio("MRGB", "rti/mrgb"));
80
- colorspace_layout->addWidget(new HelpRadio("YCC", "rti/ycc"));
81
-
82
- QGroupBox *planes = new QGroupBox("Planes");
83
- content->addWidget(planes);
84
-
85
- QGridLayout *planes_layout = new QGridLayout(planes);
86
- planes_layout->addWidget(new HelpLabel("Total number of planes:", "rti/planes"), 0, 0);
87
-
88
- QSpinBox *total_planes = new QSpinBox;
89
- planes_layout->addWidget(total_planes, 0, 1);
75
+ {
76
+ QHBoxLayout *buttons_layout = new QHBoxLayout (buttons_frame);
90
77
91
- planes_layout->addWidget(new HelpLabel("Number of luminance planes:", "rti/luminance"), 1, 0);
78
+ buttons_layout->addStretch (1 );
79
+ QPushButton *save = new QPushButton (" Export" , this );
80
+ save->setIcon (QIcon::fromTheme (" save" ));
81
+ save->setProperty (" class" , " large" );
82
+ save->setMinimumWidth (200 );
83
+ connect (save, &QPushButton::clicked, [this ]() { emit exportRti (); });
92
84
93
- QSpinBox *luminance_planes = new QSpinBox;
94
- planes_layout->addWidget(luminance_planes, 1, 1);
95
- */
96
- /*
97
- QGroupBox *legacy = new QGroupBox("Export .rti for RtiViewer");
98
- content->addWidget(legacy);
85
+ buttons_layout->addWidget (save);
86
+ }
99
87
100
- QGridLayout *legacy_layout = new QGridLayout(legacy );
101
-
102
- legacy_layout->addWidget(new HelpRadio("Lossless (heavy!)", "rti/legacy"), 0, 0 );
88
+ save_row-> addWidget (buttons_frame );
89
+ }
90
+ save_row-> addStretch ( 1 );
103
91
104
- legacy_layout->addWidget(new HelpRadio("JPEG", "rti/legacy"), 1, 0);
105
- legacy_layout->addWidget(new HelpLabel("Quality:", "rti/legacy"), 1, 1);
106
- QSpinBox *quality = new QSpinBox;
107
- legacy_layout->addWidget(quality, 1, 2);
108
92
109
- legacy_layout->addWidget(new QLabel("Filename:"), 2, 0);
110
- legacy_layout->addWidget(new QLineEdit(), 2, 1);
111
- legacy_layout->addWidget(new QPushButton("..."), 2, 2);
93
+ content->addLayout (save_row);
112
94
113
- legacy_layout->addWidget(new QPushButton("Export"), 3, 2); */
95
+ }
114
96
115
97
content->addStretch ();
98
+
116
99
}
117
100
118
101
void RtiFrame::exportRti () {
119
102
120
103
// check for lights
121
104
if (qRelightApp->project ().dome .directions .size () == 0 ) {
122
105
QMessageBox::warning (this , " Missing light directions." , " You need light directions for this dataset to build an RTI.\n "
123
- " You can either load a dome or .lp file or mark a reflective sphere in the 'Lights' tab." );
106
+ " You can either load a dome or .lp file or mark a reflective sphere in the 'Lights' tab." );
124
107
return ;
125
108
}
126
- RtiParameters ¶meters = rti_plan->parameters ;
127
- // get folder if not legacy.
128
- QString output;
129
- if (parameters.format == RtiParameters::RTI) {
130
- QString extension;
131
- QString label;
132
-
133
- if (parameters.basis == Rti::HSH) {
134
- extension = " .rti" ;
135
- label = " RTI file (*.rti)" ;
136
- } else if (parameters.basis == Rti::PTM) {
137
- extension = " .ptm" ;
138
- label = " PTM file (*.ptm)" ;
139
- }
140
- output = QFileDialog::getSaveFileName (this , " Select a file name" , QString (), label);
141
- if (output.isNull ()) return ;
142
109
143
- if (!output.endsWith (extension))
144
- output += extension;
145
-
146
- } else {
147
- output = QFileDialog::getSaveFileName (this , " Select an output folder" , QString ());
148
- if (output.isNull ()) return ;
149
- }
150
- parameters.path = output;
151
110
152
111
RtiTask *rti_task = new RtiTask (qRelightApp->project ());
153
112
rti_task->parameters = parameters;
@@ -159,3 +118,79 @@ void RtiFrame::exportRti() {
159
118
}
160
119
161
120
121
+ void RtiFrame::basisChanged () {
122
+ // when basis is changed we try to change the other values as little as possible.
123
+ // if the new basis is not compatible with the current color space we change it to the default one
124
+ // colorspace:
125
+ auto &basis = parameters.basis ;
126
+ bool pca = basis == Rti::RBF || basis == Rti::BILINEAR;
127
+
128
+ // COLORSPACE
129
+
130
+ auto &colorspace = parameters.colorspace ;
131
+ if (!pca) {
132
+ if (colorspace != Rti::RGB && colorspace != Rti::LRGB)
133
+ colorspace = Rti::RGB;
134
+
135
+ } else {
136
+ if (colorspace != Rti::MRGB && colorspace != Rti::YCC)
137
+ colorspace = Rti::MRGB;
138
+ }
139
+ colorspace_row->setColorspace (colorspace);
140
+
141
+ // PLANES
142
+
143
+ auto &nplanes = parameters.nplanes ;
144
+ auto &nchroma = parameters.nchroma ;
145
+
146
+ switch (basis) {
147
+ case Rti::PTM: nplanes = 18 ; nchroma = 0 ; break ;
148
+ case Rti::HSH: if (nplanes != 12 && nplanes != 27 ) nplanes = 27 ; nchroma = 0 ; break ;
149
+ case Rti::RBF:
150
+ case Rti::BILINEAR:
151
+ if (colorspace != Rti::YCC) nchroma = 0 ;
152
+ }
153
+
154
+ planes_row->setNPlanes (nplanes);
155
+ planes_row->setNChroma (nchroma);
156
+
157
+ // FORMAT
158
+ format_row->allowLegacy (!pca);
159
+
160
+ if (pca && parameters.format == RtiParameters::RTI) {
161
+ format_row->setFormat (RtiParameters::WEB); // emit and cascade update other rows.
162
+ }
163
+ export_row->suggestPath ();
164
+ }
165
+
166
+ void RtiFrame::colorspaceChanged () {
167
+ planes_row->setNChroma (parameters.nchroma );
168
+
169
+ bool pca = parameters.basis == Rti::RBF || parameters.basis == Rti::BILINEAR;
170
+ if (pca && parameters.format == RtiParameters::RTI) {
171
+ format_row->setFormat (RtiParameters::WEB);
172
+ }
173
+ export_row->suggestPath ();
174
+
175
+ }
176
+
177
+ void RtiFrame::nplanesChanged () {
178
+ export_row->suggestPath ();
179
+ }
180
+
181
+ void RtiFrame::formatChanged () {
182
+ bool legacy = quality_row->parameters .format == RtiParameters::RTI;
183
+ // only RTI allows for lossless.
184
+ quality_row->allowLossless (legacy);
185
+ layout_row->setEnabled (quality_row->parameters .format == RtiParameters::WEB);
186
+ export_row->suggestPath ();
187
+ }
188
+
189
+ void RtiFrame::qualityChanged () {
190
+ }
191
+
192
+ void RtiFrame::layoutChanged () {
193
+
194
+ }
195
+
196
+
0 commit comments