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
 
	tutorial4_init.xml
 
	tutorial5_init.xml
 

	
 
	* Removed: bend.xml
 
	circ.xml
 
	explant.xml
 
	init.xml
 
	one_acc_point_van3.xml
 
	one_acc_point_van3_growth.xml
 
	one_acc_point_van3_growth2.xml
 
	tissue.xml
data/leaves/auxin_growth.xml
Show inline comments
 
@@ -5,48 +5,50 @@
 
  $Author$:  Author of last commit
 
  $Source$:  Source file
 
  $Date$:  Date of last commit
 

	
 
  This file is part of the Virtual Leaf.
 

	
 
  The Virtual Leaf 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.
 

	
 
  The Virtual Leaf 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.
 
-->
 

	
 
<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"/>
 
    <par name="cellnumsize" val="1"/>
 
    <par name="nodenumsize" val="1"/>
 
    <par name="node_mag" val="1"/>
 
    <par name="outlinewidth" val="1"/>
 
    <par name="cell_outline_color" val="forestgreen"/>
 
    <par name="resize_stride" val="10"/>
 
    <par name="T" val="1"/>
 
    <par name="lambda_length" val="100"/>
 
    <par name="lambda_celllength" val="0"/>
 
    <par name="target_length" val="60"/>
 
    <par name="cell_expansion_rate" val="10"/>
 
    <par name="cell_div_expansion_rate" val="10"/>
 
    <par name="auxin_dependent_growth" val="true"/>
 
    <par name="ode_accuracy" val="0.0001"/>
 
    <par name="mc_stepsize" val="0.4"/>
 
    <par name="mc_cell_stepsize" val="0.2"/>
 
    <par name="energy_threshold" val="1000"/>
 
    <par name="bend_lambda" val="0"/>
 
    <par name="alignment_lambda" val="0"/>
 
    <par name="rel_cell_div_threshold" val="2"/>
 
    <par name="rel_perimeter_stiffness" val="2"/>
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
 
	where to write the exportCellData.
 

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

	
 

	
 
	* VirtualLeaf-install.nsi: Grab gpl3.txt from doc directory.
 

	
 
	* canvas.cpp (gpl): gpl3.txt can be either in an ancestor doc
 
	directory (Linux) or a decedent doc directory (Windows, via the
 
	binary installer).
 

	
 
	* VirtualLeaf-install.nsi: Add VirtualLeaf doc directory.
 

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

	
 

	
 
	* gpl3.txt: Moved gpl3.txt from doc to src directory.
 

	
 
	* VirtualLeaf.pro: Added -Wno-write-strings and -Wno-unused-parameter to QMAKE_CXXFLAGS.
 

	
 
	* libplugin.pro: Ditto.
src/VirtualLeafpar.tmpl
Show inline comments
 
@@ -103,24 +103,26 @@ c = 0. / double
 
mu = 0. / double
 
nu = 0. / double
 
rho0 = 0. / double
 
rho1 = 0. / double
 
c0 = 0. / double
 
gamma = 0. / double
 
eps = 0. / double
 
label = / label
 
label = <b>User-defined parameters</b> / label
 
k = 0., 0.0, 0.0, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. / doublelist
 
i1 = 0 / int
 
i2 = 0 / int
 
i3 = 0 / int
 
i4 = 0 / int
 
i5 = 0 / int
 
s1 =  / string
 
s2 =  / string
 
s3 =  / string
 
b1 = false / bool
 
b2 = false / bool
 
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
 
/*
 
 *
 
 *  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>
 
@@ -1145,55 +1146,72 @@ void Main::print()
 
    double ch = (bbur.y - bbll.y);
 
    QPainter pp(printer);
 
    QRect vp=pp.viewport();
 
#ifdef QDEBUG
 
    qDebug() << "Paper width = " << vp.width() << " x " << vp.height() << endl;
 
#endif
 

	
 
    // Note that Cell is also translated...
 
    pp.translate(-bbur.x,-bbur.y);
 
    if (cw>ch) {
 
      pp.scale(vp.width()/(2*cw*Cell::Magnification()), vp.width()/(2*cw*Cell::Magnification()));
 
    } else {
 
      pp.scale(vp.height()/(2*ch*Cell::Magnification()), vp.height()/(2*ch*Cell::Magnification()));
 
    }
 
    canvas.render(&pp, QRectF(), QRectF(0.,0.,canvas.width(),canvas.height()));
 
  }
 
}
 

	
 

	
 
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();
 
  }
 
}
 

	
 

	
 
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)
 
{
 

	
 
  stopSimulation();
 
  if ( QMessageBox::question(
 
			     this,
 
			     tr("Restart simulation?"),
 
			     tr("Restart simulation.\n"
 
				"Are you sure?"),
 
			     QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::Yes ) {
 

	
 
    cerr << "Restarting simulation" << endl;
 
    //    extern Mesh mesh;
 
    mesh.Clear();
 
    Init();
 
    Plot();
 
    editor->FullRedraw();
 
  } 
 
  //startSimulation();
 
}
 

	
 

	
 
void Main::FitCanvasToWindow(void)
 
{
 
@@ -1345,54 +1363,54 @@ void Main::XMLReadSettings(xmlNode *sett
 
xmlNode *Main::XMLSettingsTree(void) 
 
{
 

	
 
  showcentersp = view->isItemChecked(com_id);
 
  showmeshp = view->isItemChecked(mesh_id);
 
  showbordercellp =  view->isItemChecked(border_id);
 
  shownodenumbersp =  view->isItemChecked(node_number_id);
 
  showcellnumbersp =  view->isItemChecked(cell_number_id);
 
  showcellsaxesp = view->isItemChecked( cell_axes_id );
 
  showcellstrainp = view->isItemChecked( cell_strain_id );
 
  movieframesp = view->isItemChecked(movie_frames_id);;
 
  showboundaryonlyp =  view->isItemChecked(only_boundary_id);
 
  showfluxesp = view->isItemChecked(fluxes_id);
 
  dynamicscellsp = options->isItemChecked(dyn_cells_id);
 
  showwallsp = view->isItemChecked( cell_walls_id);
 
  //showapoplastsp = view->isItemChecked( apoplasts_id);
 
  hidecellsp = view->isItemChecked( hide_cells_id);
 

	
 
  xmlNode *settings = MainBase::XMLSettingsTree();
 
  QTransform viewport(editor->transform());
 
  xmlAddChild(settings, XMLViewportTree(viewport));
 
  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 );
 
      mesh.CSVExportCellData(stream);
 
      mesh.CSVExportMeshData(stream);
 
      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
 
@@ -186,67 +186,70 @@ class Main : public Q3MainWindow, public
 
    options->setItemChecked(rotation_mode_id, false); 
 
    if (editor)
 
      disconnect(editor, SIGNAL(MousePressed()), this, SLOT(ExitRotationMode()));
 
    editor->setMouseTracking(false);
 
 
 
  }
 

	
 
  virtual void UserMessage(QString message, int timeout=0);
 
  void Refresh(void) { Plot(); }
 
  void PauseIfRunning(void);
 
  void ContIfRunning(void);
 
  virtual void XMLReadSettings(xmlNode *settings);
 

	
 
  private slots:
 
  void aboutQt();
 
  void newView();
 
  void EditParameters();
 
  void readStateXML();
 
  int readStateXML(const char *filename, bool geometry = true, bool pars=true, bool simtime = true);
 
  void readNextStateXML();
 
  void readPrevStateXML();
 
  void readFirstStateXML();
 
  void readLastStateXML();
 
  void exportCellData();
 
  void exportCellData(QString);
 
  void saveStateXML();
 
  void snapshot();
 
  void savePars();
 
  void readPars();
 
  void clear();
 
  void init();
 
  virtual void CutSAM() { MainBase::CutSAM(); Refresh();}
 

	
 
  void enlarge();
 
  void shrink();
 
  void zoomIn();
 
  void zoomOut();
 

	
 
  void CleanMesh();
 
  void CleanMeshChemicals(void);
 
  void CleanMeshTransporters(void);
 

	
 
  void RandomizeMesh();
 

	
 
  QString TimeStamp();
 

	
 
 signals:
 
  void SimulationDone(void);
 
  void ParsChanged(void);
 

	
 
 protected:
 
  Mesh &mesh;
 

	
 
 private:
 
  NodeSet *node_set;
 
  FigureEditor *editor;
 
  Q3PopupMenu* options;
 
  Q3PopupMenu *view;
 
  Q3PopupMenu *run;
 
  QMenu *modelmenu;
 
  Q3PopupMenu *helpmenu;
 

	
 
  QPrinter* printer;
 
  const QDir *working_dir;
 
  QString currentFile;
 
  //  toggle item states 
 
  int dbf_id; // options->Double Buffer
 
  int com_id; // view->Show centers
 
  int mesh_id; // view->Show mesh
 
  int node_number_id; // view->Show Node numbers
src/parameter.cpp
Show inline comments
 
/*
 
 *
 
 *  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.
 
 *
 
 */
 

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

	
 

	
 
#include "parameter.h"
 
#include <cstdio>
 
#include <cstring>
 
#include <cstdlib>
 
#include <cerrno>
 
#include <iostream>
 
#include <sstream>
 
#include "output.h"
 
#include "parse.h"
 
#include "xmlwrite.h"
 
#include "warning.h"
 
#include <QLocale>
 
#include <QDir>
 
#include <QStringList>
 

	
 
using namespace std;
 

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

	
 
Parameter::Parameter() {
 
  arrowcolor = strdup("white");
 
  arrowsize = 100;
 
  textcolor = strdup("red");
 
  cellnumsize = 1;
 
@@ -162,82 +165,86 @@ Parameter::Parameter() {
 
  k[5] = 0.;
 
  k[6] = 0.;
 
  k[7] = 0.;
 
  k[8] = 0.;
 
  k[9] = 0.;
 
  k[10] = 0.;
 
  k[11] = 0.;
 
  k[12] = 0.;
 
  k[13] = 0.;
 
  k[14] = 0.;
 
  i1 = 0;
 
  i2 = 0;
 
  i3 = 0;
 
  i4 = 0;
 
  i5 = 0;
 
  s1 = strdup("");
 
  s2 = strdup("");
 
  s3 = strdup("");
 
  b1 = false;
 
  b2 = false;
 
  b3 = false;
 
  b4 = false;
 
  dir1 = strdup(".");
 
  dir2 = strdup(".");
 
  export_interval = 100;
 
  export_fn_prefix = strdup("CELLDATA");
 
}
 

	
 
Parameter::~Parameter() {
 
    
 
  // destruct parameter object
 
  // free string parameter
 
  CleanUp();
 
}
 

	
 
void Parameter::CleanUp(void) {
 
  if (arrowcolor) 
 
    free(arrowcolor);
 
  if (textcolor) 
 
    free(textcolor);
 
  if (cell_outline_color) 
 
    free(cell_outline_color);
 
  if (D) 
 
    free(D);
 
  if (initval) 
 
    free(initval);
 
  if (datadir) 
 
    free(datadir);
 
  if (k) 
 
    free(k);
 
  if (s1) 
 
    free(s1);
 
  if (s2) 
 
    free(s2);
 
  if (s3) 
 
    free(s3);
 
  if (dir1) 
 
    free(dir1);
 
  if (dir2) 
 
    free(dir2);
 
  if (export_fn_prefix) 
 
     free(export_fn_prefix);
 

	
 
}
 

	
 
void Parameter::Read(const char *filename) {
 
    
 
  static bool ReadP=false;
 

	
 
  if (ReadP) {
 

	
 
    //throw "Run Time Error in parameter.cpp: Please Read parameter file only once!!";
 
    CleanUp();
 
	
 
  } else
 
    ReadP=true;
 

	
 
  FILE *fp=OpenReadFile(filename);
 

	
 

	
 
  arrowcolor = sgetpar(fp, "arrowcolor", "white", true);
 
  arrowsize = fgetpar(fp, "arrowsize", 100, true);
 
  textcolor = sgetpar(fp, "textcolor", "red", true);
 
  cellnumsize = igetpar(fp, "cellnumsize", 1, true);
 
  nodenumsize = igetpar(fp, "nodenumsize", 1, true);
 
  node_mag = fgetpar(fp, "node_mag", 1.0, true);
 
@@ -319,48 +326,50 @@ void Parameter::Read(const char *filenam
 
  rho0 = fgetpar(fp, "rho0", 0., true);
 
  rho1 = fgetpar(fp, "rho1", 0., true);
 
  c0 = fgetpar(fp, "c0", 0., true);
 
  gamma = fgetpar(fp, "gamma", 0., true);
 
  eps = fgetpar(fp, "eps", 0., true);
 
  k = dgetparlist(fp, "k", 15, true);
 
  i1 = igetpar(fp, "i1", 0, true);
 
  i2 = igetpar(fp, "i2", 0, true);
 
  i3 = igetpar(fp, "i3", 0, true);
 
  i4 = igetpar(fp, "i4", 0, true);
 
  i5 = igetpar(fp, "i5", 0, true);
 
  s1 = sgetpar(fp, "s1", "", true);
 
  s2 = sgetpar(fp, "s2", "", true);
 
  s3 = sgetpar(fp, "s3", "", true);
 
  b1 = bgetpar(fp, "b1", false, true);
 
  b2 = bgetpar(fp, "b2", false, true);
 
  b3 = bgetpar(fp, "b3", false, true);
 
  b4 = bgetpar(fp, "b4", false, true);
 
  dir1 = sgetpar(fp, "dir1", ".", true);
 
  if (strcmp(dir1, "."))
 
    MakeDir(dir1);
 
  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) {
 

	
 
  const char *true_str="true";
 
  const char *false_str="false";
 
  if (p)
 
    return true_str;
 
  else
 
    return false_str;
 
}
 

	
 
void Parameter::Write(ostream &os) const {
 

	
 

	
 
  if (arrowcolor) 
 
    os << " arrowcolor = " << arrowcolor << endl;
 
  os << " arrowsize = " << arrowsize << endl;
 

	
 
  if (textcolor) 
 
    os << " textcolor = " << textcolor << endl;
 
  os << " cellnumsize = " << cellnumsize << endl;
 
  os << " nodenumsize = " << nodenumsize << endl;
 
  os << " node_mag = " << node_mag << endl;
 
@@ -453,48 +462,52 @@ void Parameter::Write(ostream &os) const
 
  os << " i1 = " << i1 << endl;
 
  os << " i2 = " << i2 << endl;
 
  os << " i3 = " << i3 << endl;
 
  os << " i4 = " << i4 << endl;
 
  os << " i5 = " << i5 << endl;
 

	
 
  if (s1) 
 
    os << " s1 = " << s1 << endl;
 

	
 
  if (s2) 
 
    os << " s2 = " << s2 << endl;
 

	
 
  if (s3) 
 
    os << " s3 = " << s3 << endl;
 
  os << " b1 = " << sbool(b1) << endl;
 
  os << " b2 = " << sbool(b2) << endl;
 
  os << " b3 = " << sbool(b3) << endl;
 
  os << " b4 = " << sbool(b4) << endl;
 

	
 
  if (dir1) 
 
    os << " dir1 = " << dir1 << endl;
 

	
 
  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 {
 
  xmlNode *xmlparameter = xmlNewChild(root, NULL, BAD_CAST "parameter", NULL);
 
  {
 
    xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
    xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "arrowcolor" );
 
    ostringstream text;
 

	
 
    if (arrowcolor) 
 
      text << arrowcolor;
 
    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 "arrowsize" );
 
    ostringstream text;
 
    text << arrowsize;
 
    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 "textcolor" );
 
    ostringstream text;
 
@@ -1427,48 +1440,64 @@ void Parameter::XMLAdd(xmlNode *root) co
 
    xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
    xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "b4" );
 
    ostringstream text;
 
    text << sbool(b4);
 
    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 "dir1" );
 
    ostringstream text;
 

	
 
    if (dir1) 
 
      text << dir1;
 
    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 "dir2" );
 
    ostringstream text;
 

	
 
    if (dir2) 
 
      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);
 
  bool ok;
 
  if (!strcmp(namec, "arrowcolor")) {
 
    if (arrowcolor) { free(arrowcolor); }
 
    arrowcolor=strdup(valc);
 
  }
 
  if (!strcmp(namec, "arrowsize")) {
 
    arrowsize = standardlocale.toDouble(valc, &ok);
 
    if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'arrowsize' from XML file.",valc); }
 
  }
 
  if (!strcmp(namec, "textcolor")) {
 
    if (textcolor) { free(textcolor); }
 
    textcolor=strdup(valc);
 
  }
 
  if (!strcmp(namec, "cellnumsize")) {
 
    cellnumsize = standardlocale.toInt(valc, &ok);
 
    if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'cellnumsize' from XML file.",valc); }
 
  }
 
  if (!strcmp(namec, "nodenumsize")) {
 
    nodenumsize = standardlocale.toInt(valc, &ok);
 
    if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'nodenumsize' from XML file.",valc); }
 
  }
 
@@ -1805,48 +1834,56 @@ void Parameter::AssignValToPar(const cha
 
  if (!strcmp(namec, "s3")) {
 
    if (s3) { free(s3); }
 
    s3=strdup(valc);
 
  }
 
  if (!strcmp(namec, "b1")) {
 
    b1 = strtobool(valc);
 
  }
 
  if (!strcmp(namec, "b2")) {
 
    b2 = strtobool(valc);
 
  }
 
  if (!strcmp(namec, "b3")) {
 
    b3 = strtobool(valc);
 
  }
 
  if (!strcmp(namec, "b4")) {
 
    b4 = strtobool(valc);
 
  }
 
  if (!strcmp(namec, "dir1")) {
 
    if (dir1) { free(dir1); }
 
    dir1=strdup(valc);
 
  }
 
  if (!strcmp(namec, "dir2")) {
 
    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")) {
 
    int i=0;
 
    vector<double>::const_iterator v=valarray.begin();
 
    while (v!=valarray.end() && i <= 14 ) {
 
      D[i++]=*(v++);
 
    }
 
  }
 
  if (!strcmp(namec, "initval")) {
 
    int i=0;
 
    vector<double>::const_iterator v=valarray.begin();
 
    while (v!=valarray.end() && i <= 14 ) {
 
      initval[i++]=*(v++);
 
    }
 
  }
 
  if (!strcmp(namec, "k")) {
 
    int i=0;
 
    vector<double>::const_iterator v=valarray.begin();
 
    while (v!=valarray.end() && i <= 14 ) {
 
      k[i++]=*(v++);
 
    }
 
  }
 
}
src/parameter.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_H_
 
#define _PARAMETER_H_
 
#include "vector.h"
 
#include <vector>
 

	
 
#include <libxml/parser.h>
 
#include <libxml/tree.h>
 

	
 
 class Parameter {
 
		
 
 public: 
 
   Parameter();
 
   ~Parameter();
 
   void CleanUp(void);
 
   void Read(const char *filename);
 
   void Write(ostream &os) const;
 
   void XMLAdd(xmlNode *root) const;
 
   void XMLRead(xmlNode *root);
 
   void AssignValToPar(const char *namec, const char *valc);
 
   void AssignValArrayToPar(const char *namec, vector<double> valarray);
 
  char * arrowcolor;
 
  double arrowsize;
 
  char * textcolor;
 
  int cellnumsize;
 
@@ -118,34 +121,34 @@
 
  double f;
 
  double c;
 
  double mu;
 
  double nu;
 
  double rho0;
 
  double rho1;
 
  double c0;
 
  double gamma;
 
  double eps;
 
  double * k;
 
  int i1;
 
  int i2;
 
  int i3;
 
  int i4;
 
  int i5;
 
  char * s1;
 
  char * s2;
 
  char * s3;
 
  bool b1;
 
  bool b2;
 
  bool b3;
 
  bool b4;
 
  char * dir1;
 
  char * dir2;
 
  int export_interval;
 
  char * export_fn_prefix;
 
 private:
 
 };
 

	
 
 ostream &operator<<(ostream &os, Parameter &p);
 
 const char *sbool(const bool &p);
 

	
 

	
 
#endif
 

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

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

	
 
#include "pardialog.h"
 
#include "parameter.h"
 
#include <cstring>
 
#include <qdialog.h>
 
#include <qlabel.h>
 
#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;
 
  arrowcolor_edit = new QLineEdit( QString("%1").arg(par.arrowcolor), this, "arrowcolor_edit" );
 
  arrowsize_edit = new QLineEdit( QString("%1").arg(par.arrowsize), this, "arrowsize_edit" );
 
  textcolor_edit = new QLineEdit( QString("%1").arg(par.textcolor), this, "textcolor_edit" );
 
  cellnumsize_edit = new QLineEdit( QString("%1").arg(par.cellnumsize), this, "cellnumsize_edit" );
 
  nodenumsize_edit = new QLineEdit( QString("%1").arg(par.nodenumsize), this, "nodenumsize_edit" );
 
  node_mag_edit = new QLineEdit( QString("%1").arg(par.node_mag), this, "node_mag_edit" );
 
  outlinewidth_edit = new QLineEdit( QString("%1").arg(par.outlinewidth), this, "outlinewidth_edit" );
 
  cell_outline_color_edit = new QLineEdit( QString("%1").arg(par.cell_outline_color), this, "cell_outline_color_edit" );
 
  resize_stride_edit = new QLineEdit( QString("%1").arg(par.resize_stride), this, "resize_stride_edit" );
 
  T_edit = new QLineEdit( QString("%1").arg(par.T), this, "T_edit" );
 
  lambda_length_edit = new QLineEdit( QString("%1").arg(par.lambda_length), this, "lambda_length_edit" );
 
  lambda_celllength_edit = new QLineEdit( QString("%1").arg(par.lambda_celllength), this, "lambda_celllength_edit" );
 
@@ -114,54 +116,56 @@ ParameterDialog::ParameterDialog(QWidget
 
  mu_edit = new QLineEdit( QString("%1").arg(par.mu), this, "mu_edit" );
 
  nu_edit = new QLineEdit( QString("%1").arg(par.nu), this, "nu_edit" );
 
  rho0_edit = new QLineEdit( QString("%1").arg(par.rho0), this, "rho0_edit" );
 
  rho1_edit = new QLineEdit( QString("%1").arg(par.rho1), this, "rho1_edit" );
 
  c0_edit = new QLineEdit( QString("%1").arg(par.c0), this, "c0_edit" );
 
  gamma_edit = new QLineEdit( QString("%1").arg(par.gamma), this, "gamma_edit" );
 
  eps_edit = new QLineEdit( QString("%1").arg(par.eps), this, "eps_edit" );
 
  QString k_string("%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15");
 
  k_string = k_string.arg(par.k[0]).arg(par.k[1]).arg(par.k[2]).arg(par.k[3]).arg(par.k[4]).arg(par.k[5]).arg(par.k[6]).arg(par.k[7]).arg(par.k[8]).arg(par.k[9]).arg(par.k[10]).arg(par.k[11]).arg(par.k[12]).arg(par.k[13]).arg(par.k[14]);
 
  k_edit = new QLineEdit( k_string, this, "k_edit" );
 
  i1_edit = new QLineEdit( QString("%1").arg(par.i1), this, "i1_edit" );
 
  i2_edit = new QLineEdit( QString("%1").arg(par.i2), this, "i2_edit" );
 
  i3_edit = new QLineEdit( QString("%1").arg(par.i3), this, "i3_edit" );
 
  i4_edit = new QLineEdit( QString("%1").arg(par.i4), this, "i4_edit" );
 
  i5_edit = new QLineEdit( QString("%1").arg(par.i5), this, "i5_edit" );
 
  s1_edit = new QLineEdit( QString("%1").arg(par.s1), this, "s1_edit" );
 
  s2_edit = new QLineEdit( QString("%1").arg(par.s2), this, "s2_edit" );
 
  s3_edit = new QLineEdit( QString("%1").arg(par.s3), this, "s3_edit" );
 
  b1_edit = new QLineEdit( QString("%1").arg(sbool(par.b1)), this, "b1_edit" );
 
  b2_edit = new QLineEdit( QString("%1").arg(sbool(par.b2)), this, "b2_edit" );
 
  b3_edit = new QLineEdit( QString("%1").arg(sbool(par.b3)), this, "b3_edit" );
 
  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 );
 
  grid->addWidget( arrowcolor_edit, 4, 0+1  );
 
  grid->addWidget( new QLabel( "arrowsize", this ),5, 0 );
 
  grid->addWidget( arrowsize_edit, 5, 0+1  );
 
  grid->addWidget( new QLabel( "textcolor", this ),6, 0 );
 
  grid->addWidget( textcolor_edit, 6, 0+1  );
 
  grid->addWidget( new QLabel( "cellnumsize", this ),7, 0 );
 
  grid->addWidget( cellnumsize_edit, 7, 0+1  );
 
  grid->addWidget( new QLabel( "nodenumsize", this ),8, 0 );
 
  grid->addWidget( nodenumsize_edit, 8, 0+1  );
 
  grid->addWidget( new QLabel( "node_mag", this ),9, 0 );
 
  grid->addWidget( node_mag_edit, 9, 0+1  );
 
  grid->addWidget( new QLabel( "outlinewidth", this ),10, 0 );
 
  grid->addWidget( outlinewidth_edit, 10, 0+1  );
 
  grid->addWidget( new QLabel( "cell_outline_color", this ),11, 0 );
 
  grid->addWidget( cell_outline_color_edit, 11, 0+1  );
 
  grid->addWidget( new QLabel( "resize_stride", this ),12, 0 );
 
  grid->addWidget( resize_stride_edit, 12, 0+1  );
 
  grid->addWidget( new QLabel( "", this), 13, 0, 1, 2 );
 
  grid->addWidget( new QLabel( " <b>Cell mechanics</b>", this), 14, 0, 1, 2 );
 
  grid->addWidget( new QLabel( "T", this ),15, 0 );
 
  grid->addWidget( T_edit, 15, 0+1  );
 
@@ -328,48 +332,52 @@ ParameterDialog::ParameterDialog(QWidget
 
  grid->addWidget( new QLabel( "i3", this ),19, 6 );
 
  grid->addWidget( i3_edit, 19, 6+1  );
 
  grid->addWidget( new QLabel( "i4", this ),20, 6 );
 
  grid->addWidget( i4_edit, 20, 6+1  );
 
  grid->addWidget( new QLabel( "i5", this ),21, 6 );
 
  grid->addWidget( i5_edit, 21, 6+1  );
 
  grid->addWidget( new QLabel( "s1", this ),22, 6 );
 
  grid->addWidget( s1_edit, 22, 6+1  );
 
  grid->addWidget( new QLabel( "s2", this ),23, 6 );
 
  grid->addWidget( s2_edit, 23, 6+1  );
 
  grid->addWidget( new QLabel( "s3", this ),24, 6 );
 
  grid->addWidget( s3_edit, 24, 6+1  );
 
  grid->addWidget( new QLabel( "b1", this ),25, 6 );
 
  grid->addWidget( b1_edit, 25, 6+1  );
 
  grid->addWidget( new QLabel( "b2", this ),26, 6 );
 
  grid->addWidget( b2_edit, 26, 6+1  );
 
  grid->addWidget( new QLabel( "b3", this ),27, 6 );
 
  grid->addWidget( b3_edit, 27, 6+1  );
 
  grid->addWidget( new QLabel( "b4", this ),28, 6 );
 
  grid->addWidget( b4_edit, 28, 6+1  );
 
  grid->addWidget( new QLabel( "dir1", this ),29, 6 );
 
  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() ) );
 
  QPushButton *pb2 = new QPushButton( "&Close", this );
 
  grid->addWidget(pb2,31, 6+1 );
 
  connect( pb2, SIGNAL( clicked() ), this, SLOT( close() ) );
 
  QPushButton *pb3 = new QPushButton( "&Reset", this );
 
  grid->addWidget(pb3, 31, 6+2 );
 
  connect( pb3, SIGNAL( clicked() ), this, SLOT( Reset() ) );
 
  show();
 
};
 

	
 
ParameterDialog::~ParameterDialog(void) {
 
  delete arrowcolor_edit;
 
  delete arrowsize_edit;
 
  delete textcolor_edit;
 
  delete cellnumsize_edit;
 
  delete nodenumsize_edit;
 
  delete node_mag_edit;
 
  delete outlinewidth_edit;
 
  delete cell_outline_color_edit;
 
  delete resize_stride_edit;
 
  delete T_edit;
 
  delete lambda_length_edit;
 
@@ -439,48 +447,50 @@ ParameterDialog::~ParameterDialog(void) 
 
  delete f_edit;
 
  delete c_edit;
 
  delete mu_edit;
 
  delete nu_edit;
 
  delete rho0_edit;
 
  delete rho1_edit;
 
  delete c0_edit;
 
  delete gamma_edit;
 
  delete eps_edit;
 
  delete k_edit;
 
  delete i1_edit;
 
  delete i2_edit;
 
  delete i3_edit;
 
  delete i4_edit;
 
  delete i5_edit;
 
  delete s1_edit;
 
  delete s2_edit;
 
  delete s3_edit;
 
  delete b1_edit;
 
  delete b2_edit;
 
  delete b3_edit;
 
  delete b4_edit;
 
  delete dir1_edit;
 
  delete dir2_edit;
 
delete export_interval_edit;
 
delete export_fn_prefix_edit;
 
}
 

	
 
void ParameterDialog::write(void) {
 
    
 
  extern Parameter par;
 
  QString tmpval;
 
  par.arrowcolor = strdup((const char *)arrowcolor_edit->text());
 
  par.arrowsize = arrowsize_edit->text().toDouble();
 
  par.textcolor = strdup((const char *)textcolor_edit->text());
 
  par.cellnumsize = cellnumsize_edit->text().toInt();
 
  par.nodenumsize = nodenumsize_edit->text().toInt();
 
  par.node_mag = node_mag_edit->text().toDouble();
 
  par.outlinewidth = outlinewidth_edit->text().toDouble();
 
  par.cell_outline_color = strdup((const char *)cell_outline_color_edit->text());
 
  par.resize_stride = resize_stride_edit->text().toInt();
 
  par.T = T_edit->text().toDouble();
 
  par.lambda_length = lambda_length_edit->text().toDouble();
 
  par.lambda_celllength = lambda_celllength_edit->text().toDouble();
 
  par.target_length = target_length_edit->text().toDouble();
 
  par.cell_expansion_rate = cell_expansion_rate_edit->text().toDouble();
 
  par.cell_div_expansion_rate = cell_div_expansion_rate_edit->text().toDouble();
 
  tmpval = auxin_dependent_growth_edit->text().stripWhiteSpace();
 
  if (tmpval == "true" || tmpval == "yes" ) par.auxin_dependent_growth = true;
 
  else if (tmpval == "false" || tmpval == "no") par.auxin_dependent_growth = false;
 
@@ -672,48 +682,50 @@ void ParameterDialog::write(void) {
 
  }
 
  tmpval = b2_edit->text().stripWhiteSpace();
 
  if (tmpval == "true" || tmpval == "yes" ) par.b2 = true;
 
  else if (tmpval == "false" || tmpval == "no") par.b2 = false;
 
  else {
 
    if (QMessageBox::question(this, "Syntax error", tr("Value %1 of parameter %2 is not recognized as Boolean.\nDo you mean TRUE or FALSE?").arg(tmpval).arg("b2"),"True","False", QString::null, 0, 1)==0) par.b2=true;
 
    else par.b2=false;
 
  }
 
  tmpval = b3_edit->text().stripWhiteSpace();
 
  if (tmpval == "true" || tmpval == "yes" ) par.b3 = true;
 
  else if (tmpval == "false" || tmpval == "no") par.b3 = false;
 
  else {
 
    if (QMessageBox::question(this, "Syntax error", tr("Value %1 of parameter %2 is not recognized as Boolean.\nDo you mean TRUE or FALSE?").arg(tmpval).arg("b3"),"True","False", QString::null, 0, 1)==0) par.b3=true;
 
    else par.b3=false;
 
  }
 
  tmpval = b4_edit->text().stripWhiteSpace();
 
  if (tmpval == "true" || tmpval == "yes" ) par.b4 = true;
 
  else if (tmpval == "false" || tmpval == "no") par.b4 = false;
 
  else {
 
    if (QMessageBox::question(this, "Syntax error", tr("Value %1 of parameter %2 is not recognized as Boolean.\nDo you mean TRUE or FALSE?").arg(tmpval).arg("b4"),"True","False", QString::null, 0, 1)==0) par.b4=true;
 
    else par.b4=false;
 
  }
 
  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();
 

	
 
}
 
void ParameterDialog::Reset(void) {
 
  extern Parameter par;
 
  arrowcolor_edit->setText( QString("%1").arg(par.arrowcolor) );
 
  arrowsize_edit->setText( QString("%1").arg(par.arrowsize) );
 
  textcolor_edit->setText( QString("%1").arg(par.textcolor) );
 
  cellnumsize_edit->setText( QString("%1").arg(par.cellnumsize) );
 
  nodenumsize_edit->setText( QString("%1").arg(par.nodenumsize) );
 
  node_mag_edit->setText( QString("%1").arg(par.node_mag) );
 
  outlinewidth_edit->setText( QString("%1").arg(par.outlinewidth) );
 
  cell_outline_color_edit->setText( QString("%1").arg(par.cell_outline_color) );
 
  resize_stride_edit->setText( QString("%1").arg(par.resize_stride) );
 
  T_edit->setText( QString("%1").arg(par.T) );
 
  lambda_length_edit->setText( QString("%1").arg(par.lambda_length) );
 
  lambda_celllength_edit->setText( QString("%1").arg(par.lambda_celllength) );
 
  target_length_edit->setText( QString("%1").arg(par.target_length) );
 
  cell_expansion_rate_edit->setText( QString("%1").arg(par.cell_expansion_rate) );
 
  cell_div_expansion_rate_edit->setText( QString("%1").arg(par.cell_div_expansion_rate) );
 
  auxin_dependent_growth_edit->setText( QString("%1").arg(sbool(par.auxin_dependent_growth)));
 
  ode_accuracy_edit->setText( QString("%1").arg(par.ode_accuracy) );
 
  mc_stepsize_edit->setText( QString("%1").arg(par.mc_stepsize) );
 
  mc_cell_stepsize_edit->setText( QString("%1").arg(par.mc_cell_stepsize) );
 
@@ -781,27 +793,29 @@ void ParameterDialog::Reset(void) {
 
  mu_edit->setText( QString("%1").arg(par.mu) );
 
  nu_edit->setText( QString("%1").arg(par.nu) );
 
  rho0_edit->setText( QString("%1").arg(par.rho0) );
 
  rho1_edit->setText( QString("%1").arg(par.rho1) );
 
  c0_edit->setText( QString("%1").arg(par.c0) );
 
  gamma_edit->setText( QString("%1").arg(par.gamma) );
 
  eps_edit->setText( QString("%1").arg(par.eps) );
 
  QString k_string("%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15");
 
  k_string = k_string.arg(par.k[0]).arg(par.k[1]).arg(par.k[2]).arg(par.k[3]).arg(par.k[4]).arg(par.k[5]).arg(par.k[6]).arg(par.k[7]).arg(par.k[8]).arg(par.k[9]).arg(par.k[10]).arg(par.k[11]).arg(par.k[12]).arg(par.k[13]).arg(par.k[14]);
 
  k_edit->setText( k_string );
 
  i1_edit->setText( QString("%1").arg(par.i1) );
 
  i2_edit->setText( QString("%1").arg(par.i2) );
 
  i3_edit->setText( QString("%1").arg(par.i3) );
 
  i4_edit->setText( QString("%1").arg(par.i4) );
 
  i5_edit->setText( QString("%1").arg(par.i5) );
 
  s1_edit->setText( QString("%1").arg(par.s1) );
 
  s2_edit->setText( QString("%1").arg(par.s2) );
 
  s3_edit->setText( QString("%1").arg(par.s3) );
 
  b1_edit->setText( QString("%1").arg(sbool(par.b1)));
 
  b2_edit->setText( QString("%1").arg(sbool(par.b2)));
 
  b3_edit->setText( QString("%1").arg(sbool(par.b3)));
 
  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>
 
#include <qspinbox.h>
 
#include <qlineedit.h>
 
#include <qlayout.h>
 
#include <qpushbutton.h>
 
#include <iostream>
 

	
 
class ParameterDialog : public QDialog {
 
    Q_OBJECT
 
	
 
      public:
 
	ParameterDialog(QWidget *parent=0, const char *name = 0, Qt::WindowFlags f = 0);
 
    virtual ~ParameterDialog(void);
 
    public slots:
 
    void Reset(void);
 

	
 
    private slots:
 
    void write(void);
 

	
 
  private:
 
  QLineEdit *arrowcolor_edit;
 
  QLineEdit *arrowsize_edit;
 
@@ -97,26 +123,29 @@ class ParameterDialog : public QDialog {
 
  QLineEdit *f_edit;
 
  QLineEdit *c_edit;
 
  QLineEdit *mu_edit;
 
  QLineEdit *nu_edit;
 
  QLineEdit *rho0_edit;
 
  QLineEdit *rho1_edit;
 
  QLineEdit *c0_edit;
 
  QLineEdit *gamma_edit;
 
  QLineEdit *eps_edit;
 
  QLineEdit *k_edit;
 
  QLineEdit *i1_edit;
 
  QLineEdit *i2_edit;
 
  QLineEdit *i3_edit;
 
  QLineEdit *i4_edit;
 
  QLineEdit *i5_edit;
 
  QLineEdit *s1_edit;
 
  QLineEdit *s2_edit;
 
  QLineEdit *s3_edit;
 
  QLineEdit *b1_edit;
 
  QLineEdit *b2_edit;
 
  QLineEdit *b3_edit;
 
  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.
 

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

	
 
	* make_pardialog_source.pl: Reformatted. If datadir is relative append it to the user's home directory.
 
	* make_parameter_source.pl: Ditto.
 
	* make_xmlwritecode.pl: Ditto.
 

	
src/perl/make_parameter_source.pl
Show inline comments
 
@@ -67,68 +67,91 @@ while (<parfile>) {
 
    $value_type=$line[1];
 

	
 
    @typel=split(/ \/ /,$value_type);
 
    $value[$i] = $typel[0];
 
    $type[$i] = $typel[1];
 
    
 
#get rid of spaces
 
    $param[$i] =~ s/ //g;
 
    $value[$i] =~ s/ //g;
 
    $type[$i] =~ s/ //g;
 
    $type[$i] =~s/\n//g;
 
    $convtype[$i]=$typetrans{$type[$i]};
 

	
 
    if ($convtype[$i] eq "char *") {
 
	$value[$i] = "\"$value[$i]\"";
 
    }
 
    #print cppfile "param = $param, value = $value, type = $type\n";
 

	
 
    $i++;
 
}
 

	
 
$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.
 

	
 
#include "parameter.h"
 
#include <cstdio>
 
#include <cstring>
 
#include <cstdlib>
 
#include <cerrno>
 
#include <iostream>
 
#include <sstream>
 
#include "output.h"
 
#include "parse.h"
 
#include "xmlwrite.h"
 
#include "warning.h"
 
#include <QLocale>
 
#include <QDir>
 
#include <QStringList>
 

	
 
using namespace std;
 

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

	
 
Parameter::Parameter() {
 
END_HEADER
 

	
 
for ($i=0;$i<$lines;$i++) {
 
    if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
 
	if ($convtype[$i] eq "char *") {
 
	    print cppfile "  $param[$i] = strdup($value[$i]);\n";
 
	    if ($param[$i] eq "datadir") {
 
		print cppfile "  datadir = AppendHomeDirIfPathRelative(datadir);\n";
 
	    }
 
	} else {
 
	    if ($convtype[$i] eq "double *") {
 
                #comma separated list expected
 
		@paramlist = split(/,/, $value[$i]);
 
		$length = $#paramlist+1;
 
		print cppfile "  $param[$i] = new double\[$length\];\n";
 
		for ($j=0;$j<=$#paramlist;$j++) {
 
		    print cppfile "  $param[$i]\[$j\] = $paramlist[$j];\n";
 
		}
 
	    } else {
 
		print cppfile "  $param[$i] = $value[$i];\n";
 
	    }
 
	}
 
    }
 
@@ -352,50 +375,73 @@ for ($i=0;$i<$lines;$i++) {
 
	print cppfile "  while (v!=valarray.end() && i <= $#paramlist ) {\n";
 
	print cppfile "     $param[$i]\[i++\]=*(v++);\n";
 
	print cppfile "  }\n";
 
	print cppfile "}\n";
 
    }
 
}
 

	
 
print cppfile "}\n";
 

	
 
print cppfile <<END_TRAILER;
 

	
 
ostream &operator<<(ostream &os, Parameter &p) {
 
    p.Write(os);
 
    return os;
 
}
 

	
 
END_TRAILER
 

	
 

	
 

	
 
# parameter.h
 

	
 
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_
 
#include "vector.h"
 
#include <vector>
 

	
 
#include <libxml/parser.h>
 
#include <libxml/tree.h>
 

	
 
 class Parameter {
 
		
 
 public: 
 
   Parameter();
 
   ~Parameter();
 
   void CleanUp(void);
 
   void Read(const char *filename);
 
   void Write(ostream &os) const;
 
   void XMLAdd(xmlNode *root) const;
 
   void XMLRead(xmlNode *root);
 
   void AssignValToPar(const char *namec, const char *valc);
 
   void AssignValArrayToPar(const char *namec, vector<double> valarray);
 
END_HEADER2
 

	
 
   for ($i=0;$i<$lines;$i++) {
src/perl/make_pardialog_source.pl
Show inline comments
 
@@ -67,56 +67,82 @@ while (<parfile>) {
 
    $value[$i] = $typel[0];
 
    $type[$i] = $typel[1];
 

	
 
    #get rid of spaces
 
    $type[$i] =~ s/ //g;
 
    $type[$i] =~s/\n//g;
 
    $convtype[$i]=$typetrans{$type[$i]};
 
    $param[$i] =~ s/ //g;
 
    if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
 
	#get rid of spaces
 
	$value[$i] =~ s/ //g;
 
    }
 
    if ($convtype[$i] eq "char *") {
 
	$value[$i] = "\"$value[$i]\"";
 
    }
 
    #print cppfile "param = $param, value = $value, type = $type\n";
 

	
 
    $i++;
 
}
 

	
 
$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.
 
// Do not edit. All edits will be discarded.
 

	
 
#include "$basename.h"
 
#include "parameter.h"
 
#include <cstring>
 
#include <qdialog.h>
 
#include <qlabel.h>
 
#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
 

	
 
for ($i=0;$i<$lines;$i++) {
 
    if ($convtype[$i] eq "label" || $convtype[$i] eq "title") {
 
	next;
 
    }
 
    if ($convtype[$i] eq "double *") {
 
	print cppfile  "  QString $param[$i]_string(\"";
 
	@paramlist = split(/,/,$value[$i]);
 
	for ($j=1;$j<=$#paramlist;$j++) {
 
	    print cppfile "%$j,";
 
	}
 
	print cppfile "%$j\");\n";
 
	print cppfile "  $param[$i]_string = $param[$i]_string";
 
	for ($j=0;$j<=$#paramlist;$j++) {
 
	    print cppfile ".arg(par.$param[$i]\[$j\])";
 
	}
 
	print cppfile ";\n";
 
	print cppfile "  $param[$i]_edit = new QLineEdit( $param[$i]_string, this, \"$param[$i]_edit\" );\n";
 
    } else {
 
	if ($convtype[$i] eq "bool") {
 
	    print cppfile "  $param[$i]_edit = new QLineEdit( QString(\"%1\").arg(sbool(par.$param[$i])), this, \"$param[$i]_edit\" );\n";
 
@@ -244,48 +270,74 @@ for ($i=0;$i<$lines;$i++) {
 
	    print cppfile "%$j,";
 
	}
 
	print cppfile "%$j\");\n";
 
	print cppfile "  $param[$i]_string = $param[$i]_string";
 
	for ($j=0;$j<=$#paramlist;$j++) {
 
	    print cppfile ".arg(par.$param[$i]\[$j\])";
 
	}
 
	print cppfile ";\n";
 
	print cppfile "  $param[$i]_edit->setText( $param[$i]_string );\n";
 
    } else {
 
	if ($convtype[$i] eq "bool") {
 
	    print cppfile "  $param[$i]_edit->setText( QString(\"%1\").arg(sbool(par.$param[$i])));\n";
 
	} else {
 
	    print cppfile "  $param[$i]_edit->setText( QString(\"%1\").arg(par.$param[$i]) );\n";
 
	}
 
    }
 
}
 

	
 
print cppfile "}\n\n";
 

	
 
# qparameter.h
 

	
 
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>
 
#include <qspinbox.h>
 
#include <qlineedit.h>
 
#include <qlayout.h>
 
#include <qpushbutton.h>
 
#include <iostream>
 

	
 
class ParameterDialog : public QDialog {
 
    Q_OBJECT
 
	
 
      public:
 
	ParameterDialog(QWidget *parent=0, const char *name = 0, Qt::WindowFlags f = 0);
 
    virtual ~ParameterDialog(void);
 
    public slots:
 
    void Reset(void);
 

	
 
    private slots:
 
    void write(void);
 

	
 
  private:
 
END_HEADER2
 

	
0 comments (0 inline, 0 general)