Skip to content

Commit

Permalink
rti plan update
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Jul 2, 2024
1 parent cd337e7 commit 8676326
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 79 deletions.
4 changes: 2 additions & 2 deletions relight/rtitask.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class RtiParameters {
public:

enum Format { RTI = 0, WEB = 1, IIP = 2 };
enum WebFormat { PLAIN = 0, DEEPZOOM = 1, TARZOOM = 2, ITARZOOM = 3 };
enum WebLayout { PLAIN = 0, DEEPZOOM = 1, TARZOOM = 2, ITARZOOM = 3 };

Rti::Type basis;
Rti::ColorSpace colorspace;
int nplanes;
int nchroma;

Format format;
WebFormat webFormat;
WebLayout webFormat;

bool lossless = false; //used only for RTI format;

Expand Down
197 changes: 140 additions & 57 deletions relightlab/rtiplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSpinBox>
#include <QCheckBox>
#include <QLineEdit>
#include <QButtonGroup>
#include <QComboBox>
Expand Down Expand Up @@ -36,29 +37,27 @@ RtiBasisRow::RtiBasisRow(QFrame *parent): RtiPlanRow(parent) {
label->label->setText("Basis:");
label->help->setId("rti/basis");

QButtonGroup *group = new QButtonGroup(this);

auto *ptm = new QLabelButton("PTM", "Polynomial Texture Map");
group->addButton(ptm);
buttons->addWidget(ptm, 0, Qt::AlignCenter);
connect(ptm, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::PTM);});

auto *hsh = new QLabelButton("HSH", "HemiSpherical Harmonics");
group->addButton(hsh);
buttons->addWidget(hsh, 0, Qt::AlignCenter);
connect(hsh, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::HSH);});

auto *rbf = new QLabelButton("RBF", "Radial Basis Functions");
group->addButton(rbf);
buttons->addWidget(rbf, 0, Qt::AlignCenter);
connect(rbf, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::RBF);});

auto *bnl = new QLabelButton("BNL", "Bilinear interplation");
group->addButton(bnl);

buttons->addWidget(ptm, 0, Qt::AlignCenter);
buttons->addWidget(hsh, 0, Qt::AlignCenter);
buttons->addWidget(rbf, 0, Qt::AlignCenter);
buttons->addWidget(bnl, 0, Qt::AlignCenter);

connect(ptm, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::PTM);});
connect(hsh, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::HSH);});
connect(rbf, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::RBF);});
connect(bnl, &QAbstractButton::clicked, this, [this](){emit basisChanged(Rti::BILINEAR);});

QButtonGroup *group = new QButtonGroup(this);

group->addButton(ptm);
group->addButton(hsh);
group->addButton(rbf);
group->addButton(bnl);
}

void RtiBasisRow::init(Rti::Type basis) {
Expand All @@ -70,26 +69,35 @@ RtiColorSpaceRow::RtiColorSpaceRow(QFrame *parent): RtiPlanRow(parent) {
label->label->setText("Colorspace:");
label->help->setId("rti/colorspace");

rgb = new QLabelButton("RGB", "Standard");
lrgb = new QLabelButton("LRGB", "Albedo * Luminance.");
mrgb = new QLabelButton("MRGB", "Standard");
ycc = new QLabelButton("YCC", "Dedicated chroma coefficients.");

QButtonGroup *group = new QButtonGroup(this);
auto *rgb = new QLabelButton("RGB", "Standard");
group->addButton(rgb);
buttons->addWidget(rgb, 0, Qt::AlignLeft);
connect(rgb, &QAbstractButton::clicked, this, [this](){emit colorspaceChanged(Rti::RGB);});
buttons->addWidget(lrgb, 0, Qt::AlignRight);
buttons->addWidget(mrgb, 0, Qt::AlignLeft);
buttons->addWidget(ycc, 0, Qt::AlignRight);

auto *lrgb = new QLabelButton("LRGB", "Albedo * Luminance.");
group->addButton(lrgb);
buttons->addWidget(lrgb, 0, Qt::AlignCenter);
connect(rgb, &QAbstractButton::clicked, this, [this](){emit colorspaceChanged(Rti::RGB);});
connect(lrgb, &QAbstractButton::clicked, this, [this](){emit colorspaceChanged(Rti::LRGB);});
connect(mrgb, &QAbstractButton::clicked, this, [this](){emit colorspaceChanged(Rti::MRGB);});
connect(ycc, &QAbstractButton::clicked, this, [this](){emit colorspaceChanged(Rti::YCC);});

auto *ycc = new QLabelButton("YCC", "Dedicated chroma coefficients.");
QButtonGroup *group = new QButtonGroup(this);
group->addButton(rgb);
group->addButton(lrgb);
group->addButton(mrgb);
group->addButton(ycc);
buttons->addWidget(ycc, 0, Qt::AlignRight);
connect(ycc, &QAbstractButton::clicked, this, [this](){emit colorspaceChanged(Rti::YCC);});

}

void RtiColorSpaceRow::init(Rti::ColorSpace colorspace) {
void RtiColorSpaceRow::init(Rti::Type basis, Rti::ColorSpace colorspace) {
bool pca = basis == Rti::RBF || basis == Rti::BILINEAR;

rgb->setVisible(!pca);
lrgb->setVisible(!pca);
mrgb->setVisible(pca);
ycc->setVisible(pca);
this->colorspace = colorspace;
}

Expand All @@ -101,26 +109,29 @@ RtiPlanesRow::RtiPlanesRow(QFrame *parent): RtiPlanRow(parent) {


buttons->addWidget(new QLabel("Total number of images:"));
auto *total_images = new QComboBox;
total_images->setFixedWidth(100);
nplanesbox = new QComboBox;
nplanesbox->setFixedWidth(100);
int nimages[] = { 3, 4, 5, 6, 7, 8, 9 };
for(int i = 0; i < 7; i++) {
total_images->addItem(QString::number(nimages[i]));
nplanesbox->addItem(QString::number(nimages[i]));
}
buttons->addWidget(total_images);
buttons->addWidget(nplanesbox);

buttons->addStretch(1);
buttons->addWidget(new QLabel("Number of dedicated chroma images:"));
auto *chroma = new QComboBox;
chroma->setFixedWidth(100);
nchromabox = new QComboBox;
nchromabox->setFixedWidth(100);
int nchroma[] = { 1, 2, 3 };
for(int i = 0; i < 3; i++) {
chroma->addItem(QString::number(nchroma[i]));
nchromabox->addItem(QString::number(nchroma[i]));
}
buttons->addWidget(chroma);
buttons->addWidget(nchromabox);
}

void RtiPlanesRow::init(int nplanes, int nchroma) {
void RtiPlanesRow::init(Rti::ColorSpace colorspace, int nplanes, int nchroma) {
nplanesbox->setCurrentIndex(nplanes/3 - 3);
nchromabox->setCurrentIndex(nchroma -1);

this->nplanes = nplanes;
this->nchroma = nchroma;
}
Expand All @@ -129,24 +140,58 @@ RtiFormatRow::RtiFormatRow(QFrame *parent): RtiPlanRow(parent) {
label->label->setText("Format:");
label->help->setId("rti/format");

rti = new QLabelButton("legacy (.rti, .ptm)");
buttons->addWidget(rti, Qt::AlignLeft);

web = new QLabelButton("web (json + jpeg");
buttons->addWidget(web, Qt::AlignLeft);
rti = new QLabelButton("Legacy", ".rti, .ptm");
web = new QLabelButton("Web", ".json, .jpg");
iip = new QLabelButton("IIP", ".tiff");

iip = new QLabelButton("iip (tiff)");
buttons->addWidget(rti, Qt::AlignLeft);
buttons->addWidget(web, Qt::AlignLeft);
buttons->addWidget(iip, Qt::AlignLeft);

/* buttons->addWidget(new QLabelButton("Lossless (heavy!)"));
buttons->addWidget(new QLabelButton("JPEG"));
buttons->addWidget(new QLabel("Quality:"));
buttons->addWidget(new QSpinBox);
buttons->addWidget(new QLabel("Filename:"));
QButtonGroup *group = new QButtonGroup(this);
group->addButton(rti);
group->addButton(web);
group->addButton(iip);

}

RtiQualityRow::RtiQualityRow(QFrame *parent): RtiPlanRow(parent) {
label->label->setText("Image quality:");
label->help->setId("rti/quality");

buttons->addWidget(new QCheckBox(" Lossless"), Qt::AlignLeft);

QLabel *qualitylabel = new QLabel("Quality:");
qualitylabel->setMaximumWidth(200);
buttons->addWidget(qualitylabel, Qt::AlignRight);

qualitybox = new QSpinBox;
qualitybox->setMaximumWidth(200);
qualitybox->setMinimum(75);
qualitybox->setMaximum(100);
qualitybox->setValue(quality);
buttons->addWidget(qualitybox, Qt::AlignRight);


/*buttons->addWidget(new QLabel("Filename:"));
buttons->addWidget(new QLineEdit);
buttons->addWidget(new QPushButton("..."));
buttons->addWidget(new QPushButton("Export")); */
}
void RtiQualityRow::init(int quality) {

}

RtiWebLayoutRow::RtiWebLayoutRow(QFrame *parent) {
label->label->setText("Web layout:");
label->help->setId("rti/web_layout");

}
void RtiWebLayoutRow::init(RtiParameters::WebLayout layout) {

} //0 stands for lossless.


void RtiFormatRow::init(RtiParameters::Format format) {
this->format = format;
Expand All @@ -156,28 +201,56 @@ RtiPlan::RtiPlan(QWidget *parent): QFrame(parent) {
QVBoxLayout *layout = new QVBoxLayout(this);

basis_row = new RtiBasisRow(this);
layout->addWidget(basis_row);
connect(basis_row, &RtiBasisRow::basisChanged, this, &RtiPlan::basisChanged);

colorspace_row = new RtiColorSpaceRow(this);
layout->addWidget(colorspace_row);
connect(colorspace_row, &RtiColorSpaceRow::colorspaceChanged, this, &RtiPlan::colorspaceChanged);

planes_row = new RtiPlanesRow(this);
layout->addWidget(planes_row);
connect(planes_row, &RtiPlanesRow::nplanesChanged, this, &RtiPlan::nplanesChanged);

format_row = new RtiFormatRow(this);
layout->addWidget(format_row);
connect(format_row, &RtiFormatRow::formatChanged, this, &RtiPlan::formatChanged);
quality_row = new RtiQualityRow(this);

layout->addWidget(basis_row);
layout->addWidget(colorspace_row);
layout->addWidget(planes_row);
layout->addWidget(format_row);
layout->addWidget(quality_row);
layout->addStretch();

connect(basis_row, &RtiBasisRow::basisChanged, this, &RtiPlan::basisChanged);
connect(colorspace_row, &RtiColorSpaceRow::colorspaceChanged, this, &RtiPlan::colorspaceChanged);
connect(planes_row, &RtiPlanesRow::nplanesChanged, this, &RtiPlan::nplanesChanged);
connect(format_row, &RtiFormatRow::formatChanged, this, &RtiPlan::formatChanged);
connect(quality_row, &RtiQualityRow::qualityChanged, this, &RtiPlan::qualityChanged);
}


void RtiPlan::basisChanged(Rti::Type basis) {
//when basis is changed we try to change the other values as little as possible.
//if the new basis is not compatible with the current color space we change it to the default one
//colorspace:
parameters.basis = basis;
bool pca = basis == Rti::RBF || basis == Rti::BILINEAR;

auto &colorspace = parameters.colorspace;
if(pca) {
if(colorspace != Rti::RGB && colorspace != Rti::LRGB)
colorspace = Rti::RGB;

} else {
if(colorspace != Rti::MRGB && colorspace != Rti::YCC)
colorspace = Rti::MRGB;
}
colorspace_row->init(basis, colorspace);

auto &nplanes = parameters.nplanes;
auto &nchroma = parameters.nchroma;
switch(basis) {
case Rti::PTM: nplanes = 18; nchroma = 0; break;
case Rti::HSH: if(nplanes != 12 && nplanes != 27) nplanes = 27; nchroma = 0; break;
case Rti::RBF:
case Rti::BILINEAR:
if(colorspace != Rti::YCC) nchroma = 0;
}

planes_row->init(colorspace, nplanes, nchroma);


}

Expand All @@ -198,3 +271,13 @@ void RtiPlan::formatChanged(RtiParameters::Format format) {
//if the new format is not compatible with the current basis we change it to the default one

}

void RtiPlan::qualityChanged(int quality) {


}

void RtiPlan::layoutChanged(RtiParameters::WebLayout layout) {

}

Loading

0 comments on commit 8676326

Please sign in to comment.