Skip to content

Commit

Permalink
fixed RtiFrame export, some bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ponchio committed Nov 29, 2024
1 parent 62bb8d6 commit a1c0401
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 8 deletions.
1 change: 1 addition & 0 deletions relightlab/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ void MainWindow::init() {
scale_frame->init();
lights_frame->init();
crop_frame->init();
rti_frame->init();
}


1 change: 1 addition & 0 deletions relightlab/relightapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void RelightApp::setProject(const Project &_project) {
mainwindow->init();
mainwindow->setTabIndex(1);
qRelightApp->setLastProjectDir(m_project.dir.path());
qRelightApp->clearLastOutputDir();
}

void RelightApp::newProject() {
Expand Down
16 changes: 14 additions & 2 deletions relightlab/relightapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ public slots:
void setLastProjectDir(QString dir) {
QSettings().setValue("LastProjectDir", dir);
}
QString lastOutputDir() {
if(!last_output_dir.isEmpty())
return last_output_dir;
QDir out = m_project.dir;
out.cdUp();
return out.absolutePath();
}
void setLastOutputDir(QString out) {
last_output_dir = out;
}
void clearLastOutputDir() {
last_output_dir = QString();
}
bool needsSavingProceed();

QStringList domes();
Expand All @@ -102,10 +115,9 @@ public slots:
void loadThumbnails();

private:


//keep memory of current project filename for quick saving.
QString project_filename;
QString last_output_dir;
QPalette dark_palette;
ThumbailLoader *loader = nullptr;
};
Expand Down
9 changes: 7 additions & 2 deletions relightlab/rtiframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) {
}

void RtiFrame::init() {

//fill in last RTI used or a common one.
export_row->suggestPath();
}

void RtiFrame::exportRti() {
Expand All @@ -110,9 +111,13 @@ void RtiFrame::exportRti() {
return;
}


if(parameters.path.isEmpty()) {
QMessageBox::warning(this, "Destination path is missing.", "Fill in the output folder or the filename for the RTI.");
return;
}
RtiTask *rti_task = new RtiTask(qRelightApp->project());
rti_task->parameters = parameters;
rti_task->output = parameters.path;

ProcessQueue &queue = ProcessQueue::instance();
queue.addTask(rti_task);
Expand Down
37 changes: 34 additions & 3 deletions relightlab/rtiplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QComboBox>
#include <QLineEdit>
#include <QFileDialog>
#include <QMessageBox>

RtiPlanRow::RtiPlanRow(RtiParameters &param, QFrame *parent): QFrame(parent), parameters(param) {
QHBoxLayout *layout = new QHBoxLayout(this);
Expand Down Expand Up @@ -321,17 +322,44 @@ RtiExportRow::RtiExportRow(RtiParameters &parameters, QFrame *parent): RtiPlanRo
label->help->setId("rti/export");

path_edit = new QLineEdit;
connect(path_edit, &QLineEdit::editingFinished,this, &RtiExportRow::verifyPath);
buttons->addWidget(path_edit);
QPushButton *path_button = new QPushButton("...");
buttons->addWidget(path_button);
connect(path_button, &QPushButton::clicked, this, &RtiExportRow::selectOutput);
}

void RtiExportRow::setPath(QString path, bool emitting) {
path_edit->setText(path);
parameters.path = path;
}

void RtiExportRow::verifyPath() {
parameters.path = QString();
QString path = path_edit->text();
QDir path_dir(path);
path_dir.cdUp();
if(!path_dir.exists()) {
QMessageBox::warning(this, "Invalid output path", "The specified path is not valid");
return;
}
QString extension;
if(parameters.format == RtiParameters::RTI) {
extension = parameters.basis == Rti::HSH ? ".rti" : ".ptm";
} else if(parameters.format == RtiParameters::IIP) {
extension = ".tif";
}
if(!path.endsWith(extension)) {
path += extension;
path_edit->setText(path);
}
parameters.path = path;
}

void RtiExportRow::selectOutput() {
//get folder if not legacy.
QString output_parent = qRelightApp->lastOutputDir();

QString output;
if(parameters.format == RtiParameters::RTI) {
QString extension;
Expand All @@ -344,17 +372,20 @@ void RtiExportRow::selectOutput() {
extension = ".ptm";
label = "PTM file (*.ptm)";
}
output = QFileDialog::getSaveFileName(this, "Select a file name", QString(), label);
output = QFileDialog::getSaveFileName(this, "Select a file name", output_parent, label);
if(output.isNull()) return;

if(!output.endsWith(extension))
output += extension;

} else {
output = QFileDialog::getSaveFileName(this, "Select an output folder", QString());
output = QFileDialog::getSaveFileName(this, "Select an output folder", output_parent);
if(output.isNull()) return;
}
parameters.path = output;
QDir output_parent_dir(output);
output_parent_dir.cdUp();
qRelightApp->setLastOutputDir(output_parent_dir.absolutePath());
setPath(output);
}

void RtiExportRow::suggestPath() {
Expand Down
1 change: 1 addition & 0 deletions relightlab/rtiplan.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class RtiExportRow: public RtiPlanRow {
void setPath(QString path, bool emitting = false);
public slots:
void selectOutput();
void verifyPath();
void suggestPath();

private:
Expand Down
9 changes: 8 additions & 1 deletion relightlab/rtitask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ void RtiTask::run() {
builder->yccplanes[1] = builder->yccplanes[2] = (builder->nplanes - builder->yccplanes[0])/2;
builder->nplanes = builder->yccplanes[0] + 2*builder->yccplanes[1];
}

//legacy format uses the same scale and bias for each component (RBG)
if(parameters.format == RtiParameters::RTI)
builder->commonMinMax = true;

ImageSet &imageset = builder->imageset;
imageset.images = project.getImages();
imageset.initFromDome(project.dome);
imageset.pixel_size = project.pixelSize;
imageset.initImages(input_folder.toStdString().c_str());
imageset.initFromDome(project.dome); //lights after images


if(!crop.isNull()) {
builder->crop[0] = crop.left();
Expand Down

0 comments on commit a1c0401

Please sign in to comment.