| Attached Files | 0001156.diff [^] (5,321 bytes) 2012-01-19 19:23 [Show Content] [Hide Content]diff -r 804fa18e8bc1 qtgui/mainwindow.cpp
--- a/qtgui/mainwindow.cpp Thu Jan 19 09:44:35 2012 +0100
+++ b/qtgui/mainwindow.cpp Thu Jan 19 20:20:31 2012 -0700
@@ -49,6 +49,8 @@
#include <QStringListModel>
+#include <QFile>
+
#include "error.h"
#include "mainwindow.hxx"
@@ -887,30 +889,18 @@
void MainWindow::outputBufferGroupsTonemapped()
{
// Where should these be output
- QString fileName = QFileDialog::getSaveFileName(this, tr("Select a destination for the images"), m_lastOpendir, tr("PNG Image (*.png);;JPEG Image (*.jpg);;Windows Bitmap (*.bmp);;TIFF Image (*.tif)"));
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Select a destination for the images"), m_lastOpendir, tr("PNG Image (*.png);;JPEG Image (*.jpg);;Windows Bitmap (*.bmp);;TIFF Image (*.tif)"), NULL, QFileDialog::DontConfirmOverwrite);
if (fileName.isEmpty())
return;
- // Show busy cursor
- QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-
// Output the light groups
- if (saveAllLightGroups(fileName, false)) {
- statusMessage->setText(tr("Light group tonemapped images saved"));
- LOG(LUX_INFO, LUX_NOERROR) << "Light group tonemapped images saved to '" << qPrintable(fileName) << "'";
- } else {
- statusMessage->setText(tr("ERROR: Light group tonemapped images NOT saved"));
- LOG(LUX_WARNING, LUX_SYSTEM) << "Error while saving light group tonemapped images to '" << qPrintable(fileName) << "'";
- }
-
- // Stop showing busy cursor
- QApplication::restoreOverrideCursor();
+ saveAllLightGroups(fileName, false);
}
void MainWindow::outputBufferGroupsHDR()
{
// Where should these be output
- QString fileName = QFileDialog::getSaveFileName(this, tr("Select a destination for the images"), m_lastOpendir, tr("OpenEXR Image (*.exr)"));
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Select a destination for the images"), m_lastOpendir, tr("OpenEXR Image (*.exr)"), NULL, QFileDialog::DontConfirmOverwrite);
if (fileName.isEmpty())
return;
@@ -923,27 +913,42 @@
openExrCompressionType = options->getCompressionType();
delete options;
- // Show busy cursor
- QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-
// Output the light groups
- if (saveAllLightGroups(fileName, true)) {
- statusMessage->setText(tr("Light group HDR images saved"));
- LOG(LUX_INFO, LUX_NOERROR) << "Light group HDR images saved to '" << qPrintable(fileName) << "'";
- } else {
- statusMessage->setText(tr("ERROR: Light group HDR images NOT saved"));
- LOG(LUX_WARNING, LUX_SYSTEM) << "Error while saving light group HDR images to '" << qPrintable(fileName) << "'";
- }
-
- // Stop showing busy cursor
- QApplication::restoreOverrideCursor();
+ saveAllLightGroups(fileName, true);
}
bool MainWindow::saveAllLightGroups(const QString &outFilename, const bool &asHDR)
{
+ // Prepare filename (will hack up when outputting each light group)
+ boost::filesystem::path filenamePath(qPrintable(outFilename));
+
// Get number of light groups
int lgCount = (int)luxGetParameterValue(LUX_FILM, LUX_FILM_LG_COUNT);
+ // Check if output files already exist
+ for(int i=0; i<lgCount; i++)
+ {
+ // Get light group name
+ char lgName[256];
+ luxGetStringParameterValue(LUX_FILM, LUX_FILM_LG_NAME, lgName, 256, i);
+
+ // Generate output file name
+ QString outputName = QString("%1/%2-%3%4").arg(filenamePath.parent_path().string().c_str())
+ .arg(filenamePath.stem().c_str()).arg(lgName).arg(filenamePath.extension().c_str());
+
+ // Check if file exists
+ if (QFile::exists(outputName))
+ {
+ // File exists - ask user if existing files should be overwritten
+ if (QMessageBox::warning(this, tr("Confirm Save As"),tr("Light group files already exist.\nDo you want to replace them?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No)
+ return false;
+ break;
+ }
+ }
+
+ // Show busy cursor
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+
// Start by save current light group state and turning off ALL light groups
vector<bool> prevLGState(lgCount);
for(int i=0; i<lgCount; i++)
@@ -952,9 +957,6 @@
luxSetParameterValue(LUX_FILM, LUX_FILM_LG_ENABLE, 0.f, i);
}
- // Prepare filename (will hack up when outputting each light group)
- boost::filesystem::path filenamePath(qPrintable(outFilename));
-
// Get film resolution (only needed for tonemapped case but better off being outside loop)
int w = luxGetIntAttribute("film", "xResolution");
int h = luxGetIntAttribute("film", "yResolution");
@@ -1001,6 +1003,21 @@
if (!asHDR)
luxUpdateFramebuffer();
+ // Report on success or failure
+ QString outputName = QString("%1/%2-*%4").arg(filenamePath.parent_path().string().c_str())
+ .arg(filenamePath.stem().c_str()).arg(filenamePath.extension().c_str());
+
+ if (result) {
+ statusMessage->setText(tr("Light group images saved"));
+ LOG(LUX_INFO, LUX_NOERROR) << "Light group images saved to '" << qPrintable(outputName) << "'";
+ } else {
+ statusMessage->setText(tr("ERROR: Light group images NOT saved"));
+ LOG(LUX_WARNING, LUX_SYSTEM) << "Error while saving light group images to '" << qPrintable(outputName) << "'";
+ }
+
+ // Stop showing busy cursor
+ QApplication::restoreOverrideCursor();
+
// Report success or failure (always success when outputting HDR)
return result;
}
|