Changeset - bb80657b6912
[Not reviewed]
default
0 13 0
Michael Guravage - 15 years ago 2010-10-08 16:58:27
michael.guravage@cwi.nl
Export Cell Data at interval specified in the leafML file or explicitly via the file menu.
Added new parameters to VirtualLeafpar.tmpl
Added GPL boilerplate to make_{parameter,pardialog}_source.pl files.
Added new parameters to auxin_growth.xml. See respective ChangeLog files for details.

--
user: Michael Guravage <michael.guravage@cwi.nl>
branch 'default'
changed data/leaves/ChangeLog
changed data/leaves/auxin_growth.xml
changed src/ChangeLog
changed src/VirtualLeafpar.tmpl
changed src/canvas.cpp
changed src/canvas.h
changed src/parameter.cpp
changed src/parameter.h
changed src/pardialog.cpp
changed src/pardialog.h
changed src/perl/ChangeLog
changed src/perl/make_parameter_source.pl
changed src/perl/make_pardialog_source.pl
13 files changed with 257 insertions and 20 deletions:
0 comments (0 inline, 0 general)
data/leaves/ChangeLog
Show inline comments
 
2010-10-08    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* auxin_growth.xml: Added export_interval and export_fn_prefix parameters.
 

	
 

	
 
2010-06-23    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* Added: tutorial3_init.xml
data/leaves/auxin_growth.xml
Show inline comments
 
@@ -26,6 +26,8 @@
 

	
 
<leaf name="/Users/roel/VLeafClean_plugin/Snapshot/VLeafMacOSX/auxin_growth.xml" date="Sat Aug 29 18:28:19 2009" simtime="11660">
 
  <parameter>
 
    <par name="export_interval" val="1000"/>
 
    <par name="export_fn_prefix" val="CELLDATA_"/>
 
    <par name="arrowcolor" val="white"/>
 
    <par name="arrowsize" val="10"/>
 
    <par name="textcolor" val="red"/>
src/ChangeLog
Show inline comments
 
2010-10-08    <guravage@caterpie.sen.cwi.nl>
 

	
 

	
 
	* pardialog.h:
 
	* pardialog.cpp:
 
	* parameter.h:
 
	* parameter.cpp: Regenerated to include export_interval and export_fn_prefix.
 

	
 
	* VirtualLeafpar.tmpl: Appended export_interval and export_fn_prefix.
 

	
 
	* canvas.h (MainBase): Declared polymorphic exportCellData() functions.
 

	
 
	* canvas.cpp:
 
	(TimeStamp): New private TimeStamp() function.
 
	(TimeStepWrap): Added invocation of exportCellData().
 
	(exportCellData): Created two polymorphic functions: one with a
 
	single QString argument, the other with no argument. The former is
 
	called from TimeStepWrap() while the latter is called from the
 
	"Export cell areas" item in the file menu.
 

	
 

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

	
 
	* canvas.cpp (exportCellData): Added a Q3FileDialog to inquire
src/VirtualLeafpar.tmpl
Show inline comments
 
@@ -124,3 +124,5 @@ b3 = false / bool
 
b4 = false / bool
 
dir1 = . / directory
 
dir2 = . / directory
 
export_interval = 0 / int
 
export_fn_prefix = CellData_ / string
src/canvas.cpp
Show inline comments
 
@@ -19,6 +19,7 @@
 
 *
 
 */
 

	
 
#include <time.h>
 
#include <string>
 
#include <fstream>
 
#include <streambuf>
 
@@ -1166,6 +1167,11 @@ void Main::TimeStepWrap(void)
 
  static int t=0;
 
  TimeStep();
 
  t++;
 

	
 
  if ((par.export_interval > 0) && ((t % par.export_interval) == 0)){
 
    this->exportCellData(QString(par.datadir) + QString('/') + QString(par.export_fn_prefix) + this->TimeStamp());
 
  }
 

	
 
  // check number of timesteps
 
  if (t==par.nit) {
 
    emit SimulationDone();
 
@@ -1173,6 +1179,18 @@ void Main::TimeStepWrap(void)
 
}
 

	
 

	
 
QString Main::TimeStamp(){
 
  time_t rawtime;
 
  struct tm * timeinfo;
 
  char buffer [15];
 

	
 
  time ( &rawtime );
 
  timeinfo = localtime ( &rawtime );
 
  strftime (buffer,15,"%Y%m%d%H%M%S",timeinfo);
 
  return QString(buffer);
 
}
 

	
 

	
 
void Main::RestartSim(void)
 
{
 

	
 
@@ -1366,25 +1384,12 @@ xmlNode *Main::XMLSettingsTree(void)
 
  return settings;
 
}
 

	
 
void Main::exportCellData(void) {
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 
  QString fileName;
 
  
 
  stopSimulation();
 
  fd->setMode( Q3FileDialog::AnyFile );
 

	
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 
void Main::exportCellData(QString fileName) {
 

	
 
#ifdef QDEBUG  
 
    qDebug() << "exportCellData filename: " << fileName << endl;
 
  qDebug() << "exportCellData fileName: " << fileName << endl;
 
#endif
 

	
 
  // perhaps make this more general: a popup window were user selects data he wants to export
 
  // can go to "settings" section of XML file as well so this can also be measured off-line
 
  // mesh.CSVExport would take an QMap or so to record all options
 
  // first line gives legenda
 

	
 
    QFile file(fileName);
 
    if ( file.open( IO_WriteOnly ) ) {
 
      QTextStream stream( &file );
 
@@ -1393,6 +1398,19 @@ void Main::exportCellData(void) {
 
      file.close();
 
    }
 
  }
 

	
 

	
 
void Main::exportCellData() {
 
  QString fileName;
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 

	
 
  stopSimulation();
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 
  }
 
  this->exportCellData(fileName);
 
}
 

	
 

	
 
/* finis */
src/canvas.h
Show inline comments
 
@@ -207,6 +207,7 @@ class Main : public Q3MainWindow, public
 
  void readFirstStateXML();
 
  void readLastStateXML();
 
  void exportCellData();
 
  void exportCellData(QString);
 
  void saveStateXML();
 
  void snapshot();
 
  void savePars();
 
@@ -226,6 +227,8 @@ class Main : public Q3MainWindow, public
 

	
 
  void RandomizeMesh();
 

	
 
  QString TimeStamp();
 

	
 
 signals:
 
  void SimulationDone(void);
 
  void ParsChanged(void);
src/parameter.cpp
Show inline comments
 
@@ -19,6 +19,9 @@
 
 *
 
 */
 

	
 
// Do not edit. All edits will be discarded.
 

	
 

	
 
#include "parameter.h"
 
#include <cstdio>
 
#include <cstring>
 
@@ -183,6 +186,8 @@ Parameter::Parameter() {
 
  b4 = false;
 
  dir1 = strdup(".");
 
  dir2 = strdup(".");
 
  export_interval = 100;
 
  export_fn_prefix = strdup("CELLDATA");
 
}
 

	
 
Parameter::~Parameter() {
 
@@ -217,6 +222,8 @@ void Parameter::CleanUp(void) {
 
    free(dir1);
 
  if (dir2) 
 
    free(dir2);
 
  if (export_fn_prefix) 
 
     free(export_fn_prefix);
 

	
 
}
 

	
 
@@ -340,6 +347,8 @@ void Parameter::Read(const char *filenam
 
  dir2 = sgetpar(fp, "dir2", ".", true);
 
  if (strcmp(dir2, "."))
 
    MakeDir(dir2);
 
  export_interval = igetpar(fp, "export_interval", 100, true);
 
  export_fn_prefix = sgetpar(fp, "export_fn_prefix", "CELLDATA", true);
 
}
 

	
 
const char *sbool(const bool &p) {
 
@@ -474,6 +483,10 @@ void Parameter::Write(ostream &os) const
 

	
 
  if (dir2) 
 
    os << " dir2 = " << dir2 << endl;
 
  os << " export_interval = " << export_interval << endl;
 

	
 
  if (export_fn_prefix) 
 
  os << " export_fn_prefix = " << export_fn_prefix << endl;
 
}
 

	
 
void Parameter::XMLAdd(xmlNode *root) const {
 
@@ -1448,6 +1461,22 @@ void Parameter::XMLAdd(xmlNode *root) co
 
      text << dir2;
 
    xmlNewProp(xmlpar, BAD_CAST "val", BAD_CAST text.str().c_str());
 
  }
 
{
 
  xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
  xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "export_interval" );
 
  ostringstream text;
 
    text << export_interval;
 
xmlNewProp(xmlpar, BAD_CAST "val", BAD_CAST text.str().c_str());
 
}
 
{
 
  xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
  xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "export_fn_prefix" );
 
  ostringstream text;
 

	
 
  if (export_fn_prefix) 
 
    text << export_fn_prefix;
 
xmlNewProp(xmlpar, BAD_CAST "val", BAD_CAST text.str().c_str());
 
}
 
}
 
void Parameter::AssignValToPar(const char *namec, const char *valc) {
 
  QLocale standardlocale(QLocale::C);
 
@@ -1826,6 +1855,14 @@ void Parameter::AssignValToPar(const cha
 
    if (dir2) { free(dir2); }
 
    dir2=strdup(valc);
 
  }
 
if (!strcmp(namec, "export_interval")) {
 
  export_interval = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'export_interval' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "export_fn_prefix")) {
 
  if (export_fn_prefix) { free(export_fn_prefix); }
 
  export_fn_prefix=strdup(valc);
 
}
 
}
 
void Parameter::AssignValArrayToPar(const char *namec, vector<double> valarray) {
 
  if (!strcmp(namec, "D")) {
src/parameter.h
Show inline comments
 
@@ -21,6 +21,9 @@
 
 *
 
 */
 

	
 
// WARNING: This file is automatically generated by make_parameter_source.pl. Do not edit.
 
// All edits will be discarded.
 

	
 
#ifndef _PARAMETER_H_
 
#define _PARAMETER_H_
 
#include "vector.h"
 
@@ -139,6 +142,8 @@
 
  bool b4;
 
  char * dir1;
 
  char * dir2;
 
  int export_interval;
 
  char * export_fn_prefix;
 
 private:
 
 };
 

	
 
@@ -147,5 +152,3 @@
 

	
 

	
 
#endif
 

	
 
/* finis */
src/pardialog.cpp
Show inline comments
 
@@ -19,6 +19,8 @@
 
 *
 
 */
 

	
 
// Do not edit. All edits will be discarded.
 

	
 
#include "pardialog.h"
 
#include "parameter.h"
 
#include <cstring>
 
@@ -135,12 +137,14 @@ ParameterDialog::ParameterDialog(QWidget
 
  b4_edit = new QLineEdit( QString("%1").arg(sbool(par.b4)), this, "b4_edit" );
 
  dir1_edit = new QLineEdit( QString("%1").arg(par.dir1), this, "dir1_edit" );
 
  dir2_edit = new QLineEdit( QString("%1").arg(par.dir2), this, "dir2_edit" );
 
  export_interval_edit = new QLineEdit( QString("%1").arg(par.export_interval), this, "export_interval_edit" );
 
  export_fn_prefix_edit = new QLineEdit( QString("%1").arg(par.export_fn_prefix), this, "export_fn_prefix_edit" );
 
  // make a 1x1 grid; it will auto-expand
 
  QGridLayout *grid = new QGridLayout( this, 1, 1 );
 
    
 
  // add the first four widgets with (row, column) addressing
 
  setWindowTitle( QString( " Parameter values for VirtualLeaf") );
 
  grid->addWidget( new QLabel( "<h3> Parameter values for VirtualLeaf</h3>",this), 0, 0, 1, -1, Qt::AlignCenter);
 
  setWindowTitle( QString( " Parameter values for The Virtual Leaf") );
 
  grid->addWidget( new QLabel( "<h3> Parameter values for The Virtual Leaf</h3>",this), 0, 0, 1, -1, Qt::AlignCenter);
 
  grid->addWidget( new QLabel( "", this), 0+1, 0, 1, -1);
 
  grid->addWidget( new QLabel( " <b>Visualization</b>", this), 3, 0, 1, 2 );
 
  grid->addWidget( new QLabel( "arrowcolor", this ),4, 0 );
 
@@ -349,6 +353,10 @@ ParameterDialog::ParameterDialog(QWidget
 
  grid->addWidget( dir1_edit, 29, 6+1  );
 
  grid->addWidget( new QLabel( "dir2", this ),3, 8 );
 
  grid->addWidget( dir2_edit, 3, 8+1  );
 
  grid->addWidget( new QLabel( "export_interval", this ),4, 8 );
 
  grid->addWidget( export_interval_edit, 4, 8+1  );
 
  grid->addWidget( new QLabel( "export_fn_prefix", this ),5, 8 );
 
  grid->addWidget( export_fn_prefix_edit, 5, 8+1  );
 
  QPushButton *pb = new QPushButton( "&Write", this );
 
  grid->addWidget(pb, 31, 6 );
 
  connect( pb, SIGNAL( clicked() ), this, SLOT( write() ) );
 
@@ -460,6 +468,8 @@ ParameterDialog::~ParameterDialog(void) 
 
  delete b4_edit;
 
  delete dir1_edit;
 
  delete dir2_edit;
 
delete export_interval_edit;
 
delete export_fn_prefix_edit;
 
}
 

	
 
void ParameterDialog::write(void) {
 
@@ -693,6 +703,8 @@ void ParameterDialog::write(void) {
 
  }
 
  par.dir1 = strdup((const char *)dir1_edit->text());
 
  par.dir2 = strdup((const char *)dir2_edit->text());
 
  par.export_interval = export_interval_edit->text().toInt();
 
  par.export_fn_prefix = strdup((const char *)export_fn_prefix_edit->text());
 
  Reset();
 

	
 
}
 
@@ -802,6 +814,8 @@ void ParameterDialog::Reset(void) {
 
  b4_edit->setText( QString("%1").arg(sbool(par.b4)));
 
  dir1_edit->setText( QString("%1").arg(par.dir1) );
 
  dir2_edit->setText( QString("%1").arg(par.dir2) );
 
  export_interval_edit->setText( QString("%1").arg(par.export_interval) );
 
  export_fn_prefix_edit->setText( QString("%1").arg(par.export_fn_prefix) );
 
}
 

	
 
/* finis */
src/pardialog.h
Show inline comments
 
/*
 
 *
 
 *  $Id$
 
 *
 
 *  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.
 
 *
 
 */
 

	
 
// WARNING: This file is automatically generated by make_parameter_source.pl. Do not edit.
 
// All edits will be discarded.
 

	
 
#ifndef PARAMETER_DIALOG_H
 
#define PARAMETER_DIALOG_H
 
#include <qdialog.h>
 
@@ -118,5 +144,8 @@ class ParameterDialog : public QDialog {
 
  QLineEdit *b4_edit;
 
  QLineEdit *dir1_edit;
 
  QLineEdit *dir2_edit;
 
  QLineEdit *export_interval_edit;
 
  QLineEdit *export_fn_prefix_edit;
 
};
 
#endif
 

	
src/perl/ChangeLog
Show inline comments
 
2010-10-08    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* make_pardialog_source.pl:
 
	* make_parameter_source.pl: Added GPL boilerplate and mercurial keywords.
 

	
 
2010-06-25    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* make_parameter_source.pl: Added datadir changes.
src/perl/make_parameter_source.pl
Show inline comments
 
@@ -88,6 +88,27 @@ while (<parfile>) {
 
$lines=$i;
 

	
 
print cppfile <<END_HEADER;
 
/*
 
 *
 
 *  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.
 
 *
 
 */
 

	
 
// WARNING: This file is automatically generated by make_parameter_source.pl.
 
// Do not edit. All edits will be discarded.
 

	
 
@@ -108,6 +129,8 @@ print cppfile <<END_HEADER;
 

	
 
using namespace std;
 

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

	
 
Parameter::Parameter() {
 
END_HEADER
 

	
 
@@ -373,8 +396,31 @@ END_TRAILER
 

	
 
open hfile, ">parameter.h";
 
print hfile <<END_HEADER2;
 
/*
 
 *
 
 *  \$Id\$
 
 *
 
 *  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.
 
 *
 
 */
 

	
 
// WARNING: This file is automatically generated by make_parameter_source.pl. Do not edit.
 
// All edits will be discarded.
 
// Do not edit. All edits will be discarded.
 

	
 
#ifndef _PARAMETER_H_
 
#define _PARAMETER_H_
src/perl/make_pardialog_source.pl
Show inline comments
 
@@ -88,6 +88,30 @@ while (<parfile>) {
 

	
 

	
 
print cppfile <<END_HEADER;
 
/*
 
 *
 
 *  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.
 
 *
 
 */
 

	
 
// WARNING: This file is automatically generated by make_parameter_source.pl. Do not edit.
 
// Do not edit. All edits will be discarded.
 

	
 
#include "$basename.h"
 
#include "parameter.h"
 
#include <cstring>
 
@@ -96,6 +120,8 @@ print cppfile <<END_HEADER;
 
#include <qlineedit.h>
 
#include <qmessagebox.h>
 

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

	
 
ParameterDialog::ParameterDialog(QWidget *parent, const char *name, Qt::WindowFlags f) : QDialog(parent,name,false,f) {
 
    extern Parameter par;
 
END_HEADER
 
@@ -265,6 +291,32 @@ print cppfile "}\n\n";
 

	
 
open hfile, ">$basename.h";
 
print hfile <<END_HEADER2;
 
/*
 
 *
 
 *  \$Id\$
 
 *
 
 *  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.
 
 *
 
 */
 

	
 
// WARNING: This file is automatically generated by make_parameter_source.pl. Do not edit.
 
// Do not edit. All edits will be discarded.
 

	
 
#ifndef PARAMETER_DIALOG_H
 
#define PARAMETER_DIALOG_H
 
#include <qdialog.h>
0 comments (0 inline, 0 general)