Changeset - 59e38e5f05d2
[Not reviewed]
default
0 15 0
Michael Guravage - 15 years ago 2010-06-23 16:21:32
michael.guravage@cwi.nl
Reverted NULL assignments to obviate compilation warnings.

--
user: Michael Guravage <michael.guravage@cwi.nl>
branch 'default'

changed src/ChangeLog
changed src/VirtualLeaf.cpp
changed src/apoplastitem.cpp
changed src/build_models/ChangeLog
changed src/build_models/auxingrowthplugin.cpp
changed src/build_models/meinhardtplugin.cpp
changed src/build_models/testplugin.cpp
changed src/canvas.cpp
changed src/cell.cpp
changed src/cellbase.h
changed src/forwardeuler.cpp
changed src/mainbase.h
changed src/nodeitem.cpp
changed src/qcanvasarrow.h
changed src/simitembase.cpp
15 files changed with 29 insertions and 53 deletions:
0 comments (0 inline, 0 general)
src/ChangeLog
Show inline comments
 
2010-06-23    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* simitembase.cpp: Removed NULL assignments to unused variables.
 
	* VirtualLeaf.cpp: Ditto.
 
	* apoplastitem.cpp: Ditto.
 
	* canvas.cpp: Ditto.
 
	* cell.cpp: Ditto.
 
	* cellbase.h: Ditto.
 
	* forwardeuler.cpp: Ditto.
 
	* mainbase.h: Ditto.
 
	* nodeitem.cpp: Ditto.
 
	* qcanvasarrow.h: Ditto.
 
	* simitembase.cpp: Ditto.
 

	
 

	
 
	* Makefile (clean): Add -f Makefile argument to each make invocation.
 

	
 
	* VirtualLeaf-install.nsi: New gpl license text.
 

	
 
	* VirtualLeaf.pro: Disabled console mode.
 

	
 
	* mesh.cpp (Clear): Added parentheses to qDebug statments.
 
	(TestIllegalWalls): Replaced qDebug().
 

	
 
	* canvas.cpp (mouseReleaseEvent): Replaced qDebug() with cerr since qDebug complains about *node_set.
 

	
 
	* wall.cpp (CorrectWall): Rplaced gDebug() with cerr in transform call and when printing *this.
 

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

	
 
	* Makefile (tutorials): Add tutorials target.
 

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

	
 
	* parameter.cpp: Added particular reassignment of datadir.
 

	
 
	* canvas.cpp (gpl): Added GPL3 License text. Display detail text only if the source text file exists.
 

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

	
 
	* canvas.cpp (gpl): Added gpl slot to display GPL license.
 

	
 
	* VirtualLeaf.pro: Changed default LIBXML2DIR, LIBICONVDIR and LIBZDIR to corresponding distribution lib directories.
 
	* libplugin.pro: Ditto.
 

	
 
	* Makefile (clean): add if stmt not to `touch` on windows.
 

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

	
 
	* VirtualLeaf.pro: Removed perl references.
 
	* libplugin.pro: Ditto.
 

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

	
 
	* VirtualLeaf.pro: Removed xmlwritecode.cpp from SOURCES list.
 

	
 
	* xmlwrite.cpp (XMLSave): Removed references to XMLWriteLeafSourceCode and XMLWriteReactionsCode.
 
	* xmlwrite.h (XMLIO): Ditto!
 

	
 
	* mesh.cpp (findNextBoundaryNode): Initialize Node *next_boundary_node = NULL;
 

	
 
	* xmlwrite.cpp (XMLReadSimtime): Removed unused variable cur
 
	(XMLReadWalls): viz_flux need not be declared twice; default value of 0.0.
src/VirtualLeaf.cpp
Show inline comments
 
@@ -230,100 +230,97 @@ INIT {
 

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

	
 

	
 
  double dh;
 

	
 
  if(DynamicCellsP()) {
 
    dh = mesh.DisplaceNodes();
 

	
 
    // Only allow for node insertion, cell division and cell growth
 
    // if the system has equillibrized
 
    // i.e. cell wall tension equillibrization is much faster
 
    // than biological processes, including division, cell wall yielding
 
    // and cell expansion
 
    mesh.InsertNodes(); // (this amounts to cell wall yielding)
 

	
 
    if ( (-dh) < par.energy_threshold) {
 

	
 
      mesh.IncreaseCellCapacityIfNecessary();
 
      mesh.DoCellHouseKeeping();
 
      //mesh.LoopCurrentCells(mem_fun(&plugin->CellHouseKeeping)); // this includes cell division
 

	
 
      // Reaction diffusion	
 
      mesh.ReactDiffuse(par.rd_dt);
 
      t++;
 
      Plot(par.resize_stride);
 
    }
 
  } else {
 
    mesh.ReactDiffuse(par.rd_dt);
 
    Plot(par.resize_stride);
 
  }
 
  i++;
 
  return mesh.getTime();
 
}
 

	
 

	
 

	
 
/* Called if a cell is clicked */
 
void Cell::OnClick(QMouseEvent *e)
 
{
 
  e = NULL; // use assignment merely to obviate compilation warning
 
}
 
void Cell::OnClick(QMouseEvent *e){}
 

	
 

	
 
/* Custom message handler - Default appends a newline character to the end of each line. */ 
 
void vlMessageOutput(QtMsgType type, const char *msg)
 
{
 
  switch (type) {
 
  case QtDebugMsg:
 
    //fprintf(stderr, "Debug: %s\n", msg);
 
    cerr << msg << flush;
 
    break;
 
  case QtWarningMsg:
 
    //fprintf(stderr, "Warning: %s\n", msg);
 
    cerr << "Warning: " << msg << flush;
 
    break;
 
  case QtCriticalMsg:
 
    fprintf(stderr, "Critical: %s\n", msg);
 
    cerr << "Critical: " << msg << flush;
 
    break;
 
  case QtFatalMsg:
 
    //fprintf(stderr, "Fatal: %s\n", msg);
 
    cerr << "Fatal: " << msg << flush;
 
    abort();
 
  }
 
}
 

	
 

	
 
Parameter par;
 

	
 
int main(int argc,char **argv) {
 

	
 
  try {
 
    int c;
 
    char *leaffile=0;
 
    char *modelfile=0;
 

	
 
    while (1) {
 

	
 
      //int this_option_optind = optind ? optind : 1;
 
      int option_index = 0;
 
      static struct option long_options[] = {
 
	{"batch", no_argument, NULL, 'b'},
 
	{"leaffile", required_argument, NULL, 'l'},
 
	{"model", required_argument, NULL, 'm'} 
 
      };
 

	
 
      // short option 'p' creates trouble for non-commandline usage on MacOSX. Option -p changed to -P (capital)
 
      static char *short_options = "blm";
 
      c = getopt_long (argc, argv, "bl:m:",
src/apoplastitem.cpp
Show inline comments
 
@@ -23,53 +23,51 @@
 

	
 

	
 
#include <string>
 
#include <QGraphicsScene>
 
#include "canvas.h"
 
#include "parameter.h"
 
#include "node.h"
 
#include "apoplastitem.h"
 

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

	
 
ApoplastItem::ApoplastItem( Wall *w, QGraphicsScene *canvas )
 
  : QGraphicsLineItem( 0, canvas ), SimItemBase( w, canvas){
 

	
 
  setColor();
 

	
 
  // line with "PIN1"is a bit inside the cell wall
 
  Vector edgevec = (*(w->N2())) - (*(w->N1()));
 
  Vector perp = edgevec.Normalised().Perp2D();
 

	
 
  Vector offs = Cell::Offset();
 
  double factor = Cell::Factor();
 

	
 
  Vector from = ( offs + *(w->N1()) ) * factor;
 
  Vector to = ( offs + *(w->N2()) ) *factor;
 

	
 

	
 
  setLine(( from.x ),
 
	  ( from.y ),
 
	  ( to.x ),
 
	  ( to.y ) );
 
  setZValue(12);
 
}
 

	
 

	
 
void ApoplastItem::setColor(void) {
 

	
 
  QColor diffcolor;
 
  static const QColor purple("Purple");
 
  static const QColor blue("blue");
 

	
 
  Wall *w=&getWall();
 
  double val = w->getApoplast(2);
 

	
 
  diffcolor.setRgb( 0,0,(int)( ( val / (1 + val) )*255.));
 
  setPen (QPen(diffcolor, 20) );
 
}
 

	
 
void ApoplastItem::OnClick(QMouseEvent *e) {
 
  e = NULL; // merely to obviate compilation warnings
 
}
 
void ApoplastItem::OnClick(QMouseEvent *e) {}
 

	
 
/* finis*/
src/build_models/ChangeLog
Show inline comments
 
2010-06-23    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* auxingrowthplugin.cpp: Removed NULL assignments to unused variables.
 
	* meinhardtplugin.cpp: Ditto.
 
	* testplugin.cpp: Ditto.
 

	
 

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

	
 
	* Makefile (clean): Add windows equivalent of UNIX touch.
 

	
 

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

	
 
	* plugin_auxingrowth.pro: Changed default LIBXML2DIR, LIBICONVDIR and LIBZDIR to corresponding distribution lib directories.
 
	* plugin_meinhardt.pro: Ditto.
 
	* plugin_test.pro: Ditto.
 

	
 
	* Makefile (clean): add if stmt not to `touch` on windows.
 

	
 

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

	
 

	
 
	* testplugin.cpp (CelltoCellTransport) Use NULL assignment merely to obviate compilation warnings.
 
	(WallDynamics): Ditto.
 
	(CellDynamics): Ditto.
 
	(OnDivide): Ditto.
 

	
 
	* meinhardtplugin.cpp (OnDivide): Use NULL assignment merely to obviate compilation warnings.
 
	* (WallDynamics): Ditto.
 

	
 
	* auxingrowthplugin.cpp (OnDivide): Use NULL assignment merely to obviate compilation warnings.
 

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

	
 
	* Makefile: Added top-level Makefile.
 

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

	
 
	* plugin_test.pro: Added -fPIC option to QMAKE_CXXFLAGS.
 
	* plugin_meinhardt.pro: ditto
 
	* plugin_auxingrowth.pro: ditto
 

	
 

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

	
 
#include <QObject>
 
#include <QtGui>
 
#include "../simplugin.h"
 

	
 
#include "parameter.h"
 

	
 
#include "wallbase.h"
 
#include "cellbase.h"
 
#include "auxingrowthplugin.h"
 

	
 
#include "far_mem_5.h"
 

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

	
 
bool batch = false;
 

	
 

	
 
// To be executed after cell division
 
void AuxinGrowthPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2)
 
{
 
  parent_info = NULL; // merely to obviate compile time error
 

	
 
  // Auxin distributes between parent and daughter according to area
 
  double area1 = daughter1->Area(), area2 = daughter2->Area();
 
  double tot_area = area1 + area2;
 
	
 
  daughter1->SetChemical(0,daughter1->Chemical(0)*(area1/tot_area));
 
  daughter2->SetChemical(0,daughter2->Chemical(0)*(area2/tot_area));
 
	
 
  // After divisions, parent and daughter cells get a standard stock of PINs.
 
  daughter1->SetChemical(1, par->initval[1]);
 
  daughter2->SetChemical(1, par->initval[1]);
 
	
 
	
 
  // Reset transporter values of parent and daughter
 
  QList<WallBase *> walls;
 
  foreach(WallBase *w, walls) { 
 
    w->setTransporter(daughter1, 1, 0.);
 
  }
 
}
 

	
 
void AuxinGrowthPlugin::SetCellColor(CellBase *c, QColor *color)
 
{ 
 

	
 
  // Red: PIN1
 
  // Green: Auxin
 
  if (c->CellType()==1)
 
    color->setNamedColor("Blue"); 
 
  else 
 
    color->setRgb(c->Chemical(1)/(1+c->Chemical(1)) * 255.,(c->Chemical(0)/(1+c->Chemical(0)) * 255.), 0);
 
}
 

	
 

	
 

	
 
void AuxinGrowthPlugin::CellHouseKeeping(CellBase *c)
 
{
 
  if (c->Boundary()==CellBase::None) {
 
    if (c->Area() > par->rel_cell_div_threshold * c->BaseArea() ) {
 
      c->SetChemical(0,0);
 
      c->Divide();
 
    }		
 
    if (c->Chemical(0)>0.6) {
 
      c->SetCellType(1);
 
    } 
 
    // expand according to auxin concentration
 
    c->EnlargeTargetArea(par->auxin_dependent_growth?(c->Chemical(0)/(1.+c->Chemical(0)))*par->cell_expansion_rate:par->cell_expansion_rate);
 
  }  
 
}
 

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

	
 
#include <QObject>
 
#include <QtGui>
 
#include "../simplugin.h"
 

	
 
#include "parameter.h"
 
#include "warning.h"
 
#include "wallbase.h"
 
#include "cellbase.h"
 
#include "meinhardtplugin.h"
 

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

	
 
bool batch = false;
 

	
 
// To be executed after cell division
 
void MeinhardtPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) {
 
  parent_info = NULL;
 
  daughter1 = daughter2 = NULL;
 
}
 
void MeinhardtPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) {}
 

	
 
void MeinhardtPlugin::SetCellColor(CellBase *c, QColor *color) { 
 

	
 
  if (fpclassify(c->Chemical(0))==FP_NAN) {
 
    // somehow the function isnan doesn't work properly on my system... SuSE Linux
 
    // 10.0 64-bits (isnan seems not be implemented using fpclassify).
 
    MyWarning::warning("Whoops! Numerical instability!!");
 
    color->setNamedColor("red");
 
  } else {
 
    double range_min = 0.;//, range_max = 1.;
 
    if (c->Chemical(0)<range_min) {
 
      MyWarning::warning("Whoops! Numerical instability!!");
 
      color->setNamedColor("blue");
 
    } else {
 
      color->setRgb(c->Chemical(1)/(1+c->Chemical(1)) * 255.,(c->Chemical(0)/(1+c->Chemical(0)) * 255.),(c->Chemical(3)/(1+c->Chemical(3)) *255.) );
 
    }
 
  }
 
}
 

	
 

	
 

	
 
void MeinhardtPlugin::CellHouseKeeping(CellBase *c) {
 
	
 
  if (c->Area() > par->rel_cell_div_threshold * c->BaseArea() ) {
 
    c->Divide();
 
  }
 
	
 
  // cell expansion is inhibited by substrate (chem 3)
 
  if (!par->constituous_expansion_limit || c->NCells()<par->constituous_expansion_limit) {
 
    c->EnlargeTargetArea(par->cell_expansion_rate );
 
  } else {
 
    if (c->Chemical(0)<0.5) {
 
      double tmp;
 
      c->EnlargeTargetArea((tmp=(1.-par->vessel_inh_level*c->Chemical(3))*par->cell_expansion_rate /* + c->Chemical(4)*/)<0?0:tmp); 
 
    } else {
 
      c->EnlargeTargetArea(par->vessel_expansion_rate);
 
    }
 
  } 
 
}
 

	
 
void MeinhardtPlugin::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) {
 
	
 
  // No flux boundaries for all chemicals, except activator: boundary is sink
 
  if (w->C1()->BoundaryPolP() || w->C2()->BoundaryPolP()) {
 
		
 
    if (w->C1()->BoundaryPolP()) {
 
      dchem_c2[1] -=  w->Length() * ( par->D[1] ) * ( w->C2()->Chemical(1) );
 
    } else {
 
      dchem_c1[1] -=  w->Length() * ( par->D[1] ) * ( w->C1()->Chemical(1) );
 
    } 
 
    return;
 
  }
 
	
 

	
 
  // Passive fluxes (Fick's law)
 
  for (int c=0;c<NChem();c++) {
 
    double phi = w->Length() * ( par->D[c] ) * ( w->C2()->Chemical(c) - w->C1()->Chemical(c) );
 
    dchem_c1[c] += phi; 
 
    dchem_c2[c] -= phi;
 
  }
 
}
 

	
 
void MeinhardtPlugin::WallDynamics(Wall *w, double *dw1, double *dw2) {
 
  w = NULL;
 
  for (int c = 0;c<NChem();c++) {
 
    dw1[c] = 0.; dw2[c] = 0.;
 
  }
 
}
 

	
 
void MeinhardtPlugin::CellDynamics(CellBase *c, double *dchem) {
 

	
 
  double Y = c->Chemical(0);
 
  double A = c->Chemical(1);
 
  double H = c->Chemical(2);
 
  double S = c->Chemical(3);
 
	
 
  dchem[0] = ( par->d * A - par->e * Y + Y*Y/(1 + par->f * Y*Y ) );
 
  dchem[1] = ( par->c * A*A*S/H - par->mu * A + par->rho0*Y );
 
  dchem[2] = ( par->c * A*A*S - par->nu*H + par->rho1*Y );
 
  dchem[3] = ( par->c0 - par->gamma*S - par->eps * Y * S );
 
}
 

	
 

	
 
Q_EXPORT_PLUGIN2(meinhardtplugin, MeinhardtPlugin)
 

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

	
 
#include <QObject>
 
#include <QtGui>
 

	
 
#include "simplugin.h"
 

	
 
#include "parameter.h"
 

	
 
#include "wallbase.h"
 
#include "cellbase.h"
 
#include "testplugin.h"
 

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

	
 
bool batch = false;
 

	
 
// To be executed after cell division
 
void TestPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) {
 
  parent_info = NULL;
 
  daughter1 = daughter2 = NULL;
 
}
 
void TestPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) {}
 

	
 
void TestPlugin::SetCellColor(CellBase *c, QColor *color) { 
 

	
 
  static QStringList colors;
 
  if (colors.size()==0) {
 
    colors << "red" << "green" << "blue";
 
  }
 
  color->setNamedColor(colors[c->Index()%colors.size()]);
 
}
 

	
 

	
 

	
 
void TestPlugin::CellHouseKeeping(CellBase *c) {
 
	
 
  c->EnlargeTargetArea(par->cell_expansion_rate);
 
  if (c->Area() > par->rel_cell_div_threshold * c->BaseArea() ) {
 
    c->Divide();
 
  }
 
}
 

	
 
void TestPlugin::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) {
 
  w = NULL;
 
  dchem_c1 = dchem_c2 = NULL;
 
}
 
void TestPlugin::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) {}
 

	
 
void TestPlugin::WallDynamics(Wall *w, double *dw1, double *dw2) {
 
  w = NULL;
 
  dw1 = dw2 = NULL;
 
}
 
void TestPlugin::WallDynamics(Wall *w, double *dw1, double *dw2) {}
 

	
 
void TestPlugin::CellDynamics(CellBase *c, double *dchem) {
 
  c = NULL;
 
  dchem=NULL;
 
}
 
void TestPlugin::CellDynamics(CellBase *c, double *dchem) {}
 

	
 
Q_EXPORT_PLUGIN2(testplugin, TestPlugin)
 

	
 
/* finis */
src/canvas.cpp
Show inline comments
 
@@ -58,99 +58,96 @@
 
#include <q3process.h>
 
#include <qlayout.h>
 
#include <qspinbox.h>
 
#include <fstream>
 
#include <sstream>
 
#include "pardialog.h"
 
#include "parameter.h"
 
#include "canvas.h"
 
#include "node.h"
 
#include "nodeset.h"
 
#include "nodeitem.h"
 
#include "cellitem.h"
 
#include "wallitem.h"
 
#include "mesh.h"
 
#include "xmlwrite.h"
 
#include "miscq.h"
 
#include "OptionFileDialog.h"
 
#include <cstdlib>
 
#include <cstdio>
 
#include "modelcatalogue.h"
 

	
 
#include <algorithm>
 

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

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

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

	
 
#define QUOTE_ME(s) QUOTE_ME_2NDLEV(s)
 
#define QUOTE_ME_2NDLEV(s) #s
 

	
 
static QColor dark_red("darkRed");
 

	
 

	
 
static const int imageRTTI = 984376;
 
extern Parameter par;
 
const QString Main::caption("Virtual leaf");
 
const QString Main::caption_with_file("Virtual leaf: %1");
 

	
 
FigureEditor::FigureEditor(
 
			   QGraphicsScene& c, Mesh &m, QWidget* parent,
 
			   const char* name, Qt::WindowFlags f) :
 
  QGraphicsView(&c,parent), mesh(m)
 
{
 
  name = NULL; // use these two assignments merely to obviate compile time warnings
 
  f = Qt::Widget;
 

	
 
  intersection_line = 0;
 
  //angle_line = 0;
 
  setInteractive(true);
 
  moving = 0;  
 
  rotation_mode = false;
 
}
 

	
 

	
 
void FigureEditor::clear()
 
{
 
  QList<QGraphicsItem *> list = scene()->items();
 
  QList<QGraphicsItem *>::Iterator it = list.begin();
 
  for (; it != list.end(); ++it) {
 
    delete *it;
 
  }
 
}
 

	
 
void FigureEditor::wheelEvent(QWheelEvent *event)
 
{
 
  scaleView(pow((double)2, -event->delta() / 240.0));
 
}
 

	
 

	
 
void FigureEditor::scaleView (qreal scaleFactor)
 
{
 
  qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)). width();
 
  if (factor < 0.07 || factor > 100) return;
 
  scale (scaleFactor, scaleFactor);
 
}
 

	
 
void FigureEditor::Save(const char *fname, const char *format, int sizex, int sizey)
 
{
 

	
 
  QImage *image = new QImage(sizex, sizey, QImage::Format_RGB32);
 
  image->fill(QColor(Qt::white).rgb());
 
  QPainter *painter=new QPainter(image);
 

	
 
  render(painter);
 

	
 
  image->save(QString(fname),format);
 
  delete painter;
 
  delete image;
 
}
 

	
 
void FigureEditor::mousePressEvent(QMouseEvent* e)
 
{
 
  static QList<Node*> selected;
 
  emit MousePressed();
src/cell.cpp
Show inline comments
 
@@ -1507,97 +1507,96 @@ void Cell::DrawNodes(QGraphicsScene *c) 
 
void Cell::DrawIndex(QGraphicsScene *c) const {
 

	
 
  DrawText( c, QString("%1").arg(index));
 
}
 

	
 
// Draw any text in the cell's center
 
void Cell::DrawText(QGraphicsScene *c, const QString &text) const {
 

	
 
  Vector centroid = Centroid();
 
  QGraphicsSimpleTextItem *ctext = new QGraphicsSimpleTextItem ( text, 0, c );
 
  ctext->setPen( QPen(QColor(par.textcolor)) );
 
  ctext->setZValue(20);
 
  ctext->setFont( QFont( "Helvetica", par.cellnumsize, QFont::Bold) );
 
  ctext->show();
 
  ctext ->setPos(((offset[0]+centroid.x)*factor),
 
		 ((offset[1]+centroid.y)*factor) );
 
}
 

	
 

	
 
void Cell::DrawAxis(QGraphicsScene *c) const {
 

	
 
  Vector long_axis;
 
  double width;
 
  Length(&long_axis, &width);
 

	
 
  //cerr << "Length is "  << length << endl;
 
  long_axis.Normalise();
 
  Vector short_axis=long_axis.Perp2D();
 

	
 

	
 
  Vector centroid = Centroid();
 
  Vector from = centroid - 0.5 * width * short_axis;
 
  Vector to = centroid + 0.5 * width *short_axis;
 

	
 

	
 
  QGraphicsLineItem *line = new QGraphicsLineItem(0, c);
 
  line->setPen( QPen(QColor(par.arrowcolor),2) );
 
  line->setZValue(2);
 

	
 
  line->setLine( ( (offset[0]+from.x)*factor ),
 
		 ( (offset[1]+from.y)*factor ), 
 
		 ( (offset[0]+to.x)*factor ),
 
		 ( (offset[1]+to.y)*factor ) );
 
  line->setZValue(10);
 
  line->show();
 
}
 

	
 
void Cell::DrawStrain(QGraphicsScene *c) const {
 
  c = NULL; // assignment merely to obviate compilation warning
 
  MyWarning::warning("Sorry, Cell::DrawStrain temporarily not implemented.");
 
}
 

	
 

	
 
void Cell::DrawFluxes(QGraphicsScene *c, double arrowsize)
 
{
 

	
 
  // get the mean flux through this cell
 
  Vector vec_flux = ReduceCellAndWalls<Vector>( PINdir );
 

	
 
  vec_flux.Normalise();
 

	
 
  vec_flux *= arrowsize;
 

	
 
  QGraphicsArrowItem *arrow = new QGraphicsArrowItem(0,c);
 

	
 
  Vector centroid = Centroid();
 
  Vector from = centroid - vec_flux/2.;
 
  Vector to = centroid + vec_flux/2.;
 

	
 

	
 
  arrow->setPen( QPen(QColor(par.arrowcolor),par.outlinewidth));
 
  arrow->setZValue(2);
 

	
 
  arrow->setLine( ( (offset[0]+from.x)*factor ),
 
		  ( (offset[1]+from.y)*factor ), 
 
		  ( (offset[0]+to.x)*factor ),
 
		  ( (offset[1]+to.y)*factor ) );
 
  arrow->setZValue(10);
 
  arrow->show();
 
}
 

	
 

	
 
void Cell::DrawWalls(QGraphicsScene *c) const {
 

	
 
  for_each(walls.begin(), walls.end(), bind2nd ( mem_fun ( &Wall::Draw ) , c ) );
 

	
 
  // to see the cells connected the each wall (for debugging), uncomment the following
 
  //for_each(walls.begin(), walls.end(), bind2nd ( mem_fun ( &Wall::ShowStructure ), c ) );
 
}
 

	
 

	
 
void Cell::DrawValence(QGraphicsScene *c) const {
 

	
 
  DrawText(c, QString("%1").arg(walls.size()) );
 
}
 

	
 
#endif // QTGRAPHICS !
src/cellbase.h
Show inline comments
 
@@ -408,55 +408,54 @@ class CellBase :  public QObject, public
 

	
 
  list<Wall *> walls;
 

	
 
  double *chem;
 
  double *new_chem;
 

	
 
  boundary_type boundary;
 
  mutable double area;
 
  double target_area;
 
  double target_length;
 
  double lambda_celllength;
 

	
 
  double stiffness; // stiffness like in Hogeweg (2000)
 

	
 
  bool fixed;
 
  bool pin_fixed;
 
  bool at_boundary; 
 
  bool dead; 
 
  bool flag_for_divide;
 

	
 
  Vector *division_axis;
 
  int cell_type;
 

	
 
  // for length constraint
 
  mutable double intgrl_xx, intgrl_xy, intgrl_yy, intgrl_x, intgrl_y;
 

	
 
  bool source;
 
  Vector cellvec;
 

	
 
  // STATIC DATAMEMBERS MOVED TO CLASS
 
  static CellsStaticDatamembers *static_data_members;
 
  double source_conc;
 
  int source_chem;
 

	
 
  // PRIVATE MEMBER FUNCTIONS
 
  inline static void ClearNCells(void)
 
  {
 
    NCells()=0;
 
  }
 

	
 
  bool marked;
 
  int div_counter;
 
};
 

	
 
ostream &operator<<(ostream &os, const CellBase &v);
 

	
 
inline Vector PINdir(CellBase *here, CellBase *nb, Wall *w)
 
{
 
  nb = NULL; // assignment merely to obviate compilation warning
 
  return w->getTransporter( here, 1)  *  w->getInfluxVector(here);
 
}
 

	
 
#endif
 

	
 
/* finis*/
src/forwardeuler.cpp
Show inline comments
 
@@ -13,99 +13,96 @@
 
 *  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 <cmath>
 
#include <iostream> 
 
#include "forwardeuler.h"
 
#include "warning.h"
 
#include "maxmin.h"
 
#include <string>
 

	
 
using namespace std;
 

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

	
 
// The value Errcon equals (5/Safety) raised to the power (1/PGrow), see use below.
 

	
 
const double ForwardEuler::Safety  = 0.9;
 
const double ForwardEuler::PGrow = -0.2;
 
const double ForwardEuler::Pshrnk = -0.25;
 
const double ForwardEuler::Errcon = 1.89e-4;
 
const double ForwardEuler::Maxstp = 10000000;
 
const double ForwardEuler::Tiny = 1.0e-30;
 

	
 

	
 

	
 
/* User storage for intermediate results. Preset kmax and dxsav in the calling program. If kmax =
 
   0 results are stored at approximate intervals dxsav in the arrays xp[1..kount], yp[1..nvar]
 
   [1..kount], where kount is output by odeint. Defining declarations for these variables, with
 
   memoryallo cations xp[1..kmax] and yp[1..nvar][1..kmax] for the arrays, should be in
 
   the calling program.*/
 

	
 
void ForwardEuler::odeint(double *ystart, int nvar, double x1, double x2, double eps, double h1, double hmin, int *nok, int *nbad)
 
/* Runge-Kutta driver with adaptive stepsize control. Integrate starting values ystart[1..nvar]
 
   from x1 to x2 with accuracy eps, storing intermediate results in global variables. h1 should
 
   be set as a guessed first stepsize, hmin as the minimum allowed stepsize (can be zero). On
 
   output nok and nbad are the number of good and bad (but retried and fixed) steps taken, and
 
   ystart is replaced byv alues at the end of the integration interval. derivs is the user-supplied
 
   routine for calculating the right-hand side derivative, while rkqs is the name of the stepper
 
   routine to be used. */
 
{
 
  static bool warning_issued = false;
 

	
 
  eps = hmin = 0.0; // use assignment merely to obviate compilation warning
 
  nbad = nok = NULL;
 

	
 
  if (!warning_issued) {
 
    cerr << "Using inaccurate method ForwardEuler\n";
 
    warning_issued=true;
 
    //MyWarning::warning("Using inaccurate method ForwardEuler");
 
  }
 
  // N.B. Not for serious use and not fully usage compatible with RungeKutta
 
  // simply for testing API of integrator.
 

	
 
  double *y,*dydx;
 
  y=new double[nvar];
 
  dydx=new double[nvar];
 
  double x=x1;
 

	
 
  for (int i=0;i<nvar;i++) y[i]=ystart[i];
 

	
 
  //if (kmax > 0) xsav=x-dxsav*2.0; //Assures storage of first step.
 

	
 
  dydx=new double[nvar];
 

	
 
  for (int nstp=0;nstp<Maxstp;nstp++) {
 

	
 
    derivs(x,y,dydx);
 

	
 
    if (kmax > 0 && kount < kmax-1) {
 
      xp[kount]=x; //Store intermediate results.
 
      for (int i=0;i<nvar;i++) yp[i][kount]=y[i];
 
      kount++;
 
      //xsav=x;
 
    }
 

	
 
    for (int i=0;i<nvar;i++) {
 
      y[i]=y[i] + h1 * dydx[i];
 
    }
 

	
 
    x = x + h1;
 

	
 
    if ((x-x2)*(x2-x1) >= 0.0) { //Are we done?
 
      goto done;
 
    }
 
  }
 

	
 
 done:
 
  for (int i=0;i<nvar;i++) ystart[i]=y[i];
 
  if (kmax) {
 
    xp[kount]=x; //Save final step.
 
    for (int i=0;i<nvar;i++) yp[i][kount]=y[i];
 

	
 
  }
src/mainbase.h
Show inline comments
 
@@ -57,84 +57,84 @@ class MainBase  {
 
    showwallsp =  false;
 
    showfluxesp = false;
 
    dynamicscellsp = true;
 
    showtooltipsp = false;
 
    hidecellsp = false;
 
  }
 
  virtual ~MainBase() {};
 

	
 
  virtual double TimeStep();
 
  virtual void Init(char *leaffile=0);
 

	
 
  virtual bool ShowCentersP(void) {return showcentersp;}
 
  virtual bool ShowMeshP(void) {return showmeshp; }
 
  virtual bool ShowBorderCellsP(void) {return showbordercellp; }
 
  virtual bool PausedP(void) {return false; }
 
  virtual bool ShowNodeNumbersP(void) {return shownodenumbersp; }
 
  virtual bool ShowCellNumbersP(void) {return showcellnumbersp;}
 
  virtual bool ShowCellAxesP(void) {return showcellsaxesp;}
 
  virtual bool ShowCellStrainP(void) {return showcellstrainp;}
 
  virtual bool MovieFramesP(void) {return movieframesp;}
 
  virtual bool ShowBoundaryOnlyP(void) {return showboundaryonlyp;}
 
  virtual bool ShowToolTipsP(void) {return showtooltipsp;}
 
  virtual bool ShowWallsP(void) {return showwallsp;}
 
  virtual bool ShowApoplastsP(void) { return showapoplastsp;}
 
  virtual bool ShowFluxesP(void) { return showfluxesp; }
 
  virtual bool DynamicCellsP(void) { return dynamicscellsp; }
 
  virtual void FitCanvasToWindow() {};
 
  virtual void FitLeafToCanvas() {};
 
  virtual bool HideCellsP(void) { return hidecellsp; }
 
  virtual void clear(void) {
 
    QList<QGraphicsItem *> list = canvas.items();
 
    QList<QGraphicsItem *>::Iterator it = list.begin();
 
    for (; it != list.end(); ++it) {
 
      if ( *it )
 
	delete *it;
 
    }
 
  };
 
  virtual void XMLReadSettings(xmlNode *settings);
 
  virtual void XMLReadViewport(xmlNode *viewport);
 

	
 
  virtual double getFluxArrowsize(void) { return 10.;}
 

	
 
  void Save(const char *fname, const char *format, int sizex=640, int sizey=480);
 
  void CutSAM(void);
 

	
 
  void Plot(int resize_stride=10);
 

	
 
  virtual void UserMessage(QString message, int timeout = 0) {
 
    timeout = 0; // merely to obviate 'warning unused parameter' message
 
    cerr << message.toAscii().constData() << endl;
 
  }
 

	
 
  Mesh &mesh;
 
  QTransform viewport;
 

	
 
 protected:
 
  QGraphicsScene &canvas;
 
  virtual xmlNode *XMLSettingsTree(void) const;
 
  virtual xmlNode *XMLViewportTree(QTransform &transform) const;
 
  
 
 protected:
 
  bool showcentersp;
 
  bool showmeshp;
 
  bool showbordercellp;
 
  bool shownodenumbersp;
 
  bool showcellnumbersp;
 
  bool showcellsaxesp;
 
  bool showcellstrainp;
 
  bool movieframesp;
 
  bool showboundaryonlyp;
 
  bool showwallsp;
 
  bool showapoplastsp;
 
  bool showfluxesp;
 
  bool dynamicscellsp;
 
  bool showtooltipsp;
 
  bool hidecellsp;
 
};
 

	
 
//#include <qapplication.h>
 
#define TIMESTEP double MainBase::TimeStep(void)
 
#define INIT void MainBase::Init(char *leaffile)
 

	
 
#endif
 

	
 
/* finis */
src/nodeitem.cpp
Show inline comments
 
@@ -8,98 +8,96 @@
 
 *  (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.
 
 *
 
 */
 

	
 
#include <string>
 
#include <QGraphicsScene>
 
#include <QGraphicsItem>
 
#include <QPainter>
 
#include <QStyleOption>
 
#include <Qt>
 
#include "nodeitem.h"
 
#include "parameter.h"
 

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

	
 
extern Parameter par;
 

	
 
NodeItem::NodeItem( Node *n, QGraphicsScene *canvas )
 
  : QGraphicsItem( 0, canvas ), SimItemBase( n, canvas) {
 

	
 
  brush = Qt::darkGray;
 

	
 
  const double mag = par.node_mag;
 
  ellipsesize=QRectF(-1*mag, -1*mag, 2*mag, 2*mag);
 
}
 

	
 
void NodeItem::userMove(double dx, double dy)
 
{
 
  QGraphicsItem::moveBy( dx, dy );
 

	
 
  class_cast<Node *>(obj)->x += (dx/Cell::Magnification());
 
  class_cast<Node *>(obj)->y += (dy/Cell::Magnification());
 
}
 

	
 

	
 

	
 
void NodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
 
{
 
  option = NULL; // use assignment merely to obviate compilation warning
 

	
 
  painter->setBrush(brush);
 
  painter->setPen(Qt::NoPen);
 
  painter->drawEllipse(ellipsesize);
 
}
 

	
 

	
 
QPainterPath NodeItem::shape() const
 
{
 
  QPainterPath path;
 
  path.addEllipse(ellipsesize);
 
  return path;
 
}
 

	
 
QRectF NodeItem::boundingRect() const
 
{
 
  qreal penwidth = 0;// painter->pen()->widthF();
 
  return QRectF(ellipsesize.x()-penwidth/2.,ellipsesize.y()-penwidth/2.,
 
		ellipsesize.width()+penwidth, ellipsesize.height()+penwidth);
 
}
 

	
 
// polymorphic OnClick functions
 
void NodeItem::OnClick(void)
 
{
 
  Node *n = &getNode();
 
  n->toggleBoundary();
 
  setColor();
 
  update();
 
}
 

	
 
void NodeItem::OnClick(const Qt::MouseButton &mb)
 
{
 
  if (mb == Qt::LeftButton) {
 
    Node *n = &getNode();
 
    n->toggleBoundary();
 
    setColor();
 
    update();
 
  }
 
}
 

	
 
void NodeItem::setColor(void)
 
{
 
  static QColor indian_red("IndianRed");
 
  static QColor deep_sky_blue("DeepSkyBlue");
 
  static QColor purple("Purple");
 

	
 
  Node &n=getNode();
 

	
 
  if (n.SamP()) {
src/qcanvasarrow.h
Show inline comments
 
/*
 
 *
 
 *  $Id$
 
 *
 
 *  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.
 
 *
 
 */
 

	
 

	
 
#ifndef _QCANVASARROW_H_
 
#define _QCANVASARROW_H_
 

	
 
#include <QGraphicsScene>
 

	
 
class QGraphicsArrowItem : public QGraphicsLineItem {
 

	
 
 public:
 
 QGraphicsArrowItem(QGraphicsItem *parent, QGraphicsScene *c) : QGraphicsLineItem(parent, c) {};
 

	
 
  void paint ( QPainter *p, const QStyleOptionGraphicsItem *option,
 
	       QWidget *widget ) {
 

	
 
    widget = NULL; //use assignment merely to obviate compilation warning
 
    option = NULL;
 

	
 
    // construct arrow head
 
    QPointF start=line().p1();
 
    QPointF end=line().p2();
 
    QPointF mid=start + (3./4.)*(end-start);
 

	
 
    double vx=end.x()-start.x();
 
    double vy=end.y()-start.y();
 

	
 
    double length = sqrt(vx*vx+vy*vy);
 
    if (length==0) return;
 

	
 
    // perpendicular vector
 
    double px=-vy/length;
 
    double py=vx/length;
 

	
 
    // Arrow head lines go from end point
 
    // to points about 3/4 of the total arrow, extending sideways about 1/4
 
    // of the arrow length.
 

	
 

	
 
    QPointF arwp1 = mid + QPointF( (int)( (length/4.)*px ),
 
				   (int)( (length/4.)*py ) );
 
    QPointF arwp2 = mid - QPointF( (int)( (length/4.)*px ),
 
				   (int)( (length/4.)*py ) );
 

	
 
    p->setPen(pen());
 
    // Draw arrow head
 
    p->drawLine( end, arwp1 );
 
    p->drawLine( end, arwp2 );
 
    // Draw arrow line
 
    p->drawLine( start, end);
 
  }
 
};
 

	
 
#endif
 

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

	
 
#include <string>
 
#include <QBrush>
 
#include "simitembase.h"
 

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

	
 
SimItemBase::SimItemBase( void *v, QGraphicsScene *canvas )
 
{
 
  canvas = NULL; // use assignment merely to obviate compilation warning
 
  obj=v;
 
};
 

	
 
SimItemBase::~SimItemBase(void) {};
 

	
 

	
 
void SimItemBase::userMove(double dx, double dy)
 
{
 
  dx = dy = 0.0; // use assignment merely to obviate compilation warning
 
};
 
void SimItemBase::userMove(double dx, double dy){};
 

	
 
/* finis */
0 comments (0 inline, 0 general)