Skip to content

Commit

Permalink
added rti legacy export interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Feb 26, 2024
1 parent 4ad283f commit 5229a0a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 77 deletions.
4 changes: 3 additions & 1 deletion relightlab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ set (RELIGHT_HEADERS
verifydialog.h
helpbutton.h
cropframe.h
rtiframe.h
../relight/imagecropper.h

)
Expand Down Expand Up @@ -101,7 +102,8 @@ set (RELIGHTLAB_SOURCES
verifyview.cpp
verifydialog.cpp
helpbutton.cpp
cropframe.cpp
cropframe.cpp
rtiframe.cpp
../relight/imagecropper.cpp
)

Expand Down
66 changes: 36 additions & 30 deletions relightlab/helpbutton.cpp
Original file line number Diff line number Diff line change
@@ -1,72 +1,60 @@
#include "helpbutton.h"

#include <QWidget>
#include <QAction>

#include <QDialogButtonBox>
#include <QIcon>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTextBrowser>
#include <QDialogButtonBox>
#include <QToolBar>
#include <QPushButton>
#include <QWidget>
#include <QAction>
#include <QToolButton>
#include <QRadioButton>
#include <QTextBrowser>
#include <QLabel>
#include <QSettings>
#include <QUrl>
#include <QFile>
#include <QToolBar>
#include <QToolButton>

#include <QDebug>
#include <QSettings>


HelpDialog* HelpDialog::m_instance = nullptr; // Initialize static instance to nullptr


HelpedButton::HelpedButton(QAction *action, QString url, QWidget *parent): QWidget(parent) {
init();
id = url;
setObjectName(id);
setToolTip("Help!");

init(url);
button->setText(action->text());
button->setIcon(action->icon());
connect(button, SIGNAL(clicked(bool)), action, SLOT(trigger()));
}

HelpedButton::HelpedButton(QString id, QIcon icon, QString text, QWidget *parent): QWidget(parent) {
init();
setObjectName(id);
init(id);
setToolTip(id);

button->setIcon(icon);
button->setText(text);
}

void HelpedButton::init() {
void HelpedButton::init(QString id) {
QHBoxLayout *layout = new QHBoxLayout(this);
button = new QPushButton;
button->setProperty("class", "large");

help = new HelpButton(id);

help = new QToolButton;
help->setIcon(QIcon::fromTheme("help-circle"));
help->setProperty("class", "large");
connect(help, SIGNAL(clicked()), this, SLOT(showHelp()));

setStyleSheet("QToolButton { border: none; outline: none; }");
layout->addWidget(button,1);
layout->addWidget(help);
layout->addStretch(1);
}


void HelpedButton::showHelp() {
QString id = objectName();
HelpDialog &dialog = HelpDialog::instance();
dialog.showPage(id);
//dialog.raise();
//dialog.exec();
}


HelpButton::HelpButton(QString id, QWidget *parent): QToolButton(parent) {
setCursor(Qt::PointingHandCursor);
setIcon(QIcon::fromTheme("help-circle"));
//setStyleSheet("QToolButton { color: #ff00ff; }");
setObjectName(id);
connect(this, SIGNAL(clicked()), this, SLOT(showHelp()));
setToolTip(id);
Expand All @@ -81,7 +69,25 @@ void HelpButton::showHelp() {
//dialog.exec();
}

HelpLabel::HelpLabel(QString txt, QString help_id, QWidget *parent): QWidget(parent) {
QHBoxLayout *layout = new QHBoxLayout(this);
QLabel *label = new QLabel(txt);
layout->addWidget(label);
layout->addStretch();
HelpButton *help = new HelpButton(help_id);
layout->addWidget(help);
}

HelpRadio::HelpRadio(QString txt, QString help_id, QWidget *parent): QWidget(parent) {
QHBoxLayout *layout = new QHBoxLayout(this);
radio = new QRadioButton(txt);
layout->addWidget(radio);
layout->addStretch();
HelpButton *help = new HelpButton(help_id);
layout->addWidget(help);
layout->setMargin(0);
}

HelpDialog::HelpDialog(QWidget *parent): QDialog(parent) {

QSettings settings;
Expand Down
21 changes: 16 additions & 5 deletions relightlab/helpbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
class QPushButton;
class QIcon;
class QAction;
class QRadioButton;

class HelpedButton: public QWidget {
Q_OBJECT
public:
HelpedButton(QAction *action, QString url, QWidget *parent = nullptr);
HelpedButton(QString id, QIcon icon, QString text, QWidget *parent = nullptr);
void setDefaultAction(QAction &a);
//void setDefaultAction(QAction &a);
signals:
void clicked();
public slots:
void showHelp();

private:
QPushButton *button = nullptr;
QToolButton *help = nullptr;
QString id;

void init();
void init(QString id);
};

class HelpButton: public QToolButton {
Expand All @@ -35,6 +34,18 @@ public slots:
void showHelp();
};

class HelpLabel: public QWidget {
public:
HelpLabel(QString txt, QString help_id, QWidget *parent = nullptr);
};

class HelpRadio: public QWidget {
public:
HelpRadio(QString txt, QString help_id, QWidget *parent = nullptr);
QRadioButton *radioButton() { return radio; }
private:
QRadioButton *radio = nullptr;
};

class QTextBrowser;

Expand Down
75 changes: 34 additions & 41 deletions relightlab/rtiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,67 @@
#include <QHBoxLayout>
#include <QGroupBox>
#include <QRadioButton>
#include <QPushButton>
#include <QLineEdit>
#include <QSpinBox>
#include <QLabel>

RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) {
QVBoxLayout *content = new QVBoxLayout(this);

QHBoxLayout *parameters = new QHBoxLayout;
QVBoxLayout *parameters = new QVBoxLayout;
content->addLayout(parameters);

QGroupBox *model = new QGroupBox("Model");
parameters->addWidget(model);
QGridLayout *model_layout = new QGridLayout(model);
QRadioButton *ptm = new QRadioButton("Polynomial Texture Maps (PTM)");
model_layout->addWidget(ptm, 0, 0);
model_layout->addWidget(new HelpButton("rti/ptm"), 0, 1);

QRadioButton *hsh = new QRadioButton("HemiSpherical Harmonics (HSH)");
model_layout->addWidget(hsh, 1, 0);
model_layout->addWidget(new HelpButton("rti/hsh"), 1, 1);

QRadioButton *rbf = new QRadioButton("Radial Basis Functions (RBF)");
model_layout->addWidget(rbf, 2, 0);
model_layout->addWidget(new HelpButton("rti/rbf"), 2, 1);

QRadioButton *bln = new QRadioButton("Bilinear sampling (BNL)");
model_layout->addWidget(bln, 3, 0);
model_layout->addWidget(new HelpButton("rti/bln"), 3, 1);

QRadioButton *neural = new QRadioButton("Neural networkr");
model_layout->addWidget(neural, 4, 0);
model_layout->addWidget(new HelpButton("rti/neural"), 4, 1);

QVBoxLayout *model_layout = new QVBoxLayout(model);
model_layout->addWidget(new HelpRadio("Polynomial Texture Maps (PTM)", "rti/ptm"));
model_layout->addWidget(new HelpRadio("HemiSpherical Harmonics (HSH)", "rti/hsh"));
model_layout->addWidget(new HelpRadio("Radial Basis Functions (RBF)", "rti/rbf"));
model_layout->addWidget(new HelpRadio("Bilinear sampling (BNL)", "rti/bln"));
model_layout->addWidget(new HelpRadio("Neural network", "rti/neural"));

QGroupBox *colorspace= new QGroupBox("Colorspace");
parameters->addWidget(colorspace);
QGridLayout *colorspace_layout = new QGridLayout(colorspace);
QRadioButton *rgb = new QRadioButton("RGB");
colorspace_layout->addWidget(rgb, 0, 0);
colorspace_layout->addWidget(new HelpButton("rti/rgb"), 0, 1);

QRadioButton *lrgb = new QRadioButton("LRGB");
colorspace_layout->addWidget(lrgb, 1, 0);
colorspace_layout->addWidget(new HelpButton("rti/lrgb"), 1, 1);

QRadioButton *mrgb = new QRadioButton("MRGB");
colorspace_layout->addWidget(mrgb, 2, 0);
colorspace_layout->addWidget(new HelpButton("rti/mrgb"), 2, 1);

QRadioButton *ycc = new QRadioButton("YCC");
colorspace_layout->addWidget(ycc, 3, 0);
colorspace_layout->addWidget(new HelpButton("rti/ycc"), 3, 1);

QVBoxLayout *colorspace_layout = new QVBoxLayout(colorspace);
colorspace_layout->addWidget(new HelpRadio("RGB", "rti/rgb"));
colorspace_layout->addWidget(new HelpRadio("LRGB", "rti/lrgb"));
colorspace_layout->addWidget(new HelpRadio("MRGB", "rti/mrgb"));
colorspace_layout->addWidget(new HelpRadio("YCC", "rti/ycc"));

QGroupBox *planes = new QGroupBox("Planes");
parameters->addWidget(planes);

QGridLayout *planes_layout = new QGridLayout(planes);
planes_layout->addWidget(new QLabel("Total number of planes:"), 0, 0);
planes_layout->addWidget(new HelpLabel("Total number of planes:", "rti/planes"), 0, 0);

QSpinBox *total_planes = new QSpinBox;
planes_layout->addWidget(total_planes, 0, 1);

planes_layout->addWidget(new QLabel("Number of luminance planes:"), 1, 0);
planes_layout->addWidget(new HelpLabel("Number of luminance planes:", "rti/luminance"), 1, 0);

QSpinBox *luminance_planes = new QSpinBox;
planes_layout->addWidget(luminance_planes, 1, 1);


QGroupBox *legacy = new QGroupBox("Export legacy RTI");
parameters->addWidget(legacy);

QGridLayout *legacy_layout = new QGridLayout(legacy);

legacy_layout->addWidget(new HelpRadio("Lossless (heavy!)", "rti/legacy"), 0, 0);

legacy_layout->addWidget(new HelpRadio("JPEG", "rti/legacy"), 1, 0);
legacy_layout->addWidget(new HelpLabel("Quality:", "rti/legacy"), 1, 1);
QSpinBox *quality = new QSpinBox;
legacy_layout->addWidget(quality, 1, 2);

legacy_layout->addWidget(new QLabel("Filename:"), 2, 0);
legacy_layout->addWidget(new QLineEdit(), 2, 1);
legacy_layout->addWidget(new QPushButton("..."), 2, 2);

legacy_layout->addWidget(new QPushButton("Export"), 3, 2);

content->addStretch();
}

Expand Down

0 comments on commit 5229a0a

Please sign in to comment.