Skip to content

Commit c0f69f2

Browse files
committed
hsh and ptm enforces specific number of images.
1 parent a945ce6 commit c0f69f2

File tree

4 files changed

+54
-24
lines changed

4 files changed

+54
-24
lines changed

relightlab/rtiframe.cpp

+30-18
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,34 @@ void RtiFrame::exportRti() {
124124

125125
emit processStarted();
126126
}
127+
void RtiFrame::updateNPlanes() {
128+
// PLANES
129+
130+
auto &nplanes = parameters.nplanes;
131+
auto &nchroma = parameters.nchroma;
127132

133+
switch(parameters.basis) {
134+
case Rti::PTM:
135+
nplanes = parameters.colorspace == Rti::RGB? 18: 9;
136+
nchroma = 0;
137+
planes_row->forceNPlanes(nplanes);
138+
break;
139+
case Rti::HSH:
140+
nplanes = parameters.colorspace == Rti::RGB? 27 : 12;
141+
nchroma = 0;
142+
planes_row->forceNPlanes(nplanes);
143+
break;
144+
case Rti::RBF:
145+
case Rti::BILINEAR:
146+
if(parameters.colorspace != Rti::YCC) nchroma = 0;
147+
planes_row->forceNPlanes(-1);
148+
default:
149+
break;
150+
}
151+
152+
planes_row->setNPlanes(nplanes);
153+
planes_row->setNChroma(nchroma);
154+
}
128155

129156
void RtiFrame::basisChanged() {
130157
//when basis is changed we try to change the other values as little as possible.
@@ -146,23 +173,7 @@ void RtiFrame::basisChanged() {
146173
}
147174
colorspace_row->setColorspace(colorspace);
148175

149-
// PLANES
150-
151-
auto &nplanes = parameters.nplanes;
152-
auto &nchroma = parameters.nchroma;
153-
154-
switch(basis) {
155-
case Rti::PTM: nplanes = 18; nchroma = 0; break;
156-
case Rti::HSH: if(nplanes != 12 && nplanes != 27) nplanes = 27; nchroma = 0; break;
157-
case Rti::RBF:
158-
case Rti::BILINEAR:
159-
if(colorspace != Rti::YCC) nchroma = 0;
160-
default:
161-
break;
162-
}
163-
164-
planes_row->setNPlanes(nplanes);
165-
planes_row->setNChroma(nchroma);
176+
updateNPlanes();
166177

167178
//FORMAT
168179
format_row->allowLegacy(!pca);
@@ -174,7 +185,8 @@ void RtiFrame::basisChanged() {
174185
}
175186

176187
void RtiFrame::colorspaceChanged() {
177-
planes_row->setNChroma(parameters.nchroma);
188+
189+
updateNPlanes();
178190

179191
bool pca = parameters.basis == Rti::RBF || parameters.basis == Rti::BILINEAR;
180192
if(pca && parameters.format == RtiParameters::RTI) {

relightlab/rtiframe.h

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public slots:
5050
RtiQualityRow *quality_row = nullptr;
5151
RtiWebLayoutRow *layout_row = nullptr;
5252
RtiExportRow *export_row = nullptr;
53+
54+
void updateNPlanes();
5355
};
5456

5557

relightlab/rtiplan.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
#include <QLineEdit>
1212
#include <QButtonGroup>
1313
#include <QComboBox>
14+
#include <QStandardItemModel>
1415
#include <QLineEdit>
1516
#include <QFileDialog>
1617
#include <QMessageBox>
1718

19+
#include <iostream>
20+
using namespace std;
1821
RtiPlanRow::RtiPlanRow(RtiParameters &param, QFrame *parent): QFrame(parent), parameters(param) {
1922
QHBoxLayout *layout = new QHBoxLayout(this);
2023

@@ -147,9 +150,11 @@ RtiPlanesRow::RtiPlanesRow(RtiParameters &parameters, QFrame *parent): RtiPlanRo
147150
nplanesbox = new QComboBox;
148151
nplanesbox->setFixedWidth(100);
149152
for(int i = 0; i < 7; i++) {
150-
nplanesbox->addItem(QString::number(nimages[i]));
153+
nplanesbox->addItem(QString::number(nimages[i]), QVariant(nimages[i]));
151154
}
152-
connect(nplanesbox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int n) { setNPlanes(nimages[n]*3, true); });
155+
connect(nplanesbox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int n) {
156+
setNPlanes(nimages[n]*3, true);
157+
});
153158
buttons->addWidget(nplanesbox);
154159

155160
buttons->addStretch(1);
@@ -167,6 +172,17 @@ RtiPlanesRow::RtiPlanesRow(RtiParameters &parameters, QFrame *parent): RtiPlanRo
167172
setNChroma(parameters.nchroma);
168173
}
169174

175+
void RtiPlanesRow::forceNPlanes(int nplanes) {
176+
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(nplanesbox->model());
177+
Q_ASSERT(model != nullptr);
178+
for(int i = 0; i < 7; i++) {
179+
QStandardItem *item = model->item(i);
180+
bool disabled = nplanes >= 0 && nplanes != nimages[i]*3;
181+
item->setFlags(disabled ? item->flags() & ~Qt::ItemIsEnabled
182+
: item->flags() | Qt::ItemIsEnabled);
183+
}
184+
}
185+
170186
void RtiPlanesRow::setNPlanes(int nplanes, bool emitting) {
171187
nchromabox->setEnabled(parameters.colorspace == Rti::YCC);
172188

@@ -175,8 +191,8 @@ void RtiPlanesRow::setNPlanes(int nplanes, bool emitting) {
175191
emit nplanesChanged();
176192
return;
177193
}
178-
for(int i = 0; i < 7; i++) {
179-
if(nimages[i] == nplanes/3)
194+
for(int i = 0; i < nplanesbox->count(); i++) {
195+
if(nplanes/3 == nplanesbox->itemData(i).toInt())
180196
nplanesbox->setCurrentIndex(i);
181197
}
182198
}
@@ -399,7 +415,7 @@ void RtiExportRow::suggestPath() {
399415

400416
switch(parameters.basis) {
401417
case Rti::PTM: filename = parameters.colorspace == Rti::RGB ? "ptm" : "lptm"; break;
402-
case Rti::HSH: filename = "hsh"; break;
418+
case Rti::HSH: filename = parameters.colorspace == Rti::RGB ? "hsh" : "lhsh"; break;
403419
case Rti::RBF: filename = "rbf" + QString::number(parameters.nplanes); break;
404420
case Rti::BILINEAR: filename = "bln" + QString::number(parameters.nplanes); break;
405421
default: filename = "rti"; break;

relightlab/rtiplan.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class RtiPlanesRow: public RtiPlanRow {
5858
RtiPlanesRow(RtiParameters &parameters, QFrame *parent = nullptr);
5959
void setNPlanes(int nplanes, bool emitting = false);
6060
void setNChroma(int nchroma, bool emitting = false);
61-
61+
void forceNPlanes(int nplanes);
6262
private:
6363
QComboBox *nplanesbox, *nchromabox;
6464
int nimages[7] = { 3, 4, 5, 6, 7, 8, 9 };

0 commit comments

Comments
 (0)