Changeset - 2accd83924da
[Not reviewed]
default
0 20 0
Roeland Merks - 15 years ago 2010-11-25 14:57:33
roeland.merks@cwi.nl
Some last fine-tuning
- File dialogs start from appropriate data directories
- XML files contain right values for datadir
- Reordered parameter dialog
- Added new "make perl" heading to the makefile
- Corrected segfault for batch mode

user: Roeland Merks <roeland.merks@cwi.nl>
branch 'default'
changed data/leaves/auxin_growth.xml
changed data/leaves/meinhardt_init.xml
changed data/leaves/tutorial1_init.xml
changed data/leaves/tutorial2_init.xml
changed data/leaves/tutorial3_init.xml
changed data/leaves/tutorial4_init.xml
changed data/leaves/tutorial5_init.xml
changed src/Makefile
changed src/VirtualLeaf.cpp
changed src/VirtualLeafpar.tmpl
changed src/canvas.cpp
changed src/canvas.h
changed src/mesh.cpp
changed src/mesh.h
changed src/modelcatalogue.cpp
changed src/modelcatalogue.h
changed src/parameter.cpp
changed src/parameter.h
changed src/pardialog.cpp
changed src/pardialog.h
18 files changed:
0 comments (0 inline, 0 general)
data/leaves/auxin_growth.xml
Show inline comments
 
binary diff not shown
data/leaves/meinhardt_init.xml
Show inline comments
 
binary diff not shown
data/leaves/tutorial1_init.xml
Show inline comments
 
binary diff not shown
data/leaves/tutorial2_init.xml
Show inline comments
 
binary diff not shown
data/leaves/tutorial3_init.xml
Show inline comments
 
binary diff not shown
data/leaves/tutorial4_init.xml
Show inline comments
 
binary diff not shown
data/leaves/tutorial5_init.xml
Show inline comments
 
binary diff not shown
src/Makefile
Show inline comments
 
@@ -13,38 +13,41 @@ ifeq ($(QMAKE),)
 
	QMAKE=qmake
 
endif
 

	
 
all: VirtualLeaf libplugin plugins tutorials
 

	
 
VirtualLeaf: Makefile.VirtualLeaf
 
	$(MAKE) -f Makefile.VirtualLeaf
 

	
 
Makefile.VirtualLeaf: VirtualLeaf.pro
 
	$(QMAKE) -o $@ $< 
 

	
 
libplugin: Makefile.libplugin
 
	$(MAKE) -f Makefile.libplugin
 

	
 
Makefile.libplugin: libplugin.pro
 
	$(QMAKE) -o $@ $< 
 

	
 
plugins:
 
	$(MAKE) -C build_models -f Makefile
 

	
 
tutorials:
 
	$(MAKE) -C build_models -f Makefile
 
	$(MAKE) -C TutorialCode -f Makefile
 

	
 
perl: Makefile.perl
 
	$(MAKE) -f Makefile.perl
 

	
 
clean:
 
	$(MAKE) -f Makefile.libplugin clean
 
	$(MAKE) -f Makefile.VirtualLeaf clean
 
	$(MAKE) -C build_models -f Makefile clean
 
	$(MAKE) -C TutorialCode -f Makefile clean
 
ifeq ($(MAKE),make)
 
	touch VirtualLeaf.pro
 
	touch libplugin.pro
 
else
 
	copy /b VirtualLeaf.pro +,,
 
	copy /b libplugin.pro +,,
 
endif
 

	
 
#finis
src/VirtualLeaf.cpp
Show inline comments
 
@@ -186,55 +186,60 @@ void MainBase::Plot(int resize_stride)
 
      fname.fill('0');
 
      fname.width(6);
 
      fname << count << ".png";
 
      // Write high-res PNG snapshot every plot step
 
      Save(fname.str().c_str(), "PNG", 1024, 768);
 
    }
 

	
 
    if (!(count%par.xml_storage_stride)) {
 
      stringstream fname;
 
      fname << par.datadir << "/leaf.";
 
      fname.fill('0');
 
      fname.width(6);
 
      fname << count << ".xml";
 
      // Write XML file every ten plot steps
 
      mesh.XMLSave(fname.str().c_str(), XMLSettingsTree());
 
    }
 
  }
 
}
 

	
 

	
 
INIT {
 

	
 
  //mesh.SetSimPlugin(plugin);
 
  if (leaffile) { 
 
    xmlNode *settings;
 
    mesh.XMLRead(leaffile, &settings);
 

	
 
    main_window->XMLReadSettings(settings);
 
    xmlFree(settings);
 
    main_window->UserMessage(QString("Ready. Time is %1").arg(mesh.getTimeHours().c_str()));
 

	
 
    if (qApp->type()==QApplication::Tty) {
 
      
 
      xmlNode *settings;
 
      mesh.XMLRead(leaffile, &settings);
 
      
 
      main_window->XMLReadSettings(settings);
 
      xmlFree(settings);
 
      main_window->UserMessage(QString("Ready. Time is %1").arg(mesh.getTimeHours().c_str()));
 
    } else {
 
      ((Main *)main_window)->readStateXML(leaffile);
 
    }
 
    
 
  } else {
 
    mesh.StandardInit();
 
  }
 
  
 
  Cell::SetMagnification(1);
 
  Cell::setOffset(0,0);
 
  
 
  FitLeafToCanvas();
 
  Plot();
 

	
 
}
 

	
 
TIMESTEP {
 

	
 
  static int i=0;
 
  static int t=0;
 
  static int ncells;
 

	
 
  if (!batch) {
 
    UserMessage(QString("Time: %1").arg(mesh.getTimeHours().c_str()),0);
 
  }
 

	
 
  ncells=mesh.NCells();
 

	
 
@@ -392,49 +397,49 @@ int main(int argc,char **argv) {
 
      main_window=new Main(canvas, mesh);
 
      if ( QApplication::desktop()->width() > ((Main *)main_window)->width() + 10
 
	   && QApplication::desktop()->height() > ((Main *)main_window)->height() +30 ) {
 

	
 
	((Main *)main_window)->show();
 
	((Main *)main_window)->resize( ((Main *)main_window)->sizeHint());
 
      } else {
 
        ((Main *)main_window)->showMaximized();
 
      }
 
      
 
      // show "About" window at start up
 
      ((Main *)main_window)->about();
 
    } else {
 
      main_window=new MainBase(canvas, mesh);
 
    }
 

	
 
    canvas.setSceneRect(QRectF());
 
    if (!batch) {
 
      QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) );
 
    }
 

	
 
    //    main_window->Init(leaffile);
 

	
 
    // Install model or read catalogue of models
 
    ModelCatalogue model_catalogue(&mesh, useGUI?(Main *)main_window:0,modelfile);
 
    ModelCatalogue model_catalogue(&mesh, main_window,modelfile);
 

	
 

	
 
    if (useGUI)
 
      model_catalogue.PopulateModelMenu();
 
    model_catalogue.InstallFirstModel();
 
    
 
    
 

	
 
    /*    Cell::SetMagnification(1);
 
    Cell::setOffset(0,0);
 

	
 
    main_window->FitLeafToCanvas();
 

	
 
    main_window->Plot();
 
    */
 
    if (batch) {
 
      double t=0.;
 
      do {
 
	t = main_window->TimeStep();
 
      } while (t < par.maxt);
 
    } else
 
      return app.exec();
 

	
 
  } catch (const char *message) {
src/VirtualLeafpar.tmpl
Show inline comments
 
title = Parameter values for The Virtual Leaf / title
 
label = <b>Visualization</b> / label
 
arrowcolor = white / string
 
arrowsize = 100 / double
 
textcolor = red / string
 
cellnumsize = 1 / int
 
nodenumsize = 1 / int
 
node_mag = 1.0 / double 
 
outlinewidth = 1.0 / double
 
cell_outline_color = forestgreen / string
 
resize_stride = 0 / int
 
label = / label
 
label = <b>Data Export</b> / label
 
export_interval = 0 / int
 
export_fn_prefix = cell. / string
 
storage_stride = 10 / int
 
xml_storage_stride = 500 / int
 
datadir = . / directory 
 
label = / label
 
label = <b>Cell mechanics</b> / label
 
T = 1.0 / double
 
lambda_length = 100. / double
 
yielding_threshold = 4. / double
 
lambda_celllength = 0. / double
 
target_length = 60. / double 
 
cell_expansion_rate = 1. / double
 
cell_div_expansion_rate = 0. / double
 
auxin_dependent_growth = true / bool
 
ode_accuracy = 1e-4 / double
 
mc_stepsize = 0.4 / double
 
mc_cell_stepsize = 0.2 / double
 
energy_threshold = 1000. / double
 
bend_lambda = 0. / double
 
alignment_lambda = 0. / double
 
rel_cell_div_threshold = 2. / double
 
rel_perimeter_stiffness = 2 / double
 
collapse_node_threshold = 0.05 / double
 
morphogen_div_threshold = 0.2 / double
 
morphogen_expansion_threshold = 0.01 / double
 
copy_wall = true / bool
 
label = / label
 
label = <b>Auxin transport and PIN1 dynamics</b> / label
 
source = 0. / double
 
@@ -59,71 +66,66 @@ aux1decay = 0.001 / double
 
aux1decaymeso = 0.1 / double
 
aux1transport = 0.036 / double
 
aux_cons = 0. / double
 
aux_breakdown = 0. / double
 
kaux1 = 1 / double
 
kap = 1 / double
 
leaf_tip_source = 0.001 / double
 
sam_efflux = 0.0001 / double
 
sam_auxin = 10. / double
 
# gf_prod = 1e-3 / double
 
# gf_decay = 1e-3 / double
 
sam_auxin_breakdown = 0 / double
 
#label = / label
 
#label = <b>miscellaneous</b> / label
 
van3prod = 0.002 / double
 
van3autokat = 0.1 / double
 
van3sat = 10 / double
 
k2van3 = 0.3 / double
 
#glvprod = 0.0 / double
 
#glvbreakdown = 0. / double
 
label = / label
 
label = <b>Integration parameters</b> / label
 
dt = 0.1 / double 
 
rd_dt = 1.0 / double
 
datadir = . / directory 
 
movie = false / bool
 
nit = 100000 / int
 
maxt = 1000. / double
 
storage_stride = 10 / int
 
xml_storage_stride = 500 / int
 
rseed = -1 / int
 
#label = / label
 
#label = <b>Parameters for new chemical</b> / label
 
#glvproduction = 0. / double
 
#glvdecay = 0. / double
 
#glvdiffthreshold = 0. / double
 
label = / label
 
label = <b>Meinhardt leaf venation model</b> / label
 
constituous_expansion_limit = 16 / int
 
vessel_inh_level = 1 / double
 
vessel_expansion_rate = 0.25 / double
 
d = 0. / double
 
e = 0. / double
 
f = 0. / double
 
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 = cell. / string
src/canvas.cpp
Show inline comments
 
@@ -624,116 +624,120 @@ void Main::newView()
 
  m->show();
 
  qApp->setMainWidget(0);
 
}
 

	
 

	
 
void Main::EditParameters()
 
{
 

	
 
  ParameterDialog *pardial = new ParameterDialog(this, "stridediag");
 

	
 
  // Make sure the values in the parameter dialog are updated after a file is read 
 
  // each method changing the parameters (reading XML or PAR files) should
 
  // emit this signal
 
  QObject::connect(   this, SIGNAL( ParsChanged() ), pardial, SLOT( Reset() ) );
 
}
 

	
 
void Main::savePars()
 
{
 

	
 
  stopSimulation();
 

	
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  fd->setFilter( "Parameter files (*.par)");
 
  fd->setDir(par.datadir);
 

	
 
  QString fileName;
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 
    ofstream parfile((const char *)fileName);
 
    par.Write(parfile);
 
  }
 

	
 
  startSimulation();
 
}
 

	
 
void Main::readPars()
 
{
 

	
 
  stopSimulation();
 

	
 
  Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE );
 
  fd->setMode( Q3FileDialog::ExistingFile );
 
  fd->setFilter( "Parameter files (*.par)");
 
  fd->setDir(par.datadir);
 

	
 
  QString fileName;
 
  if ( fd->exec() == QDialog::Accepted ) {
 
    fileName = fd->selectedFile();
 
    par.Read((const char *)fileName);
 
  }
 

	
 
  emit ParsChanged();
 
}
 

	
 

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

	
 
    }
 
  }
 
}
 

	
 

	
 

	
 
void Main::snapshot()
 
{
 

	
 

	
 
  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 *.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? -- Cell data export"),
 
			       tr("A file called %1 already exists."
 
				  " Do you want to overwrite it?").arg( fileName ),
 
@@ -889,62 +893,101 @@ void Main::readLastStateXML()
 
  }
 
}
 

	
 

	
 
void Main::readFirstStateXML()
 
{
 

	
 
  // 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 );
 

	
 

	
 
    next_file = xml_files.front();
 

	
 
    next_file = currentFile_path+"/"+next_file;
 

	
 
    readStateXML((const char*)next_file);
 
  }
 
}
 

	
 
QDir Main::GetLeafDir(void) {
 
   
 
  QDir LeafDir(QApplication::applicationDirPath()); 
 
  QStringList plugin_filters; // filter for plugins, i.e "*.dll", "*.dylib"
 
  
 
  
 
#if defined(Q_OS_WIN) 
 
  if (LeafDir.dirName().toLower() =="debug" 
 
      ||LeafDir.dirName().toLower() =="release") 
 
    LeafDir.cdUp(); 
 
  //plugin_filters << "*.dll";
 
#elif defined(Q_OS_MAC) 
 
  if (LeafDir.dirName() =="MacOS"){ 
 
    LeafDir.cdUp(); 
 
    LeafDir.cdUp(); 
 
    LeafDir.cdUp(); 
 
  }
 
  
 
#endif
 
  // for all OS-es. Move from "bin" directory to root application folder.
 
  if (LeafDir.dirName() == "bin") {
 
    LeafDir.cdUp();
 
  }
 

	
 
  LeafDir.cd("data/leaves");
 
  /* if (!LeafDir.cd("data/leaves")) {
 
    QString status_message = QString("No directory data/leaves");
 
    statusBar()->showMessage(status_message);
 
    
 
    return LeafDir;
 
  } 
 
  */
 
  return LeafDir;
 
      
 
}
 
 
 

	
 
void Main::readStateXML()
 
{
 

	
 
  //  extern Mesh mesh;
 

	
 
  stopSimulation();
 
#ifdef QDEBUG
 
  qDebug() << "Trying to open an OptionFileDialog" << endl;
 
#endif
 
  OptionFileDialog *fd = new OptionFileDialog( this, "read dialog", TRUE );
 
  fd->setMode( OptionFileDialog::ExistingFile );
 
  fd->setFilter( "LeafML files (*.xml)");
 
  if (working_dir) {
 
    fd->setDir(*working_dir);
 
  } else {
 
    fd->setDir(par.datadir);
 
  }
 
  QString fileName;
 
  if ( fd->exec() == QDialog::Accepted ) {
 

	
 
    fileName = fd->selectedFile();
 
    if (working_dir) {
 
      delete working_dir;
 
    }
 
    working_dir = fd->dir();
 

	
 
    if (readStateXML((const char *)fileName,fd->readGeometryP(), fd->readParametersP()) )
 
      return readStateXML(); // user can try again
 
  }
 
}
 

	
 

	
 
void Main::clear()
 
{
 
  editor->clear();
 
}
 

	
 
void Main::about()
 
{
 
  static QMessageBox* about = new QMessageBox
 
@@ -1374,70 +1417,69 @@ 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;
 
}
 

	
 

	
 
#define QDEBUG
 

	
 
void Main::exportCellData(QString fileName) {
 
  
 
#ifdef QDEBUG  
 
  qDebug() << "exportCellData fileName: " << fileName << endl;
 
#endif
 

	
 
  QFile file(fileName);
 
  if ( file.open( IO_WriteOnly ) ) {
 
    QTextStream stream( &file );
 
    mesh.CSVExportCellData(stream);
 
    mesh.CSVExportWallData(stream);
 
    mesh.CSVExportMeshData(stream);
 
    file.close();
 
  }
 
}
 

	
 

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

	
 
  fd->setDir(par.datadir); 
 
  stopSimulation();
 
  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 
src/canvas.h
Show inline comments
 
@@ -9,48 +9,49 @@
 
 *  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.
 
 *
 
 */
 

	
 
#ifndef _CANVAS_H_
 
#define _CANVAS_H_
 

	
 
#include <q3popupmenu.h>
 
#include <q3mainwindow.h>
 
#include <q3intdict.h>
 
#include <QGraphicsScene>
 
#include <QGraphicsView>
 
#include <QList>
 
#include <QDir>
 

	
 
#include <string>
 
#include <sstream>
 

	
 
//Added by qt3to4:
 
#include <QMouseEvent>
 
#include <vector>
 
#include "simitembase.h"
 
#include "mainbase.h"
 
#include "cellitem.h"
 
#include "infobar.h"
 

	
 
#include "nodeitem.h"
 
#include "cell.h"
 

	
 
#ifdef HAVE_QWT
 
#include "data_plot.h"
 
#endif
 

	
 
#include <libxml/xpath.h>
 
#include <libxml/xmlreader.h>
 

	
 
#if defined(Q_OS_MAC)
 
#define PREFIX "cmd"
 
@@ -141,87 +142,88 @@ class Main : public Q3MainWindow, public
 
  void about();
 
  void gpl();
 
  void TimeStepWrap();
 
  void togglePaused();
 
  void setFluxArrowSize(int size);
 
  void RestartSim(void);
 
  void toggleShowCellCenters(void);
 
  void toggleShowNodes(void);
 
  void toggleShowBorderCells(void);
 
  void toggleShowFluxes(void);
 
  void toggleNodeNumbers(void);
 
  void toggleCellNumbers(void);
 
  void toggleCellAxes(void);
 
  void toggleCellStrain(void);
 
  void toggleShowWalls(void);
 
  void toggleShowApoplasts(void);
 
  void toggleDynCells(void);
 
  void toggleMovieFrames(void);
 
  void toggleLeafBoundary(void);
 
  void toggleHideCells(void);
 
  void print();
 
  void startSimulation(void);
 
  void stopSimulation(void);
 
  void RefreshInfoBar(void);
 

	
 
  int readStateXML(const char *filename, bool geometry = true, bool pars=true, bool simtime = true);
 
  
 
  void EnterRotationMode(void)
 
  {
 

	
 
    UserMessage("Rotation mode. Click mouse to exit.");
 
    if (editor) {
 
      editor->rot_angle = 0. ; 
 

	
 
      // Exit rotation mode if mouse is clicked
 
      connect(editor, SIGNAL(MousePressed()), this, SLOT(ExitRotationMode()));
 
      
 
      editor->setMouseTracking(true);
 

	
 
    }
 

	
 
  }
 
  void ExitRotationMode(void)
 
  { 
 
    UserMessage("Exited rotation mode.",2000);
 

	
 
    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();
 
  QDir GetLeafDir(void);
 
  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();
src/mesh.cpp
Show inline comments
 
@@ -2044,38 +2044,74 @@ double Mesh::Compactness(double *res_com
 

	
 
// DataExport
 
void Mesh::CSVExportCellData(QTextStream &csv_stream) const {
 

	
 
  csv_stream << "\"Cell Index\",\"Center of mass (x)\",\"Center of mass (y)\",\"Cell area\",\"Cell length\"";
 
  
 
  for (int c=0;c<Cell::NChem(); c++) {
 
    csv_stream << ",\"Chemical " << c << "\"";
 
  }
 
  csv_stream << endl;
 
  for (vector<Cell *>::const_iterator i=cells.begin();
 
       i!=cells.end();
 
       i++) {
 
    Vector centroid = (*i)->Centroid();
 
    csv_stream << (*i)->Index() << ", "
 
	       << centroid.x << ", "
 
	       << centroid.y << ", " 
 
	       <<  (*i)->Area() << ", "
 
	       <<(*i)->Length();
 
    for (int c=0;c<Cell::NChem(); c++) {
 
      csv_stream << ", " << (*i)->Chemical(c);
 
    }
 
    csv_stream << endl;
 
  }
 

	
 
  
 
}
 

	
 

	
 
// DataExport
 
void Mesh::CSVExportWallData(QTextStream &csv_stream) const {
 

	
 
  csv_stream << "\"Wall Index\",\"Cell A\",\"Cell B\",\"Length\"";
 
  
 
  for (int c=0;c<Cell::NChem(); c++) {
 
    csv_stream << ",\"Transporter A:" << c << "\"";
 
  }
 
  for (int c=0;c<Cell::NChem(); c++) {
 
    csv_stream << ",\"Transporter B:" << c << "\"";
 
  }
 
  csv_stream << endl;
 
  for (list<Wall *>::const_iterator i=walls.begin();
 
       i!=walls.end();
 
       i++) {
 
    csv_stream << (*i)->Index() << ","
 
	       << (*i)->C1()->Index() << ","
 
	       << (*i)->C2()->Index() << ","
 
	       << (*i)->Length();
 
	      
 
    for (int c=0;c<Cell::NChem(); c++) {
 
      csv_stream << "," << (*i)->Transporters1(c);
 
    }
 
    for (int c=0;c<Cell::NChem(); c++) {
 
      csv_stream << "," << (*i)->Transporters2(c);
 
    }
 

	
 
    csv_stream << endl;
 
  }
 

	
 
  
 
}
 

	
 

	
 
void Mesh::CSVExportMeshData(QTextStream &csv_stream) { 
 
  
 
  csv_stream << "\"Morph area\",\"Number of cells\",\"Number of nodes\",\"Compactness\",\"Hull area\",\"Morph circumference\",\"Hull circumference\"" << endl;
 
  
 
  double res_compactness, res_area, res_cell_area, hull_circumference;
 
  Compactness(&res_compactness, &res_area, &res_cell_area, &hull_circumference);
 
  double morph_circumference = boundary_polygon->ExactCircumference();
 
  csv_stream << Area() << ", " << NCells() << ", " << NNodes() << ", " << res_compactness << ", " << res_area << ", " << morph_circumference << ", " << hull_circumference << endl;
 
  
 
}
 
/* finis */
src/mesh.h
Show inline comments
 
@@ -367,48 +367,49 @@ class Mesh {
 

	
 
  void DeleteLooseWalls(void);
 
  void FitLeafToCanvas(double width, double height);
 
  void AddNodeSet(NodeSet *node_set) {
 
    node_sets.push_back(node_set);
 
  }
 

	
 
  void CleanChemicals(const vector<double> &clean_chem);
 
  void CleanTransporters(const vector<double> &clean_transporters);
 
  void RandomizeChemicals(const vector<double> &max_chem, const vector<double> &max_transporters);
 
  inline double getTime(void) const { return time; }
 
  string getTimeHours(void) const; 
 
  inline void setTime(double t) { time = t; }
 
  double CalcProtCellsWalls(int ch) const;  
 
  void SettoInitVals(void);
 
  QVector<qreal> VertexAngles(void);
 
  QVector< QPair<qreal,int> > VertexAnglesValues(void);
 
  void SetSimPlugin(SimPluginInterface *new_plugin) {
 
    plugin=new_plugin;
 
  }
 
  QString ModelID(void) { return plugin?plugin->ModelID():QString("undefined"); }
 
  void StandardInit(void);	
 
  double Compactness(double *res_compactness=0, double *res_area=0, double *res_cell_area=0, double *hull_circumference=0);
 
  void CSVExportCellData(QTextStream &csv_stream) const;
 
  void CSVExportWallData(QTextStream &csv_stream) const;
 
  void CSVExportMeshData(QTextStream &csv_stream);
 
  
 
  Node* findNextBoundaryNode(Node*);
 

	
 
 private:
 

	
 
  // Data members
 
  vector<Cell *> cells;
 
  vector<Node *> nodes;
 
  list<Wall *> walls; // we need to erase elements from this container frequently, hence a list.
 
 public:
 
  vector<NodeSet *> node_sets;
 
 private:
 
  vector<Node *> shuffled_nodes;
 
  vector<Cell *> shuffled_cells;
 
  unique_queue<Edge> node_insertion_queue;
 
  BoundaryPolygon *boundary_polygon;
 
  double time;
 
  SimPluginInterface *plugin;
 

	
 
  // Private member functions
 
  void AddNodeToCell(Cell *c, Node *n, Node *nb1 , Node *nb2);
 
  void AddNodeToCellAtIndex(Cell *c, Node *n, Node *nb1 , Node *nb2, list<Node *>::iterator ins_pos);
 
  void InsertNode(Edge &e);
src/modelcatalogue.cpp
Show inline comments
 
@@ -4,49 +4,49 @@
 
 *
 
 *  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 <string>
 
#include "modelcatalogue.h"
 
#include <QVariant>
 

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

	
 
ModelCatalogue::ModelCatalogue(Mesh *_mesh, Main *_mainwin, const char *model=0) {
 
ModelCatalogue::ModelCatalogue(Mesh *_mesh, MainBase *_mainwin, const char *model=0) {
 
  mesh = _mesh;
 
  mainwin = _mainwin;
 
  if (model) {
 
    cerr << "Loading model: " << model << endl;
 
    LoadPlugin(model);
 
  } else {
 
    cerr << "Loading all models." << endl;
 
    LoadPlugins();
 
  }
 
}
 

	
 
void ModelCatalogue::LoadPlugins() {
 

	
 
  QDir pluginDir(QApplication::applicationDirPath()); 
 
  QStringList plugin_filters; // filter for plugins, i.e "*.dll", "*.dylib"
 
#if defined(Q_OS_WIN) 
 
  if (pluginDir.dirName().toLower() =="debug" 
 
      ||pluginDir.dirName().toLower() =="release") 
 
    pluginDir.cdUp(); 
 
  plugin_filters << "*.dll";
 
#elif defined(Q_OS_MAC) 
 
  if (pluginDir.dirName() =="MacOS"){ 
 
    pluginDir.cdUp(); 
 
    pluginDir.cdUp(); 
 
@@ -105,80 +105,83 @@ void ModelCatalogue::LoadPlugin(const ch
 
  }
 

	
 
  QStringList modelnames=pluginDir.entryList(QDir::Files);
 
  if (modelnames.empty()) {
 
    MyWarning::error("Model %s not found - hint: do not include path in filename.",model);
 
  }
 
  foreach (QString fileName, modelnames){ 
 
    QPluginLoader loader(pluginDir.absoluteFilePath(fileName)); 
 

	
 
    if (SimPluginInterface *plugin = 
 
	qobject_cast<SimPluginInterface *>(loader.instance())) {
 
      models.append(plugin); 
 
      //MyWarning::warning("Successfully loaded model %s",fileName.toStdString().c_str());
 
    } else {
 
      MyWarning::warning("Could not load plugin %s",fileName.toStdString().c_str());
 
    }
 
  }
 
}
 

	
 
void ModelCatalogue::InstallFirstModel() {
 
  InstallModel(models[0]);
 
}
 
void ModelCatalogue::PopulateModelMenu() {
 
  foreach (SimPluginInterface *model, models) {
 
    QAction *modelaction = new QAction(model->ModelID(), mainwin); 
 
    QAction *modelaction = new QAction(model->ModelID(), (Main *)mainwin); 
 
    QVariant data;
 
    data.setValue(model);
 
    modelaction->setData(data);
 
    mainwin->modelmenu->addAction(modelaction);
 
    ((Main *)mainwin)->modelmenu->addAction(modelaction);
 

	
 
  }
 
  connect(mainwin->modelmenu, SIGNAL(triggered(QAction *)), this, SLOT(InstallModel(QAction *)) );
 
  connect(((Main *)mainwin)->modelmenu, SIGNAL(triggered(QAction *)), this, SLOT(InstallModel(QAction *)) );
 
}	
 

	
 
void ModelCatalogue::InstallModel(QAction *modelaction) {
 
  QVariant data = modelaction->data();
 
  SimPluginInterface *model = data.value<SimPluginInterface *>();
 
  cerr << "You chose model " << model->ModelID().toStdString() << "!\n";
 
  mesh->Clean();
 
  InstallModel(model);
 
}
 

	
 
void ModelCatalogue::InstallModel(SimPluginInterface *plugin) {
 

	
 
  // make sure both main and plugin use the same static datamembers (ncells, nchems...)
 
  mesh->Clean();
 
  plugin->SetCellsStaticDatamembers(CellBase::GetStaticDataMemberPointer());
 

	
 
  mesh->SetSimPlugin(plugin);
 
 
 

	
 
  Cell::SetNChem(plugin->NChem());
 
  plugin->SetParameters(&par);
 
  
 
  if (mainwin) {
 
    mainwin->RefreshInfoBar();
 
    
 
    if (!qApp->type()==QApplication::Tty)  // only do this if we are running a GUI
 
      ((Main *)mainwin)->RefreshInfoBar();
 
    
 
    if (plugin->DefaultLeafML().isEmpty()) {
 
      mainwin->Init(0);
 
    } else {
 
      // locate LeafML file
 
      
 
      QDir pluginDir(QApplication::applicationDirPath()); 
 
      QStringList plugin_filters; // filter for plugins, i.e "*.dll", "*.dylib"
 
      
 
      
 
#if defined(Q_OS_WIN) 
 
      if (pluginDir.dirName().toLower() =="debug" 
 
	  ||pluginDir.dirName().toLower() =="release") 
 
	pluginDir.cdUp(); 
 
      //plugin_filters << "*.dll";
 
#elif defined(Q_OS_MAC) 
 
      if (pluginDir.dirName() =="MacOS"){ 
 
	pluginDir.cdUp(); 
 
	pluginDir.cdUp(); 
 
	pluginDir.cdUp(); 
 
      }
 
     
 
#endif
 
      // for all OS-es. Move from "bin" directory to root application folder.
 
      if (pluginDir.dirName() == "bin") {
src/modelcatalogue.h
Show inline comments
 
@@ -20,43 +20,43 @@
 
 *  Copyright 2010 Roeland Merks.
 
 *
 
 */
 

	
 
#ifndef _MODELCATALOGUE_H_
 
#define _MODELCATALOGUE_H_
 

	
 
#include "warning.h"
 
#include "cell.h"
 
#include "mesh.h"
 
#include "simplugin.h"
 
#include "canvas.h"
 
#include <QPluginLoader>
 
#include <Q3PopupMenu>
 
#include <QAction>
 
#include <QDir>
 
#include <QApplication>
 
#include <QObject>
 
#include <QAction>
 
#include <QMenu>
 

	
 
class ModelCatalogue : public QObject {
 
  Q_OBJECT
 
    public:
 
  ModelCatalogue(Mesh *mesh, Main *mainwin, const char *model); 	
 
  ModelCatalogue(Mesh *mesh, MainBase *mainwin, const char *model); 	
 
  void LoadPlugins(); 
 
  void LoadPlugin(const char *model);
 

	
 
  void InstallFirstModel();
 
  void PopulateModelMenu();	
 

	
 
  public slots:
 
  void InstallModel(SimPluginInterface *model);	
 
  void InstallModel(QAction *modelaction);
 
 private:
 
  QVector<SimPluginInterface *> models;
 
  Mesh *mesh;
 
  Main *mainwin;
 
  MainBase *mainwin;
 
};
 

	
 
#endif
 

	
 
/* finis */
src/parameter.cpp
Show inline comments
 
@@ -30,48 +30,54 @@
 
#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;
 
  nodenumsize = 1;
 
  node_mag = 1.0;
 
  outlinewidth = 1.0;
 
  cell_outline_color = strdup("forestgreen");
 
  resize_stride = 0;
 
  export_interval = 0;
 
  export_fn_prefix = strdup("cell.");
 
  storage_stride = 10;
 
  xml_storage_stride = 500;
 
  datadir = strdup(".");
 
  datadir = AppendHomeDirIfPathRelative(datadir);
 
  T = 1.0;
 
  lambda_length = 100.;
 
  yielding_threshold = 4.;
 
  lambda_celllength = 0.;
 
  target_length = 60.;
 
  cell_expansion_rate = 1.;
 
  cell_div_expansion_rate = 0.;
 
  auxin_dependent_growth = true;
 
  ode_accuracy = 1e-4;
 
  mc_stepsize = 0.4;
 
  mc_cell_stepsize = 0.2;
 
  energy_threshold = 1000.;
 
  bend_lambda = 0.;
 
  alignment_lambda = 0.;
 
  rel_cell_div_threshold = 2.;
 
  rel_perimeter_stiffness = 2;
 
  collapse_node_threshold = 0.05;
 
  morphogen_div_threshold = 0.2;
 
  morphogen_expansion_threshold = 0.01;
 
  copy_wall = true;
 
  source = 0.;
 
  D = new double[15];
 
  D[0] = 0.;
 
  D[1] = 0.0;
 
@@ -114,165 +120,167 @@ Parameter::Parameter() {
 
  ka = 1;
 
  pin_prod = 0.001;
 
  pin_prod_in_epidermis = 0.1;
 
  pin_breakdown = 0.001;
 
  pin_breakdown_internal = 0.001;
 
  aux1prod = 0.001;
 
  aux1prodmeso = 0.;
 
  aux1decay = 0.001;
 
  aux1decaymeso = 0.1;
 
  aux1transport = 0.036;
 
  aux_cons = 0.;
 
  aux_breakdown = 0.;
 
  kaux1 = 1;
 
  kap = 1;
 
  leaf_tip_source = 0.001;
 
  sam_efflux = 0.0001;
 
  sam_auxin = 10.;
 
  sam_auxin_breakdown = 0;
 
  van3prod = 0.002;
 
  van3autokat = 0.1;
 
  van3sat = 10;
 
  k2van3 = 0.3;
 
  dt = 0.1;
 
  rd_dt = 1.0;
 
  datadir = strdup(".");
 
  datadir = AppendHomeDirIfPathRelative(datadir);
 
  movie = false;
 
  nit = 100000;
 
  maxt = 1000.;
 
  storage_stride = 10;
 
  xml_storage_stride = 500;
 
  rseed = -1;
 
  constituous_expansion_limit = 16;
 
  vessel_inh_level = 1;
 
  vessel_expansion_rate = 0.25;
 
  d = 0.;
 
  e = 0.;
 
  f = 0.;
 
  c = 0.;
 
  mu = 0.;
 
  nu = 0.;
 
  rho0 = 0.;
 
  rho1 = 0.;
 
  c0 = 0.;
 
  gamma = 0.;
 
  eps = 0.;
 
  k = new double[15];
 
  k[0] = 0.;
 
  k[1] = 0.0;
 
  k[2] = 0.0;
 
  k[3] = 0.;
 
  k[4] = 0.;
 
  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 = 0;
 
  export_fn_prefix = strdup("cell.");
 
}
 

	
 
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 (export_fn_prefix) 
 
     free(export_fn_prefix);
 
  if (datadir) 
 
     free(datadir);
 
  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);
 
  outlinewidth = fgetpar(fp, "outlinewidth", 1.0, true);
 
  cell_outline_color = sgetpar(fp, "cell_outline_color", "forestgreen", true);
 
  resize_stride = igetpar(fp, "resize_stride", 0, true);
 
  export_interval = igetpar(fp, "export_interval", 0, true);
 
  export_fn_prefix = sgetpar(fp, "export_fn_prefix", "cell.", true);
 
  storage_stride = igetpar(fp, "storage_stride", 10, true);
 
  xml_storage_stride = igetpar(fp, "xml_storage_stride", 500, true);
 
  datadir = sgetpar(fp, "datadir", ".", true);
 
  datadir = AppendHomeDirIfPathRelative(datadir);
 
  if (strcmp(datadir, "."))
 
    MakeDir(datadir);
 
  T = fgetpar(fp, "T", 1.0, true);
 
  lambda_length = fgetpar(fp, "lambda_length", 100., true);
 
  yielding_threshold = fgetpar(fp, "yielding_threshold", 4., true);
 
  lambda_celllength = fgetpar(fp, "lambda_celllength", 0., true);
 
  target_length = fgetpar(fp, "target_length", 60., true);
 
  cell_expansion_rate = fgetpar(fp, "cell_expansion_rate", 1., true);
 
  cell_div_expansion_rate = fgetpar(fp, "cell_div_expansion_rate", 0., true);
 
  auxin_dependent_growth = bgetpar(fp, "auxin_dependent_growth", true, true);
 
  ode_accuracy = fgetpar(fp, "ode_accuracy", 1e-4, true);
 
  mc_stepsize = fgetpar(fp, "mc_stepsize", 0.4, true);
 
  mc_cell_stepsize = fgetpar(fp, "mc_cell_stepsize", 0.2, true);
 
  energy_threshold = fgetpar(fp, "energy_threshold", 1000., true);
 
  bend_lambda = fgetpar(fp, "bend_lambda", 0., true);
 
  alignment_lambda = fgetpar(fp, "alignment_lambda", 0., true);
 
  rel_cell_div_threshold = fgetpar(fp, "rel_cell_div_threshold", 2., true);
 
  rel_perimeter_stiffness = fgetpar(fp, "rel_perimeter_stiffness", 2, true);
 
  collapse_node_threshold = fgetpar(fp, "collapse_node_threshold", 0.05, true);
 
  morphogen_div_threshold = fgetpar(fp, "morphogen_div_threshold", 0.2, true);
 
  morphogen_expansion_threshold = fgetpar(fp, "morphogen_expansion_threshold", 0.01, true);
 
  copy_wall = bgetpar(fp, "copy_wall", true, true);
 
  source = fgetpar(fp, "source", 0., true);
 
  D = dgetparlist(fp, "D", 15, true);
 
  initval = dgetparlist(fp, "initval", 15, true);
 
  k1 = fgetpar(fp, "k1", 1., true);
 
@@ -285,122 +293,127 @@ void Parameter::Read(const char *filenam
 
  ka = fgetpar(fp, "ka", 1, true);
 
  pin_prod = fgetpar(fp, "pin_prod", 0.001, true);
 
  pin_prod_in_epidermis = fgetpar(fp, "pin_prod_in_epidermis", 0.1, true);
 
  pin_breakdown = fgetpar(fp, "pin_breakdown", 0.001, true);
 
  pin_breakdown_internal = fgetpar(fp, "pin_breakdown_internal", 0.001, true);
 
  aux1prod = fgetpar(fp, "aux1prod", 0.001, true);
 
  aux1prodmeso = fgetpar(fp, "aux1prodmeso", 0., true);
 
  aux1decay = fgetpar(fp, "aux1decay", 0.001, true);
 
  aux1decaymeso = fgetpar(fp, "aux1decaymeso", 0.1, true);
 
  aux1transport = fgetpar(fp, "aux1transport", 0.036, true);
 
  aux_cons = fgetpar(fp, "aux_cons", 0., true);
 
  aux_breakdown = fgetpar(fp, "aux_breakdown", 0., true);
 
  kaux1 = fgetpar(fp, "kaux1", 1, true);
 
  kap = fgetpar(fp, "kap", 1, true);
 
  leaf_tip_source = fgetpar(fp, "leaf_tip_source", 0.001, true);
 
  sam_efflux = fgetpar(fp, "sam_efflux", 0.0001, true);
 
  sam_auxin = fgetpar(fp, "sam_auxin", 10., true);
 
  sam_auxin_breakdown = fgetpar(fp, "sam_auxin_breakdown", 0, true);
 
  van3prod = fgetpar(fp, "van3prod", 0.002, true);
 
  van3autokat = fgetpar(fp, "van3autokat", 0.1, true);
 
  van3sat = fgetpar(fp, "van3sat", 10, true);
 
  k2van3 = fgetpar(fp, "k2van3", 0.3, true);
 
  dt = fgetpar(fp, "dt", 0.1, true);
 
  rd_dt = fgetpar(fp, "rd_dt", 1.0, true);
 
  datadir = sgetpar(fp, "datadir", ".", true);
 
  datadir = AppendHomeDirIfPathRelative(datadir);
 
  if (strcmp(datadir, "."))
 
    MakeDir(datadir);
 
  movie = bgetpar(fp, "movie", false, true);
 
  nit = igetpar(fp, "nit", 100000, true);
 
  maxt = fgetpar(fp, "maxt", 1000., true);
 
  storage_stride = igetpar(fp, "storage_stride", 10, true);
 
  xml_storage_stride = igetpar(fp, "xml_storage_stride", 500, true);
 
  rseed = igetpar(fp, "rseed", -1, true);
 
  constituous_expansion_limit = igetpar(fp, "constituous_expansion_limit", 16, true);
 
  vessel_inh_level = fgetpar(fp, "vessel_inh_level", 1, true);
 
  vessel_expansion_rate = fgetpar(fp, "vessel_expansion_rate", 0.25, true);
 
  d = fgetpar(fp, "d", 0., true);
 
  e = fgetpar(fp, "e", 0., true);
 
  f = fgetpar(fp, "f", 0., true);
 
  c = fgetpar(fp, "c", 0., true);
 
  mu = fgetpar(fp, "mu", 0., true);
 
  nu = fgetpar(fp, "nu", 0., true);
 
  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", 0, true);
 
  export_fn_prefix = sgetpar(fp, "export_fn_prefix", "cell.", 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;
 
  os << " outlinewidth = " << outlinewidth << endl;
 

	
 
  if (cell_outline_color) 
 
  os << " cell_outline_color = " << cell_outline_color << endl;
 
  os << " resize_stride = " << resize_stride << endl;
 
  os << " export_interval = " << export_interval << endl;
 

	
 
  if (export_fn_prefix) 
 
  os << " export_fn_prefix = " << export_fn_prefix << endl;
 
  os << " storage_stride = " << storage_stride << endl;
 
  os << " xml_storage_stride = " << xml_storage_stride << endl;
 
  if (datadir) {
 
                                     QDir dataDir = QDir::home().relativeFilePath(datadir);
 
                                     os << " datadir = " << dataDir.dirName().toStdString() << endl;
 
                                 }
 
                                 else {
 
                                     os << "datadir = ." << endl;
 
                                 }
 
  os << " T = " << T << endl;
 
  os << " lambda_length = " << lambda_length << endl;
 
  os << " yielding_threshold = " << yielding_threshold << endl;
 
  os << " lambda_celllength = " << lambda_celllength << endl;
 
  os << " target_length = " << target_length << endl;
 
  os << " cell_expansion_rate = " << cell_expansion_rate << endl;
 
  os << " cell_div_expansion_rate = " << cell_div_expansion_rate << endl;
 
  os << " auxin_dependent_growth = " << sbool(auxin_dependent_growth) << endl;
 
  os << " ode_accuracy = " << ode_accuracy << endl;
 
  os << " mc_stepsize = " << mc_stepsize << endl;
 
  os << " mc_cell_stepsize = " << mc_cell_stepsize << endl;
 
  os << " energy_threshold = " << energy_threshold << endl;
 
  os << " bend_lambda = " << bend_lambda << endl;
 
  os << " alignment_lambda = " << alignment_lambda << endl;
 
  os << " rel_cell_div_threshold = " << rel_cell_div_threshold << endl;
 
  os << " rel_perimeter_stiffness = " << rel_perimeter_stiffness << endl;
 
  os << " collapse_node_threshold = " << collapse_node_threshold << endl;
 
  os << " morphogen_div_threshold = " << morphogen_div_threshold << endl;
 
  os << " morphogen_expansion_threshold = " << morphogen_expansion_threshold << endl;
 
  os << " copy_wall = " << sbool(copy_wall) << endl;
 
  os << " source = " << source << endl;
 
  os << " D = "<< D[0] << ", " << D[1] << ", " << D[2] << ", " << D[3] << ", " << D[4] << ", " << D[5] << ", " << D[6] << ", " << D[7] << ", " << D[8] << ", " << D[9] << ", " << D[10] << ", " << D[11] << ", " << D[12] << ", " << D[13] << ", " << D[14] << endl;
 
  os << " initval = "<< initval[0] << ", " << initval[1] << ", " << initval[2] << ", " << initval[3] << ", " << initval[4] << ", " << initval[5] << ", " << initval[6] << ", " << initval[7] << ", " << initval[8] << ", " << initval[9] << ", " << initval[10] << ", " << initval[11] << ", " << initval[12] << ", " << initval[13] << ", " << initval[14] << endl;
 
  os << " k1 = " << k1 << endl;
 
@@ -413,104 +426,91 @@ void Parameter::Write(ostream &os) const
 
  os << " ka = " << ka << endl;
 
  os << " pin_prod = " << pin_prod << endl;
 
  os << " pin_prod_in_epidermis = " << pin_prod_in_epidermis << endl;
 
  os << " pin_breakdown = " << pin_breakdown << endl;
 
  os << " pin_breakdown_internal = " << pin_breakdown_internal << endl;
 
  os << " aux1prod = " << aux1prod << endl;
 
  os << " aux1prodmeso = " << aux1prodmeso << endl;
 
  os << " aux1decay = " << aux1decay << endl;
 
  os << " aux1decaymeso = " << aux1decaymeso << endl;
 
  os << " aux1transport = " << aux1transport << endl;
 
  os << " aux_cons = " << aux_cons << endl;
 
  os << " aux_breakdown = " << aux_breakdown << endl;
 
  os << " kaux1 = " << kaux1 << endl;
 
  os << " kap = " << kap << endl;
 
  os << " leaf_tip_source = " << leaf_tip_source << endl;
 
  os << " sam_efflux = " << sam_efflux << endl;
 
  os << " sam_auxin = " << sam_auxin << endl;
 
  os << " sam_auxin_breakdown = " << sam_auxin_breakdown << endl;
 
  os << " van3prod = " << van3prod << endl;
 
  os << " van3autokat = " << van3autokat << endl;
 
  os << " van3sat = " << van3sat << endl;
 
  os << " k2van3 = " << k2van3 << endl;
 
  os << " dt = " << dt << endl;
 
  os << " rd_dt = " << rd_dt << endl;
 
  if (datadir) {
 
                                     QDir dataDir = QDir::home().relativeFilePath(datadir);
 
                                     os << " datadir = " << dataDir.dirName().toStdString() << endl;
 
                                 }
 
                                 else {
 
                                     os << "datadir = ." << endl;
 
                                 }
 
  os << " movie = " << sbool(movie) << endl;
 
  os << " nit = " << nit << endl;
 
  os << " maxt = " << maxt << endl;
 
  os << " storage_stride = " << storage_stride << endl;
 
  os << " xml_storage_stride = " << xml_storage_stride << endl;
 
  os << " rseed = " << rseed << endl;
 
  os << " constituous_expansion_limit = " << constituous_expansion_limit << endl;
 
  os << " vessel_inh_level = " << vessel_inh_level << endl;
 
  os << " vessel_expansion_rate = " << vessel_expansion_rate << endl;
 
  os << " d = " << d << endl;
 
  os << " e = " << e << endl;
 
  os << " f = " << f << endl;
 
  os << " c = " << c << endl;
 
  os << " mu = " << mu << endl;
 
  os << " nu = " << nu << endl;
 
  os << " rho0 = " << rho0 << endl;
 
  os << " rho1 = " << rho1 << endl;
 
  os << " c0 = " << c0 << endl;
 
  os << " gamma = " << gamma << endl;
 
  os << " eps = " << eps << endl;
 
  os << " k = "<< k[0] << ", " << k[1] << ", " << k[2] << ", " << k[3] << ", " << k[4] << ", " << k[5] << ", " << k[6] << ", " << k[7] << ", " << k[8] << ", " << k[9] << ", " << k[10] << ", " << k[11] << ", " << k[12] << ", " << k[13] << ", " << k[14] << endl;
 
  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;
 
@@ -544,48 +544,89 @@ xmlNewProp(xmlpar, BAD_CAST "val", BAD_C
 
  xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
  xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "outlinewidth" );
 
  ostringstream text;
 
    text << outlinewidth;
 
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 "cell_outline_color" );
 
  ostringstream text;
 

	
 
  if (cell_outline_color) 
 
    text << cell_outline_color;
 
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 "resize_stride" );
 
  ostringstream text;
 
    text << resize_stride;
 
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());
 
}
 
{
 
  xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
  xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "storage_stride" );
 
  ostringstream text;
 
    text << storage_stride;
 
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 "xml_storage_stride" );
 
  ostringstream text;
 
    text << xml_storage_stride;
 
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 "datadir" );
 
  ostringstream text;
 

	
 
  if (datadir) {
 
                                     QDir dataDir = QDir::home().relativeFilePath(datadir);
 
                                     text << dataDir.dirName().toStdString();
 
                                   }
 
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 "T" );
 
  ostringstream text;
 
    text << T;
 
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 "lambda_length" );
 
  ostringstream text;
 
    text << lambda_length;
 
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 "yielding_threshold" );
 
  ostringstream text;
 
    text << yielding_threshold;
 
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 "lambda_celllength" );
 
  ostringstream text;
 
    text << lambda_celllength;
 
@@ -1098,94 +1139,69 @@ xmlNewProp(xmlpar, BAD_CAST "val", BAD_C
 
}
 
{
 
  xmlNode *xmlpar = xmlNewChild(xmlparameter, NULL, BAD_CAST "par", NULL);
 
  xmlNewProp(xmlpar, BAD_CAST "name", BAD_CAST "k2van3" );
 
  ostringstream text;
 
    text << k2van3;
 
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 "dt" );
 
  ostringstream text;
 
    text << dt;
 
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 "rd_dt" );
 
  ostringstream text;
 
    text << rd_dt;
 
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 "datadir" );
 
  ostringstream text;
 

	
 
  if (datadir) {
 
                                     QDir dataDir = QDir::home().relativeFilePath(datadir);
 
                                     text << dataDir.dirName().toStdString();
 
                                   }
 
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 "movie" );
 
  ostringstream text;
 
text << sbool(movie);
 
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 "nit" );
 
  ostringstream text;
 
    text << nit;
 
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 "maxt" );
 
  ostringstream text;
 
    text << maxt;
 
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 "storage_stride" );
 
  ostringstream text;
 
    text << storage_stride;
 
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 "xml_storage_stride" );
 
  ostringstream text;
 
    text << xml_storage_stride;
 
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 "rseed" );
 
  ostringstream text;
 
    text << rseed;
 
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 "constituous_expansion_limit" );
 
  ostringstream text;
 
    text << constituous_expansion_limit;
 
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 "vessel_inh_level" );
 
  ostringstream text;
 
    text << vessel_inh_level;
 
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 "vessel_expansion_rate" );
 
  ostringstream text;
 
    text << vessel_expansion_rate;
 
@@ -1450,104 +1466,109 @@ xmlNewProp(xmlpar, BAD_CAST "val", BAD_C
 
  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); }
 
}
 
if (!strcmp(namec, "node_mag")) {
 
  node_mag = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'node_mag' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "outlinewidth")) {
 
  outlinewidth = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'outlinewidth' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "cell_outline_color")) {
 
  if (cell_outline_color) { free(cell_outline_color); }
 
  cell_outline_color=strdup(valc);
 
}
 
if (!strcmp(namec, "resize_stride")) {
 
  resize_stride = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'resize_stride' from XML file.",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);
 
}
 
if (!strcmp(namec, "storage_stride")) {
 
  storage_stride = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'storage_stride' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "xml_storage_stride")) {
 
  xml_storage_stride = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'xml_storage_stride' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "datadir")) {
 
  if (datadir) { free(datadir); }
 
  datadir=strdup(valc);
 
  datadir = AppendHomeDirIfPathRelative(datadir);
 
}
 
if (!strcmp(namec, "T")) {
 
  T = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'T' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "lambda_length")) {
 
  lambda_length = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'lambda_length' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "yielding_threshold")) {
 
  yielding_threshold = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'yielding_threshold' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "lambda_celllength")) {
 
  lambda_celllength = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'lambda_celllength' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "target_length")) {
 
  target_length = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'target_length' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "cell_expansion_rate")) {
 
  cell_expansion_rate = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'cell_expansion_rate' from XML file.",valc); }
 
}
 
@@ -1712,72 +1733,59 @@ if (!strcmp(namec, "sam_auxin_breakdown"
 
if (!strcmp(namec, "van3prod")) {
 
  van3prod = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'van3prod' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "van3autokat")) {
 
  van3autokat = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'van3autokat' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "van3sat")) {
 
  van3sat = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'van3sat' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "k2van3")) {
 
  k2van3 = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'k2van3' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "dt")) {
 
  dt = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'dt' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "rd_dt")) {
 
  rd_dt = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'rd_dt' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "datadir")) {
 
  if (datadir) { free(datadir); }
 
  datadir=strdup(valc);
 
  datadir = AppendHomeDirIfPathRelative(datadir);
 
}
 
if (!strcmp(namec, "movie")) {
 
movie = strtobool(valc);
 
}
 
if (!strcmp(namec, "nit")) {
 
  nit = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'nit' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "maxt")) {
 
  maxt = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'maxt' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "storage_stride")) {
 
  storage_stride = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'storage_stride' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "xml_storage_stride")) {
 
  xml_storage_stride = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'xml_storage_stride' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "rseed")) {
 
  rseed = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'rseed' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "constituous_expansion_limit")) {
 
  constituous_expansion_limit = standardlocale.toInt(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to integer while reading parameter 'constituous_expansion_limit' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "vessel_inh_level")) {
 
  vessel_inh_level = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'vessel_inh_level' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "vessel_expansion_rate")) {
 
  vessel_expansion_rate = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'vessel_expansion_rate' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "d")) {
 
  d = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'd' from XML file.",valc); }
 
}
 
if (!strcmp(namec, "e")) {
 
  e = standardlocale.toDouble(valc, &ok);
 
  if (!ok) { MyWarning::error("Read error: cannot convert string \"%s\" to double while reading parameter 'e' from XML file.",valc); }
 
}
 
@@ -1848,56 +1856,48 @@ if (!strcmp(namec, "s2")) {
 
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
 
@@ -32,48 +32,53 @@
 
#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;
 
  int nodenumsize;
 
  double node_mag;
 
  double outlinewidth;
 
  char * cell_outline_color;
 
  int resize_stride;
 
  int export_interval;
 
  char * export_fn_prefix;
 
  int storage_stride;
 
  int xml_storage_stride;
 
  char * datadir;
 
  double T;
 
  double lambda_length;
 
  double yielding_threshold;
 
  double lambda_celllength;
 
  double target_length;
 
  double cell_expansion_rate;
 
  double cell_div_expansion_rate;
 
  bool auxin_dependent_growth;
 
  double ode_accuracy;
 
  double mc_stepsize;
 
  double mc_cell_stepsize;
 
  double energy_threshold;
 
  double bend_lambda;
 
  double alignment_lambda;
 
  double rel_cell_div_threshold;
 
  double rel_perimeter_stiffness;
 
  double collapse_node_threshold;
 
  double morphogen_div_threshold;
 
  double morphogen_expansion_threshold;
 
  bool copy_wall;
 
  double source;
 
  double * D;
 
  double * initval;
 
  double k1;
 
@@ -86,70 +91,65 @@
 
  double ka;
 
  double pin_prod;
 
  double pin_prod_in_epidermis;
 
  double pin_breakdown;
 
  double pin_breakdown_internal;
 
  double aux1prod;
 
  double aux1prodmeso;
 
  double aux1decay;
 
  double aux1decaymeso;
 
  double aux1transport;
 
  double aux_cons;
 
  double aux_breakdown;
 
  double kaux1;
 
  double kap;
 
  double leaf_tip_source;
 
  double sam_efflux;
 
  double sam_auxin;
 
  double sam_auxin_breakdown;
 
  double van3prod;
 
  double van3autokat;
 
  double van3sat;
 
  double k2van3;
 
  double dt;
 
  double rd_dt;
 
  char * datadir;
 
  bool movie;
 
  int nit;
 
  double maxt;
 
  int storage_stride;
 
  int xml_storage_stride;
 
  int rseed;
 
  int constituous_expansion_limit;
 
  double vessel_inh_level;
 
  double vessel_expansion_rate;
 
  double d;
 
  double e;
 
  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

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)