Changeset - c6ad8e34e8eb
[Not reviewed]
default
2 2 0
Roeland Merks - 15 years ago 2010-11-25 12:02:40
roeland.merks@cwi.nl
In response to referee's comment:

"I am also afraid that

the ‘snapshot’ and the ‘Export cell data’ functions do not seem to work very
well in my hands, could the program be changed so that the correct file
extension (.jpg, .tif, .txt, .dat, .xls, .csv…) is given automatically."

I corrected the "export cell data" dialog (it did not actually write the file in the submitted version). Also we now assume default file extensions (.jpg for snapshot and .csv for data export) if none is given.

--
user: Roeland Merks <roeland.merks@cwi.nl>
branch 'default'
changed src/VirtualLeaf.pro
changed src/canvas.cpp
removed src/miscq.cpp
removed src/miscq.h
4 files changed with 64 insertions and 97 deletions:
0 comments (0 inline, 0 general)
src/VirtualLeaf.pro
Show inline comments
 
@@ -92,7 +92,6 @@ HEADERS += \
 
 mainbase.h \
 
 matrix.h \
 
 mesh.h \
 
 miscq.h \
 
 modelcatalogue.h \
 
 Neighbor.h \
 
 node.h \
 
@@ -132,7 +131,6 @@ SOURCES += \
 
 mainbase.cpp \
 
 matrix.cpp \
 
 mesh.cpp \
 
 miscq.cpp \
 
 modelcatalogue.cpp \
 
 Neighbor.cpp \
 
 node.cpp \
src/canvas.cpp
Show inline comments
 
@@ -45,7 +45,7 @@
 
#include <QGraphicsItem>
 
#include <QList>
 
#include <QDir>
 

	
 
#include <QFileInfo>
 
#include <QDebug>
 

	
 
#include <set>
 
@@ -71,7 +71,6 @@
 
#include "wallitem.h"
 
#include "mesh.h"
 
#include "xmlwrite.h"
 
#include "miscq.h"
 
#include "OptionFileDialog.h"
 
#include <cstdlib>
 
#include <cstdio>
 
@@ -682,7 +681,7 @@ void Main::saveStateXML()
 
  stopSimulation();
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  fd->setFilter( "XML (*.xml)");
 
  fd->setFilter( "LeafML files (*.xml)");
 
  QString fileName;
 

	
 
  if ( fd->exec() == QDialog::Accepted ) {
 
@@ -715,29 +714,43 @@ void Main::snapshot()
 
  stopSimulation();
 
  Q3FileDialog *fd = new Q3FileDialog( this, "Save snapshot", TRUE );
 
  fd->setMode( Q3FileDialog::AnyFile );
 

	
 
  fd->setFilter( "Image files (*.pdf *.png *.jpg *.tif *.bpm)");
 
  QString fileName;
 

	
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 
    
 
    // extract extension from filename
 
    QFileInfo fi(fileName);
 
    QString extension = fi.suffix();
 
    
 
    if (extension.isEmpty()) {
 
      extension = "jpg";
 
      fileName += ".";
 
      fileName += extension;
 
    }
 
    
 
    
 
    if ( QFile::exists( fileName ) &&
 
	 QMessageBox::question(
 
			       this,
 
			       tr("Overwrite File? -- Leaf Growth"),
 
			       tr("Overwrite file? -- Cell data export"),
 
			       tr("A file called %1 already exists."
 
				  " Do you want to overwrite it?")
 
			       .arg( fileName ),
 
			       tr("&Yes"), tr("&No"),
 
			       QString::null, 1, 1 ) ) {
 
				  " Do you want to overwrite it?").arg( fileName ),
 
			       QMessageBox::Yes, QMessageBox::No 
 
			       ) == QMessageBox::No
 
	 ) {
 
      
 
      return snapshot();
 

	
 
      
 
    } else {
 

	
 
      // extract extension from filename
 
      QString extension = getExtension(fileName);
 

	
 
      // Save bitmaps at 1024x768
 
      Save((const char *)fileName, extension, 1024, 768);
 
      QString status_message = QString("Wrote snapshot to %1").arg(fileName);
 
      cerr << status_message.toStdString() << endl;
 
      statusBar()->showMessage(status_message);
 

	
 
    }
 
  }
 
}
 
@@ -908,7 +921,7 @@ void Main::readStateXML()
 
#endif
 
  OptionFileDialog *fd = new OptionFileDialog( this, "read dialog", TRUE );
 
  fd->setMode( OptionFileDialog::ExistingFile );
 
  fd->setFilter( "XML files (*.xml)");
 
  fd->setFilter( "LeafML files (*.xml)");
 
  if (working_dir) {
 
    fd->setDir(*working_dir);
 
  }
 
@@ -1408,21 +1421,51 @@ void Main::exportCellData() {
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 

	
 
    // extract extension from filename
 
    QFileInfo fi(fileName);
 
    QString extension = fi.suffix();
 
    
 
    if (extension.isEmpty()) {
 
      extension = "csv";
 
      fileName += ".";
 
      fileName += extension;
 
    }
 

	
 
    if (extension!="csv" && extension!="CSV") {
 
      
 
      if (
 
	  QMessageBox::question(
 
				 this,
 
				 tr("Change extension? -- Cell data export"),
 
				 tr("VirtualLeaf can only export data to CSV format (Excel-compatible)."
 
				    "Do you want to change the file extension to \".csv\"?"),
 
				 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No 
 
	  ) {
 

	
 
	return exportCellData();
 
      } else {
 
	fileName.replace(extension,"csv");
 
	extension="csv";
 
      }
 
    }
 
    if ( QFile::exists( fileName ) &&
 
	 !QMessageBox::question(
 
	 QMessageBox::question(
 
			       this,
 
			       tr("Overwrite File? -- Cell Data"),
 
			       tr("Overwrite file? -- Cell data export"),
 
			       tr("A file called %1 already exists."
 
				  " Do you want to overwrite it?")
 
			       .arg( fileName ),
 
			       tr("&Yes"), tr("&No"),
 
			       QString::null, 1, 1 ) ) {
 
				  " Do you want to overwrite it?").arg( fileName ),
 
			       QMessageBox::Yes, QMessageBox::No 
 
			       ) == QMessageBox::No
 
	 ) {
 
      return exportCellData();
 
    } else {
 
      exportCellData(fileName);
 
      QString status_message = QString("Wrote data file to %1").arg(fileName);
 
      statusBar()->showMessage(status_message);
 
    }
 
  }
 
}
 

	
 

	
 
/* finis */
 
  /* finis */
src/miscq.cpp
Show inline comments
 
deleted file
src/miscq.h
Show inline comments
 
deleted file
0 comments (0 inline, 0 general)