From 4b7852d3ae8d50a32cd5ac48269035b0f8a454f8 Mon Sep 17 00:00:00 2001 From: ponchio Date: Mon, 1 Apr 2024 12:56:39 +0200 Subject: [PATCH] export dialogs --- relightlab/alignframe.cpp | 2 +- relightlab/alignrow.cpp | 2 +- relightlab/helpbutton.cpp | 2 +- relightlab/helpbutton.h | 2 + relightlab/relightlab.pro | 6 ++- relightlab/rticard.cpp | 79 +++++++++++++++++++++++++++------- relightlab/rticard.h | 5 +++ relightlab/rtiexportdialog.cpp | 73 +++++++++++++++++++++++++++++++ relightlab/rtiexportdialog.h | 20 +++++++++ relightlab/rtiframe.cpp | 22 +++------- 10 files changed, 176 insertions(+), 37 deletions(-) create mode 100644 relightlab/rtiexportdialog.cpp create mode 100644 relightlab/rtiexportdialog.h diff --git a/relightlab/alignframe.cpp b/relightlab/alignframe.cpp index 6f95e868..b0bb638a 100644 --- a/relightlab/alignframe.cpp +++ b/relightlab/alignframe.cpp @@ -83,7 +83,7 @@ void AlignFrame::removeAlign(AlignRow *row) { auto it = std::find(aligns.begin(), aligns.end(), align); - assert(it != aligns.end()); +// assert(it != aligns.end()); delete align; aligns.erase(it); diff --git a/relightlab/alignrow.cpp b/relightlab/alignrow.cpp index ce2da63b..d5367673 100644 --- a/relightlab/alignrow.cpp +++ b/relightlab/alignrow.cpp @@ -93,7 +93,7 @@ void AlignRow::edit() { void AlignRow::verify() { std::vector centers; std::vector thumbs; - assert(0); //todo needs to initialize those vaules and update align. +// assert(0); //todo needs to initialize those vaules and update align. VerifyDialog *verify_dialog = new VerifyDialog(thumbs, centers, this); verify_dialog->exec(); } diff --git a/relightlab/helpbutton.cpp b/relightlab/helpbutton.cpp index 23c161d9..06c995fb 100644 --- a/relightlab/helpbutton.cpp +++ b/relightlab/helpbutton.cpp @@ -71,7 +71,7 @@ void HelpButton::showHelp() { HelpLabel::HelpLabel(QString txt, QString help_id, QWidget *parent): QWidget(parent) { QHBoxLayout *layout = new QHBoxLayout(this); - QLabel *label = new QLabel(txt); + label = new QLabel(txt); layout->addWidget(label); layout->addStretch(); HelpButton *help = new HelpButton(help_id); diff --git a/relightlab/helpbutton.h b/relightlab/helpbutton.h index ff6e675a..f1aa213f 100644 --- a/relightlab/helpbutton.h +++ b/relightlab/helpbutton.h @@ -34,9 +34,11 @@ public slots: void showHelp(); }; +class QLabel; class HelpLabel: public QWidget { public: HelpLabel(QString txt, QString help_id, QWidget *parent = nullptr); + QLabel *label = nullptr; }; class HelpRadio: public QWidget { diff --git a/relightlab/relightlab.pro b/relightlab/relightlab.pro index ed6cffa6..5dd1174d 100644 --- a/relightlab/relightlab.pro +++ b/relightlab/relightlab.pro @@ -82,7 +82,8 @@ SOURCES += main.cpp \ helpbutton.cpp \ cropframe.cpp \ ../relight/imagecropper.cpp \ - creatertidialog.cpp + creatertidialog.cpp \ + rtiexportdialog.cpp RESOURCES += \ res.qrc @@ -136,7 +137,8 @@ HEADERS += \ helpbutton.h \ cropframe.h \ ../relight/imagecropper.h \ - creatertidialog.h + creatertidialog.h \ + rtiexportdialog.h FORMS += \ form.ui diff --git a/relightlab/rticard.cpp b/relightlab/rticard.cpp index 5d53111c..79d10d90 100644 --- a/relightlab/rticard.cpp +++ b/relightlab/rticard.cpp @@ -1,5 +1,6 @@ #include "rticard.h" #include "helpbutton.h" +#include "rtiexportdialog.h" #include #include @@ -29,18 +30,9 @@ RtiCard::RtiCard(Rti::Type _type, Rti::ColorSpace _colorspace, int _nplanes, int "Bilinear sampling" << "Convolutional neural network"; - QString title = titles[(int)type]; - if(colorspace == Rti::LRGB) { - title = "L" + title; - } - - title += QString(" %1").arg(nplanes); - if(nchroma > 0) { - title += QString(".%1").arg(nchroma); - } - QVBoxLayout *layout = new QVBoxLayout(this); - layout->addWidget(new HelpLabel(title, "rti/" + titles[(int)type].toLower())); + layout->addWidget(title_label = new HelpLabel("", "rti/" + titles[(int)type].toLower())); + updateTitle(); //QImage thumb = qRelightApp->thumbnails()[0]; QLabel *img = new QLabel(); @@ -48,20 +40,77 @@ RtiCard::RtiCard(Rti::Type _type, Rti::ColorSpace _colorspace, int _nplanes, int img->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); layout->addWidget(img); + if(type == Rti::HSH) { + QComboBox *combo = new QComboBox; + combo->addItems(QStringList() << "4 harmonics" << "9 harmonics"); + connect(combo, QOverload::of(&QComboBox::currentIndexChanged), [&] (int h) { + nplanes = h == 0? 12 : 27; + updateTitle(); + }); + layout->addWidget(combo); + } + if(type == Rti::RBF || type == Rti::BILINEAR) { + QComboBox *combo = new QComboBox; + combo->addItems(QStringList() << "12 coefficients" << "15 coefficients" << "18 coefficients" << "21 coefficients" << "24 coefficients" << "27 coefficients"); + combo->setCurrentIndex(nplanes/3 - 4); + + layout->addWidget(combo); + + QComboBox *chroma = new QComboBox; + chroma->addItems(QStringList() << "0 chroma dedicated" << "1 chroma dedicated" << "2 chroma dedicated"); + chroma->setCurrentIndex(nchroma); + layout->addWidget(chroma); + } + QHBoxLayout *hbox = new QHBoxLayout; layout->addLayout(hbox); - hbox->addWidget(new QPushButton("Preview"), 1); - hbox->addWidget(new QPushButton("Create..."), 1); + //hbox->addWidget(new QPushButton("Preview"), 1); + QPushButton *create = new QPushButton("Create"); + hbox->addWidget(create, 1); + + if(type == Rti::PTM) { + QPushButton *legacy = new QPushButton("Export .ptm for RtiViewer"); + hbox->addWidget(legacy, 1); + } + if(type == Rti::HSH) { + QPushButton *legacy = new QPushButton("Export .rti for RtiViewer"); + hbox->addWidget(legacy, 1); + } + + + - hbox->addWidget(new QPushButton(QIcon::fromTheme("trash-2"), "")); - //img->setPixmap(QPixmap::fromImage(thumb.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation))); + connect(create, &QPushButton::clicked, [&]() { + RtiExportDialog + }) setFrameStyle(QFrame::StyledPanel); setAutoFillBackground(true); setBackgroundRole(QPalette::AlternateBase); } +void RtiCard::updateTitle() { + QStringList titles; + titles << + "PTM" << + "HSH" << + "RBF" << + "BNL" << + "Neural"; + + QString title = titles[(int)type]; + if(colorspace == Rti::LRGB) { + title = "L" + title; + } + + title += QString(" %1").arg(nplanes); + if(nchroma > 0) { + title += QString(".%1").arg(nchroma); + } + title_label->label->setText(title); +} + void RtiCard::mousePressEvent(QMouseEvent *event) { if(checkable) { setChecked(!checked); diff --git a/relightlab/rticard.h b/relightlab/rticard.h index 4f3bfd47..c918d837 100644 --- a/relightlab/rticard.h +++ b/relightlab/rticard.h @@ -5,6 +5,8 @@ #include "../src/rti.h" +class HelpLabel; + class RtiCard: public QFrame { Q_OBJECT public: @@ -15,8 +17,10 @@ class RtiCard: public QFrame { RtiCard(Rti::Type type, Rti::ColorSpace colorspace, int nplanes, int nchroma, QWidget *parent = nullptr); void setCheckable(bool); + public slots: void setChecked(bool); + void updateTitle(); signals: void toggled(bool checked); @@ -26,6 +30,7 @@ public slots: void mousePressEvent(QMouseEvent *event) override; private: + HelpLabel *title_label = nullptr; bool checkable = false; bool checked = false; diff --git a/relightlab/rtiexportdialog.cpp b/relightlab/rtiexportdialog.cpp new file mode 100644 index 00000000..12004072 --- /dev/null +++ b/relightlab/rtiexportdialog.cpp @@ -0,0 +1,73 @@ +#include "rtiexportdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +RtiExportDialog::RtiExportDialog(QWidget *parent): QDialog(parent) { + setWindowTitle("Export RTI"); + setMinimumWidth(400); + + QVBoxLayout *content = new QVBoxLayout(this); + + QGroupBox *format = new QGroupBox("Format"); + content->addWidget(format); + QVBoxLayout *format_layout = new QVBoxLayout(format); + format_layout->addWidget(new QRadioButton("Plain images")); + format_layout->addWidget(new QRadioButton("Deepzoom")); + format_layout->addWidget(new QRadioButton("Tarzoom")); + format_layout->addWidget(new QRadioButton("Interleaved Tarzoom")); + + QHBoxLayout *quality_box = new QHBoxLayout; + content->addLayout(quality_box); + quality_box->addWidget(new QLabel("Jpeg quality")); + quality_box->addWidget(quality = new QSpinBox); + quality->setRange(75, 100); + + + content->addSpacing(20); + content->addWidget(new QLabel("Directory:")); + + QHBoxLayout *dir = new QHBoxLayout; + content->addLayout(dir); + dir->addWidget(new QLineEdit()); + dir->addWidget(new QPushButton("...")); + + QHBoxLayout *buttons = new QHBoxLayout; + content->addLayout(buttons); + buttons->addStretch(); + buttons->addWidget(new QPushButton("Create")); + buttons->addWidget(new QPushButton("Cancel")); +} + +LegacyExportDialog::LegacyExportDialog(QWidget *parent): QDialog(parent) { + setWindowTitle("Export legacy RTI"); + setMinimumWidth(400); + + QVBoxLayout *content = new QVBoxLayout(this); + + content->addWidget(new QRadioButton("Uncompressed")); + content->addWidget(new QRadioButton("JPEG")); + + QHBoxLayout *quality_box = new QHBoxLayout; + content->addLayout(quality_box); + quality_box->addWidget(new QLabel("Jpeg quality")); + quality_box->addWidget(quality = new QSpinBox); + quality->setRange(75, 100); + + QHBoxLayout *filename = new QHBoxLayout; + content->addLayout(filename); + filename->addWidget(new QLineEdit()); + filename->addWidget(new QPushButton("...")); + + QHBoxLayout *buttons = new QHBoxLayout; + content->addLayout(buttons); + buttons->addStretch(); + buttons->addWidget(new QPushButton("Create")); + buttons->addWidget(new QPushButton("Cancel")); +} diff --git a/relightlab/rtiexportdialog.h b/relightlab/rtiexportdialog.h new file mode 100644 index 00000000..502c7fac --- /dev/null +++ b/relightlab/rtiexportdialog.h @@ -0,0 +1,20 @@ +#ifndef RTIEXPORTDIALOG_H +#define RTIEXPORTDIALOG_H + +#include + +class QSpinBox; + +class RtiExportDialog: public QDialog { +public: + RtiExportDialog(QWidget *parent = nullptr); + QSpinBox *quality = nullptr; +}; + +class LegacyExportDialog: public QDialog { +public: + LegacyExportDialog(QWidget *parent = nullptr); + QSpinBox *quality = nullptr; +}; + +#endif // RTIEXPORTDIALOG_H diff --git a/relightlab/rtiframe.cpp b/relightlab/rtiframe.cpp index 4445d68d..0b9e68a7 100644 --- a/relightlab/rtiframe.cpp +++ b/relightlab/rtiframe.cpp @@ -22,11 +22,11 @@ RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) { content->addWidget(new QLabel("

Relightable images

")); content->addSpacing(20); - content->addWidget(new PtmRow()); - content->addWidget(new HshRow()); - content->addWidget(new RbfRow()); +/* content->addWidget(new PtmRow()); + content->addWidget(new HshRow()); + content->addWidget(new RbfRow()); */ + -/* QScrollArea *area = new QScrollArea; area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); area->setWidgetResizable(true); @@ -40,25 +40,13 @@ RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) { sample_layout->addWidget(new RtiCard(Rti::PTM, Rti::LRGB, 9, 0)); sample_layout->addWidget(new RtiCard(Rti::PTM, Rti::RGB, 18, 0)); - sample_layout->addWidget(new RtiCard(Rti::HSH, Rti::RGB, 12, 0)); - sample_layout->addWidget(new RtiCard(Rti::HSH, Rti::LRGB, 12, 0)); sample_layout->addWidget(new RtiCard(Rti::HSH, Rti::RGB, 27, 0)); - sample_layout->addWidget(new RtiCard(Rti::RBF, Rti::MRGB, 12, 0)); + sample_layout->addWidget(new RtiCard(Rti::RBF, Rti::MRGB, 18, 0)); - sample_layout->addWidget(new RtiCard(Rti::RBF, Rti::MRGB, 24, 0)); - sample_layout->addWidget(new RtiCard(Rti::BILINEAR, Rti::MRGB, 12, 0)); sample_layout->addWidget(new RtiCard(Rti::BILINEAR, Rti::MRGB, 18, 0)); - sample_layout->addWidget(new RtiCard(Rti::BILINEAR, Rti::MRGB, 24, 0)); - sample_layout->addWidget(new RtiCard(Rti::RBF, Rti::YCC, 12, 1)); - sample_layout->addWidget(new RtiCard(Rti::RBF, Rti::YCC, 18, 2)); - sample_layout->addWidget(new RtiCard(Rti::RBF, Rti::YCC, 24, 3)); - sample_layout->addWidget(new RtiCard(Rti::BILINEAR, Rti::YCC, 12, 1)); - sample_layout->addWidget(new RtiCard(Rti::BILINEAR, Rti::YCC, 18, 2)); - sample_layout->addWidget(new RtiCard(Rti::BILINEAR, Rti::YCC, 24, 3)); -*/ /* QGroupBox *model = new QGroupBox("Model");