From 867632695ba9da246d5ed6dff16a018aa798161a Mon Sep 17 00:00:00 2001 From: ponchio Date: Tue, 2 Jul 2024 19:52:05 +0200 Subject: [PATCH] rti plan update --- relight/rtitask.h | 4 +- relightlab/rtiplan.cpp | 197 +++++++++++++++++++++++++++++------------ relightlab/rtiplan.h | 57 +++++++----- 3 files changed, 179 insertions(+), 79 deletions(-) diff --git a/relight/rtitask.h b/relight/rtitask.h index ccab92fc..5ab9dfc1 100644 --- a/relight/rtitask.h +++ b/relight/rtitask.h @@ -22,7 +22,7 @@ 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; @@ -30,7 +30,7 @@ class RtiParameters { int nchroma; Format format; - WebFormat webFormat; + WebLayout webFormat; bool lossless = false; //used only for RTI format; diff --git a/relightlab/rtiplan.cpp b/relightlab/rtiplan.cpp index e59091e7..8ef0e852 100644 --- a/relightlab/rtiplan.cpp +++ b/relightlab/rtiplan.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -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) { @@ -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; } @@ -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; } @@ -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; @@ -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); + } @@ -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) { + +} + diff --git a/relightlab/rtiplan.h b/relightlab/rtiplan.h index a85bfd07..5d6074a4 100644 --- a/relightlab/rtiplan.h +++ b/relightlab/rtiplan.h @@ -15,8 +15,6 @@ class RtiPlanRow: public QFrame { Q_OBJECT public: RtiPlanRow(QFrame *parent = nullptr); - -protected: HelpLabel *label = nullptr; QHBoxLayout *buttons = nullptr; }; @@ -26,36 +24,36 @@ class RtiBasisRow: public RtiPlanRow { public: RtiBasisRow(QFrame *parent = nullptr); void init(Rti::Type basis); -signals: - void basisChanged(Rti::Type basis); -private: Rti::Type basis; QLabelButton *ptm, *hsh, *rbf, *bln; +signals: + void basisChanged(Rti::Type basis); + }; class RtiColorSpaceRow: public RtiPlanRow { Q_OBJECT public: RtiColorSpaceRow(QFrame *parent = nullptr); - void init(Rti::ColorSpace colorspace); -signals: - void colorspaceChanged(Rti::ColorSpace colorspace); -private: + void init(Rti::Type basis, Rti::ColorSpace colorspace); Rti::ColorSpace colorspace; QLabelButton *rgb, *lrgb, *mrgb, *ycc; + +signals: + void colorspaceChanged(Rti::ColorSpace colorspace); }; class RtiPlanesRow: public RtiPlanRow { Q_OBJECT public: RtiPlanesRow(QFrame *parent = nullptr); - void init(int nplanes, int nchroma); -signals: - void nplanesChanged(int nplanes, int nchroma); -private: + void init(Rti::ColorSpace colorspace, int nplanes, int nchroma); int nplanes; int nchroma; QComboBox *nplanesbox, *nchromabox; + +signals: + void nplanesChanged(int nplanes, int nchroma); }; class RtiFormatRow: public RtiPlanRow { @@ -63,11 +61,11 @@ class RtiFormatRow: public RtiPlanRow { public: RtiFormatRow(QFrame *parent = nullptr); void init(RtiParameters::Format format); -signals: - void formatChanged(RtiParameters::Format format); -private: RtiParameters::Format format; QLabelButton *rti, *web, *iip; + +signals: + void formatChanged(RtiParameters::Format format); }; class RtiQualityRow: public RtiPlanRow { @@ -75,12 +73,22 @@ class RtiQualityRow: public RtiPlanRow { public: RtiQualityRow(QFrame *parent = nullptr); void init(int quality); //0 stands for lossless. -signals: - void formatChanged(RtiParameters::Format format); -private: int quality = 95; QSpinBox *qualitybox; - QLabelButton *rti, *img, *deepzoom; + +signals: + void qualityChanged(int quality); +}; + +class RtiWebLayoutRow: public RtiPlanRow { + Q_OBJECT +public: + RtiWebLayoutRow(QFrame *parent = nullptr); + void init(RtiParameters::WebLayout layout); //0 stands for lossless. + RtiParameters::WebLayout layout; +signals: + void layoutChanged(RtiParameters::WebLayout layout); + }; @@ -88,16 +96,25 @@ class RtiPlan: public QFrame { Q_OBJECT public: RtiPlan(QWidget *parent = nullptr); + void setParameters(RtiParameters parameters); + + RtiParameters parameters; + public slots: void basisChanged(Rti::Type basis); void colorspaceChanged(Rti::ColorSpace colorspace); void nplanesChanged(int nplanes, int nchroma); void formatChanged(RtiParameters::Format format); + void qualityChanged(int quality); + void layoutChanged(RtiParameters::WebLayout layout); + private: RtiBasisRow *basis_row = nullptr; RtiColorSpaceRow *colorspace_row = nullptr; RtiPlanesRow *planes_row = nullptr; RtiFormatRow *format_row = nullptr; + RtiQualityRow *quality_row = nullptr; + RtiWebLayoutRow *layout_row = nullptr; }; #endif // RTIPLAN_H