Skip to content

Commit

Permalink
export dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Apr 1, 2024
1 parent b2cfd14 commit 4b7852d
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 37 deletions.
2 changes: 1 addition & 1 deletion relightlab/alignframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion relightlab/alignrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void AlignRow::edit() {
void AlignRow::verify() {
std::vector<QPointF> centers;
std::vector<QImage> 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();
}
Expand Down
2 changes: 1 addition & 1 deletion relightlab/helpbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions relightlab/helpbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions relightlab/relightlab.pro
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ SOURCES += main.cpp \
helpbutton.cpp \
cropframe.cpp \
../relight/imagecropper.cpp \
creatertidialog.cpp
creatertidialog.cpp \
rtiexportdialog.cpp

RESOURCES += \
res.qrc
Expand Down Expand Up @@ -136,7 +137,8 @@ HEADERS += \
helpbutton.h \
cropframe.h \
../relight/imagecropper.h \
creatertidialog.h
creatertidialog.h \
rtiexportdialog.h

FORMS += \
form.ui
Expand Down
79 changes: 64 additions & 15 deletions relightlab/rticard.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "rticard.h"
#include "helpbutton.h"
#include "rtiexportdialog.h"

#include <QPushButton>
#include <QVBoxLayout>
Expand Down Expand Up @@ -29,39 +30,87 @@ 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();
img->setMinimumSize(300, 300);
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<int>::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);
Expand Down
5 changes: 5 additions & 0 deletions relightlab/rticard.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "../src/rti.h"


class HelpLabel;

class RtiCard: public QFrame {
Q_OBJECT
public:
Expand All @@ -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);
Expand All @@ -26,6 +30,7 @@ public slots:
void mousePressEvent(QMouseEvent *event) override;

private:
HelpLabel *title_label = nullptr;
bool checkable = false;
bool checked = false;

Expand Down
73 changes: 73 additions & 0 deletions relightlab/rtiexportdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "rtiexportdialog.h"

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QRadioButton>
#include <QSpinBox>
#include <QLineEdit>
#include <QPushButton>

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"));
}
20 changes: 20 additions & 0 deletions relightlab/rtiexportdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef RTIEXPORTDIALOG_H
#define RTIEXPORTDIALOG_H

#include <QDialog>

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
22 changes: 5 additions & 17 deletions relightlab/rtiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) {
content->addWidget(new QLabel("<h2>Relightable images</h2>"));
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);
Expand All @@ -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");
Expand Down

0 comments on commit 4b7852d

Please sign in to comment.