Skip to content

Commit a1c0401

Browse files
committed
fixed RtiFrame export, some bugfix.
1 parent 62bb8d6 commit a1c0401

7 files changed

+66
-8
lines changed

relightlab/mainwindow.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void MainWindow::init() {
124124
scale_frame->init();
125125
lights_frame->init();
126126
crop_frame->init();
127+
rti_frame->init();
127128
}
128129

129130

relightlab/relightapp.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void RelightApp::setProject(const Project &_project) {
153153
mainwindow->init();
154154
mainwindow->setTabIndex(1);
155155
qRelightApp->setLastProjectDir(m_project.dir.path());
156+
qRelightApp->clearLastOutputDir();
156157
}
157158

158159
void RelightApp::newProject() {

relightlab/relightapp.h

+14-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ public slots:
9494
void setLastProjectDir(QString dir) {
9595
QSettings().setValue("LastProjectDir", dir);
9696
}
97+
QString lastOutputDir() {
98+
if(!last_output_dir.isEmpty())
99+
return last_output_dir;
100+
QDir out = m_project.dir;
101+
out.cdUp();
102+
return out.absolutePath();
103+
}
104+
void setLastOutputDir(QString out) {
105+
last_output_dir = out;
106+
}
107+
void clearLastOutputDir() {
108+
last_output_dir = QString();
109+
}
97110
bool needsSavingProceed();
98111

99112
QStringList domes();
@@ -102,10 +115,9 @@ public slots:
102115
void loadThumbnails();
103116

104117
private:
105-
106-
107118
//keep memory of current project filename for quick saving.
108119
QString project_filename;
120+
QString last_output_dir;
109121
QPalette dark_palette;
110122
ThumbailLoader *loader = nullptr;
111123
};

relightlab/rtiframe.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ RtiFrame::RtiFrame(QWidget *parent): QFrame(parent) {
9898
}
9999

100100
void RtiFrame::init() {
101-
101+
//fill in last RTI used or a common one.
102+
export_row->suggestPath();
102103
}
103104

104105
void RtiFrame::exportRti() {
@@ -110,9 +111,13 @@ void RtiFrame::exportRti() {
110111
return;
111112
}
112113

113-
114+
if(parameters.path.isEmpty()) {
115+
QMessageBox::warning(this, "Destination path is missing.", "Fill in the output folder or the filename for the RTI.");
116+
return;
117+
}
114118
RtiTask *rti_task = new RtiTask(qRelightApp->project());
115119
rti_task->parameters = parameters;
120+
rti_task->output = parameters.path;
116121

117122
ProcessQueue &queue = ProcessQueue::instance();
118123
queue.addTask(rti_task);

relightlab/rtiplan.cpp

+34-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <QComboBox>
1414
#include <QLineEdit>
1515
#include <QFileDialog>
16+
#include <QMessageBox>
1617

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

323324
path_edit = new QLineEdit;
325+
connect(path_edit, &QLineEdit::editingFinished,this, &RtiExportRow::verifyPath);
324326
buttons->addWidget(path_edit);
325327
QPushButton *path_button = new QPushButton("...");
326328
buttons->addWidget(path_button);
329+
connect(path_button, &QPushButton::clicked, this, &RtiExportRow::selectOutput);
327330
}
328331

329332
void RtiExportRow::setPath(QString path, bool emitting) {
330333
path_edit->setText(path);
334+
parameters.path = path;
335+
}
336+
337+
void RtiExportRow::verifyPath() {
338+
parameters.path = QString();
339+
QString path = path_edit->text();
340+
QDir path_dir(path);
341+
path_dir.cdUp();
342+
if(!path_dir.exists()) {
343+
QMessageBox::warning(this, "Invalid output path", "The specified path is not valid");
344+
return;
345+
}
346+
QString extension;
347+
if(parameters.format == RtiParameters::RTI) {
348+
extension = parameters.basis == Rti::HSH ? ".rti" : ".ptm";
349+
} else if(parameters.format == RtiParameters::IIP) {
350+
extension = ".tif";
351+
}
352+
if(!path.endsWith(extension)) {
353+
path += extension;
354+
path_edit->setText(path);
355+
}
356+
parameters.path = path;
331357
}
332358

333359
void RtiExportRow::selectOutput() {
334360
//get folder if not legacy.
361+
QString output_parent = qRelightApp->lastOutputDir();
362+
335363
QString output;
336364
if(parameters.format == RtiParameters::RTI) {
337365
QString extension;
@@ -344,17 +372,20 @@ void RtiExportRow::selectOutput() {
344372
extension = ".ptm";
345373
label = "PTM file (*.ptm)";
346374
}
347-
output = QFileDialog::getSaveFileName(this, "Select a file name", QString(), label);
375+
output = QFileDialog::getSaveFileName(this, "Select a file name", output_parent, label);
348376
if(output.isNull()) return;
349377

350378
if(!output.endsWith(extension))
351379
output += extension;
352380

353381
} else {
354-
output = QFileDialog::getSaveFileName(this, "Select an output folder", QString());
382+
output = QFileDialog::getSaveFileName(this, "Select an output folder", output_parent);
355383
if(output.isNull()) return;
356384
}
357-
parameters.path = output;
385+
QDir output_parent_dir(output);
386+
output_parent_dir.cdUp();
387+
qRelightApp->setLastOutputDir(output_parent_dir.absolutePath());
388+
setPath(output);
358389
}
359390

360391
void RtiExportRow::suggestPath() {

relightlab/rtiplan.h

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class RtiExportRow: public RtiPlanRow {
117117
void setPath(QString path, bool emitting = false);
118118
public slots:
119119
void selectOutput();
120+
void verifyPath();
120121
void suggestPath();
121122

122123
private:

relightlab/rtitask.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,17 @@ void RtiTask::run() {
4646
builder->yccplanes[1] = builder->yccplanes[2] = (builder->nplanes - builder->yccplanes[0])/2;
4747
builder->nplanes = builder->yccplanes[0] + 2*builder->yccplanes[1];
4848
}
49+
50+
//legacy format uses the same scale and bias for each component (RBG)
51+
if(parameters.format == RtiParameters::RTI)
52+
builder->commonMinMax = true;
53+
4954
ImageSet &imageset = builder->imageset;
5055
imageset.images = project.getImages();
51-
imageset.initFromDome(project.dome);
56+
imageset.pixel_size = project.pixelSize;
5257
imageset.initImages(input_folder.toStdString().c_str());
58+
imageset.initFromDome(project.dome); //lights after images
59+
5360

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

0 commit comments

Comments
 (0)