Use the static functions on 'Save scene as'.
parent
1cf94e546a
commit
f078daa1be
|
@ -223,7 +223,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
move(windowPos);
|
||||
#endif
|
||||
show();
|
||||
/* Move again just to be sure.. */
|
||||
/* Move again just to be sure ... */
|
||||
move(windowPos);
|
||||
|
||||
updateUI();
|
||||
|
@ -274,7 +274,7 @@ void MainWindow::initWorkers() {
|
|||
QDialog *dialog = new NonClosableDialog(this);
|
||||
dialog->setWindowModality(Qt::WindowModal);
|
||||
QVBoxLayout *layout = new QVBoxLayout(dialog);
|
||||
QLabel *label = new QLabel(tr("Establishing network connections .."), dialog);
|
||||
QLabel *label = new QLabel(tr("Establishing network connections ..."), dialog);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(label);
|
||||
QProgressBar *progressBar = new QProgressBar(dialog);
|
||||
|
@ -624,7 +624,7 @@ SceneContext *MainWindow::loadScene(const QString &qFileName) {
|
|||
ref<SceneLoader> loadingThread;
|
||||
loaddlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
loaddlg->setWindowModality(Qt::ApplicationModal);
|
||||
loaddlg->setWindowTitle("Loading ..");
|
||||
loaddlg->setWindowTitle("Loading ...");
|
||||
loaddlg->show();
|
||||
|
||||
retry:
|
||||
|
@ -1434,7 +1434,7 @@ inline float toSRGB(float value) {
|
|||
void MainWindow::on_actionExportImage_triggered() {
|
||||
QSettings settings;
|
||||
const QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Export image..."), settings.value("exportFileDir").toString(),
|
||||
tr("Export image ..."), settings.value("exportFileDir").toString(),
|
||||
tr("All supported formats (*.exr *.hdr *.rgbe *.pfm *.png *.jpg *.jpeg);;"
|
||||
"High dynamic range OpenEXR image (*.exr);;"
|
||||
"High dynamic range Radiance RGBE image (*.rgbe *.hdr);;"
|
||||
|
@ -1450,7 +1450,7 @@ void MainWindow::on_actionExportImage_triggered() {
|
|||
#else // MTSGUI_STATIC_QFILEDIALOG
|
||||
|
||||
void MainWindow::on_actionExportImage_triggered() {
|
||||
QFileDialog *dialog = new QFileDialog(this, tr("Export image .."),
|
||||
QFileDialog *dialog = new QFileDialog(this, tr("Export image ..."),
|
||||
"", tr("All supported formats (*.exr *.hdr *.rgbe *.pfm *.png *.jpg *.jpeg);;"
|
||||
"High dynamic range OpenEXR image (*.exr);;"
|
||||
"High dynamic range Radiance RGBE image (*.rgbe *.hdr);;"
|
||||
|
@ -1497,14 +1497,17 @@ void MainWindow::onExportDialogClose(int reason) {
|
|||
void MainWindow::exportImage(const QString &fileName) {
|
||||
if (!fileName.isEmpty()) {
|
||||
Bitmap::EFileFormat format;
|
||||
bool isHDR = true;
|
||||
if (fileName.endsWith(".exr")) {
|
||||
format = Bitmap::EOpenEXR;
|
||||
} else if (fileName.endsWith(".png")) {
|
||||
format = Bitmap::EPNG;
|
||||
isHDR = false;
|
||||
} else if (fileName.endsWith(".hdr") || fileName.endsWith(".rgbe")) {
|
||||
format = Bitmap::ERGBE;
|
||||
} else if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
|
||||
format = Bitmap::EJPEG;
|
||||
isHDR = false;
|
||||
} else if (fileName.endsWith(".pfm")) {
|
||||
format = Bitmap::EPFM;
|
||||
} else {
|
||||
|
@ -1523,7 +1526,7 @@ void MainWindow::exportImage(const QString &fileName) {
|
|||
ui->glView->downloadFramebuffer();
|
||||
|
||||
ref<Bitmap> bitmap = ctx->framebuffer;
|
||||
if (format != Bitmap::EOpenEXR && format != Bitmap::ERGBE && format != Bitmap::EPFM) {
|
||||
if (!isHDR) {
|
||||
/* Tonemap the image */
|
||||
if (ctx->toneMappingMethod == EReinhard) {
|
||||
Float logAvgLuminance = 0, maxLuminance = 0; /* Unused */
|
||||
|
@ -1537,7 +1540,7 @@ void MainWindow::exportImage(const QString &fileName) {
|
|||
bitmap = bitmap->convert(Bitmap::ERGB, Bitmap::EUInt8,
|
||||
ctx->srgb ? (Float) -1 : ctx->gamma,
|
||||
ctx->toneMappingMethod == EReinhard
|
||||
? (Float) 1.0f : std::pow((Float) 2.0f, ctx->exposure));
|
||||
? (Float) 1.0f : std::pow((Float) 2, ctx->exposure));
|
||||
}
|
||||
|
||||
bitmap->write(format, fs);
|
||||
|
@ -1549,8 +1552,24 @@ void MainWindow::on_actionSave_triggered() {
|
|||
saveScene(this, context, context->fileName);
|
||||
}
|
||||
|
||||
#if MTSGUI_STATIC_QFILEDIALOG
|
||||
|
||||
void MainWindow::on_actionSaveAs_triggered() {
|
||||
QFileDialog *dialog = new QFileDialog(this, tr("Save as .."),
|
||||
SceneContext *context = m_context[ui->tabBar->currentIndex()];
|
||||
QString fileDir = QFileInfo(context->fileName).absolutePath();
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save scene as ..."), fileDir, tr("Mitsuba scenes (*.xml)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
QSettings settings;
|
||||
settings.setValue("fileDir", QFileInfo(fileName).absolutePath());
|
||||
saveSceneAs(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
#else // MTSGUI_STATIC_QFILEDIALOG
|
||||
|
||||
void MainWindow::on_actionSaveAs_triggered() {
|
||||
QFileDialog *dialog = new QFileDialog(this, tr("Save scene as ..."),
|
||||
"", tr("Mitsuba scenes (*.xml)"));
|
||||
|
||||
m_currentChild = dialog;
|
||||
|
@ -1570,19 +1589,27 @@ void MainWindow::on_actionSaveAs_triggered() {
|
|||
}
|
||||
|
||||
void MainWindow::onSaveAsDialogClose(int reason) {
|
||||
int currentIndex = ui->tabBar->currentIndex();
|
||||
SceneContext *context = m_context[currentIndex];
|
||||
|
||||
QSettings settings;
|
||||
QFileDialog *dialog = static_cast<QFileDialog *>(sender());
|
||||
m_currentChild = NULL;
|
||||
if (reason == QDialog::Accepted) {
|
||||
QString fileName = dialog->selectedFiles().value(0);
|
||||
settings.setValue("fileDialogState", dialog->saveState());
|
||||
saveSceneAs(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MTSGUI_STATIC_QFILEDIALOG
|
||||
|
||||
void MainWindow::saveSceneAs(const QString &fileName) {
|
||||
if (!fileName.isEmpty()) {
|
||||
int currentIndex = ui->tabBar->currentIndex();
|
||||
SceneContext *context = m_context[currentIndex];
|
||||
|
||||
saveScene(this, context, fileName);
|
||||
fs::path pathName = toFsPath(fileName),
|
||||
complete = fs::absolute(pathName),
|
||||
baseName = pathName.stem();
|
||||
complete = fs::absolute(pathName),
|
||||
baseName = pathName.stem();
|
||||
context->fileName = fileName;
|
||||
context->shortName = QFileInfo(fileName).fileName();
|
||||
context->scene->setSourceFile(pathName);
|
||||
|
|
|
@ -195,8 +195,8 @@ private slots:
|
|||
#if !MTSGUI_STATIC_QFILEDIALOG
|
||||
void onOpenDialogClose(int reason);
|
||||
void onExportDialogClose(int reason);
|
||||
#endif
|
||||
void onSaveAsDialogClose(int reason);
|
||||
#endif
|
||||
void onRenderSettingsClose(int reason);
|
||||
void onImportDialogClose(int reason);
|
||||
void onSceneInformationClose(int reason);
|
||||
|
@ -207,6 +207,7 @@ private slots:
|
|||
|
||||
private:
|
||||
void exportImage(const QString &fileName);
|
||||
void saveSceneAs(const QString &fileName);
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QAction *m_actRecent[MAX_RECENT_FILES];
|
||||
|
|
Loading…
Reference in New Issue