Changeset - 98a2c6cae168
[Not reviewed]
default
0 3 0
Michael Guravage - 15 years ago 2010-11-30 10:51:27
michael.guravage@cwi.nl
Install imageformats folder alongside Windows executable.
Solicit supported image formats for file dialogue filter.

--
user: Michael Guravage <michael.guravage@cwi.nl>
branch 'default'
changed src/ChangeLog
changed src/VirtualLeaf-install-windows.nsi
changed src/canvas.cpp
3 files changed with 41 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/ChangeLog
Show inline comments
 
2010-11-30    <guravage@petitdru.sen.cwi.nl>
 

	
 
	* VirtualLeaf-install-windows.nsi: Include imageformats folder
 
	alongside executable.
 

	
 
	* canvas.cpp (snapshot): PNG is the default image format.
 

	
 
2010-11-29    <guravage@petitdru.sen.cwi.nl>
 

	
 
	* canvas.cpp (snapshot): Query and display supported snapshot file
 
	formats.
 

	
 
	* VirtualLeaf-install-windows.nsi: To facilitate debugging I added
 
	the debug versions of all the windows DLLs.
 

	
 
2010-10-19    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* mainbase.cpp (Save): Use format specified in function prototype.
 

	
 
	* VirtualLeaf.cpp (Plot): Render PNG instead of JPEG. Write image
 
	and XML files dependent only on getTime().
 

	
 
2010-10-18    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* mainbase.cpp (Save): QDir::toNativeSeparators(fname). Invoke
 
	save with format argument set to zero to force QImage to guess the
 
	format by looking at fileName's suffix.
 

	
 
	* VirtualLeaf-install.nsi: Put uninstaller in top directory.
 

	
 
	* modelcatalogue.cpp (InstallModel): For all OS-es. Move from "bin" directory to root application folder.
 

	
 
	* VirtualLeaf.pro: MAXOSX, look for gpl3.txt in the ../doc directory.
 

	
 
	* Makefile (Makefile.libplugin): Removed -makefile qmake option.
 

	
 
	* VirtualLeaf.cpp (TIMESTEP): Removed getIterations().
 

	
 
	* mesh.h (Mesh): Removed {increment,get}Iterations().
 

	
 
	* canvas.cpp (TimeStepWrap): Replaced getIterations() with getTime().
 

	
 
2010-10-15    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* mesh.h (Mesh): Added iterations. incrementIterations() and
 
	getIterations().
 

	
 
	* VirtualLeaf.cpp (Plot): Replaced local frame counter with
 
	mesh.incrementIterations().
 

	
 
	* canvas.cpp (TimeStepWrap): Replaced local counter with
 
	mesh.incrementIterations().
 

	
 
2010-10-14    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* VirtualLeaf.pro: Turned debug off to make all profiles must be
 
	consistant.
 

	
 
	* VirtualLeaf-install.nsi: Tweaked paths to coincide with UNIX
 
	distribution, i.e. VirtualLeaf.exe, its libraries, models, and the
 
	uninstaller all go in the bin directory. And leaves directory
 
	placed under data directory.
 

	
src/VirtualLeaf-install-windows.nsi
Show inline comments
 
@@ -86,100 +86,111 @@
 
# Directory page
 
!insertmacro MUI_PAGE_DIRECTORY
 

	
 
# Instfiles page
 
!insertmacro MUI_PAGE_INSTFILES
 

	
 
# Finish page
 
!insertmacro MUI_PAGE_FINISH
 

	
 
# Uninstaller pages
 
!insertmacro MUI_UNPAGE_CONFIRM
 
!insertmacro MUI_UNPAGE_INSTFILES
 
!insertmacro MUI_UNPAGE_FINISH
 

	
 
# Language files
 
!insertmacro MUI_LANGUAGE "English"
 

	
 
# MUI end ------
 

	
 
# set the name of the installer
 
outfile "VirtualLeaf-install.exe"
 
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
 
ShowInstDetails show
 
ShowUnInstDetails show
 
 
 
# define the directory to install to
 
installDir C:\VirtualLeaf
 

	
 
# Request application privileges
 
RequestExecutionLevel user
 

	
 
section "Virtual Leaf executable"
 
  #sectionIn RO
 
  # define the output path for the Virtual Leaf executable
 
  setOutPath $INSTDIR\bin
 
  writeUninstaller $INSTDIR\uninstaller.exe
 
  file ..\bin\VirtualLeaf.exe
 

	
 
  # Required DLLs
 
  setOutPath $INSTDIR\bin
 

	
 
  file ..\lib\libiconv\bin\libiconv-2.dll
 
  file ..\lib\libxml2\lib\libxml2.dll
 
  file ..\lib\libz\bin\zlib1.dll
 

	
 
  # Is the pegging of these DLLs to a specific QT version a problem?
 
  file C:\Qt\2010.02.1\mingw\bin\mingwm10.dll
 
  file C:\Qt\2010.02.1\mingw\bin\libgcc_s_dw2-1.dll
 

	
 
  file C:\Qt\2010.02.1\qt\bin\Qt3Support4.dll
 
  file C:\Qt\2010.02.1\qt\bin\QtCore4.dll
 
  file C:\Qt\2010.02.1\qt\bin\QtGui4.dll
 
  file C:\Qt\2010.02.1\qt\bin\QtNetwork4.dll
 
  file C:\Qt\2010.02.1\qt\bin\QtSql4.dll
 
  file C:\Qt\2010.02.1\qt\bin\QtXml4.dll
 

	
 
  # Prepend the Virtual Leaf bin directory to the installers PATH
 
  ${EnvVarUpdate} $0 "PATH" "P" "HKCU" "$INSTDIR\bin"  
 

	
 
  # create a shortcut named "VirtualLeaf" in the start menu programs directory
 
  # point the new shortcut at the program VirtualLeaf
 
  createShortCut "$SMPROGRAMS\VirtualLeaf.lnk" "$INSTDIR\bin\VirtualLeaf.exe"
 
sectionEnd
 
 
 

	
 
section "Image Formats"
 
  # define the output path for the Qt Image Formats
 
  setOutPath $INSTDIR\bin\imageformats
 
  file C:\Qt\2010.02.1\qt\plugins\imageformats\qgif4.dll
 
  file C:\Qt\2010.02.1\qt\plugins\imageformats\qico4.dll
 
  file C:\Qt\2010.02.1\qt\plugins\imageformats\qjpeg4.dll
 
  file C:\Qt\2010.02.1\qt\plugins\imageformats\qmng4.dll
 
  file C:\Qt\2010.02.1\qt\plugins\imageformats\qsvg4.dll
 
  file C:\Qt\2010.02.1\qt\plugins\imageformats\qtiff4.dll
 
sectionEnd
 

	
 

	
 
section "Virtual Leaf plugins"
 
  # define the output path for the Virtual Leaf models
 
  setOutPath $INSTDIR\bin\models
 
  file ..\bin\models\*
 
sectionEnd
 

	
 
section "Virtual Leaf data"
 
  # define the output path for the Virtual Leaf models
 
  setOutPath $INSTDIR\data\leaves
 
  file ..\data\leaves\*
 
sectionEnd
 

	
 
section "Virtual Leaf docs"
 
  # define the output path for the Virtual Leaf documentation
 
  setOutPath $INSTDIR\doc
 
  file ..\doc\*
 
sectionEnd
 

	
 
# create a section to define what the uninstaller does.
 
# the section will always be named "Uninstall"
 
section "Uninstall"
 

	
 
  # Always delete uninstaller first
 
  delete $INSTDIR\uninstaller.exe
 
 
 
  # Now delete installed file
 
  !insertmacro RemoveFilesAndSubDirs "$INSTDIR"
 

	
 
  # Delete shortcut from start menu
 
  delete "$SMPROGRAMS\VirtualLeaf.lnk"
 

	
 
  # Last but not least - delete the path  
 
  ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\bin"
 
sectionEnd
 

	
 
# finis
src/canvas.cpp
Show inline comments
 
@@ -2,96 +2,97 @@
 
 *
 
 *  This file is part of the Virtual Leaf.
 
 *
 
 *  VirtualLeaf is free software: you can redistribute it and/or modify
 
 *  it under the terms of the GNU General Public License as published by
 
 *  the Free Software Foundation, either version 3 of the License, or
 
 *  (at your option) any later version.
 
 *
 
 *  VirtualLeaf is distributed in the hope that it will be useful,
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 *  GNU General Public License for more details.
 
 *
 
 *  You should have received a copy of the GNU General Public License
 
 *  along with the Virtual Leaf.  If not, see <http://www.gnu.org/licenses/>.
 
 *
 
 *  Copyright 2010 Roeland Merks.
 
 *
 
 */
 

	
 
#include <time.h>
 
#include <string>
 
#include <fstream>
 
#include <streambuf>
 
#include <QGraphicsScene>
 
#include <QGraphicsView>
 
#include <qdatetime.h>
 
#include <q3mainwindow.h>
 
#include <qstatusbar.h>
 
#include <qmessagebox.h>
 
#include <qmenubar.h>
 
#include <qapplication.h>
 
#include <qpainter.h>
 
#include <qprinter.h>
 
#include <qlabel.h>
 
#include <qimage.h>
 
#include <q3progressdialog.h>
 
#include <qtimer.h>
 
#include <qslider.h>
 
#include <qpixmap.h>
 
#include <qfile.h>
 
#include <qdir.h>
 
#include <q3filedialog.h>
 
#include <QGraphicsItem>
 
#include <QList>
 
#include <QDir>
 
#include <QFileInfo>
 
#include <QDebug>
 
#include <QImageWriter>
 

	
 
#include <set>
 

	
 
//Added by qt3to4:
 
#include <Q3ValueList>
 
#include <Q3PopupMenu>
 
#include <QMouseEvent>
 
#include <typeinfo>
 
#include <cstring>
 
#include <q3process.h>
 
#include <qlayout.h>
 
#include <qspinbox.h>
 
#include <fstream>
 
#include <sstream>
 
#include "pardialog.h"
 
#include "parameter.h"
 
#include "canvas.h"
 
#include "node.h"
 
#include "nodeset.h"
 
#include "nodeitem.h"
 
#include "cellitem.h"
 
#include "wallitem.h"
 
#include "mesh.h"
 
#include "xmlwrite.h"
 
#include "OptionFileDialog.h"
 
#include <cstdlib>
 
#include <cstdio>
 
#include "modelcatalogue.h"
 

	
 
#include <algorithm>
 

	
 
// Include VIB and PSB logos
 
#include "psb.xpm"
 
#include "cwi.xpm"
 

	
 
static const std::string _module_id("$Id$");
 

	
 
using namespace std;
 

	
 
// We use a global variable to save memory - all the brushes and pens in
 
// the mesh are shared.
 

	
 
#define FNAMESIZE 100
 
#define QUOTE_ME(s) QUOTE_ME_2NDLEV(s)
 
#define QUOTE_ME_2NDLEV(s) #s
 

	
 
static QColor dark_red("darkRed");
 

	
 
@@ -683,113 +684,122 @@ void Main::saveStateXML()
 
  stopSimulation();
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  fd->setFilter( "LeafML files (*.xml)");
 
  fd->setDir(par.datadir);
 
  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 = "xml";
 
      fileName += ".";
 
      fileName += extension;
 
    }
 
    
 
    
 
    if ( QFile::exists( fileName ) &&
 
	 QMessageBox::question(
 
			       this,
 
			       tr("Overwrite File? -- Leaf Growth"),
 
			       tr("A file called %1 already exists."
 
				  " Do you want to overwrite it?")
 
			       .arg( fileName ),
 
			       tr("&Yes"), tr("&No"),
 
			       QString::null, 1, 1 ) ) {
 
      return saveStateXML();
 

	
 
    } else {
 

	
 
      mesh.XMLSave((const char *)fileName, XMLSettingsTree());
 
      QString status_message;
 
      status_message = QString("Wrote LeafML to %1").arg(fileName);
 
      cerr << status_message.toStdString() << endl;
 
      statusBar()->showMessage(status_message);
 
    }
 
  }
 
}
 

	
 

	
 

	
 
void Main::snapshot()
 
{
 

	
 
#ifdef QDEBUG
 
  qDebug() << "Supported Image Formats: " << QImageWriter::supportedImageFormats() << endl;
 
#endif
 

	
 
  stopSimulation();
 
  Q3FileDialog *fd = new Q3FileDialog( this, "Save snapshot", TRUE );
 
  fd->setDir(par.datadir);
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  fd->setFilter( "Image files (*.pdf *.png *.jpg *.tif)");
 

	
 
  QString supported_file_formats = " .pdf";
 
  foreach (QString format, QImageWriter::supportedImageFormats()){
 
    supported_file_formats += (" ." + format);
 
  }
 

	
 
  fd->setFilter("Image files (" + supported_file_formats + " )");
 

	
 
  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";
 
      extension = "png";
 
      fileName += ".";
 
      fileName += extension;
 
    }
 
    
 
    
 
    if ( QFile::exists( fileName ) &&
 
	 QMessageBox::question(
 
			       this,
 
			       tr("Overwrite file? -- Cell data export"),
 
			       tr("A file called %1 already exists."
 
				  " Do you want to overwrite it?").arg( fileName ),
 
			       QMessageBox::Yes, QMessageBox::No 
 
			       ) == QMessageBox::No
 
	 ) {
 
      
 
      return snapshot();
 
      
 
    } else {
 

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

	
 
    }
 
  }
 
}
 

	
 

	
 

	
 
void Main::readPrevStateXML()
 
{
 

	
 
  // if we have already read a file, read the next file
 
  if (!currentFile.isEmpty() && working_dir) {
 
    QString next_file;
 

	
 
    QStringList xml_files = working_dir->entryList("*.xml");
 
    QString currentFile_nopath = currentFile.section( '/', -1 );
 
    QString currentFile_path = currentFile.section( '/', 0, -2 );
 

	
 
    QList<QString>::iterator f = xml_files.find( currentFile_nopath );
 

	
0 comments (0 inline, 0 general)