Changeset - 18e4f7f50259
[Not reviewed]
default
0 14 0
Michael Guravage - 15 years ago 2010-06-15 11:06:33
michael.guravage@cwi.nl
Wrapped diagnostic messages in QDEBUG blocks. Information messages still go to stderr.

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

changed src/ChangeLog
changed src/VirtualLeaf.cpp
changed src/build_models/Makefile
changed src/canvas.cpp
changed src/cell.cpp
changed src/cellbase.h
changed src/data_plot.cpp
changed src/forwardeuler.cpp
changed src/mesh.cpp
changed src/mesh.h
changed src/random.cpp
changed src/wall.cpp
changed src/wallbase.cpp
changed src/wallitem.cpp
14 files changed with 368 insertions and 277 deletions:
0 comments (0 inline, 0 general)
src/ChangeLog
Show inline comments
 
2010-06-15    <guravage@caterpie.sen.cwi.nl>
 

	
 
	* cell.cpp: Wrapped diagnostic output in QDEBUG blocks.
 
	* VirtualLeaf.cpp ditto.
 
	* canvas.cpp ditto.
 
	* cell.cpp ditto.
 
	* cellbase.h
 
	* data_plot.cpp ditto.
 
	* forwardeuler.cpp ditto.
 
	* mesh.cpp ditto.
 
	* mesh.h
 
	* random.cpp ditto.
 
	* wall.cpp ditto.
 
	* wallbase.cpp ditto.
 
	* wallitem.cpp ditto.
 

	
 

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

	
 
	* VirtualLeaf.pro: Removed explicit perl invocation to regerenerate parameter files.
 
	* libplugin.pro: ditto.
 

	
 
2010-06-03    <guravage@caterpie.sen.cwi.nl>
src/VirtualLeaf.cpp
Show inline comments
 
@@ -55,25 +55,24 @@
 
#include "simplugin.h"
 
#include <QPluginLoader>
 
#include <QDir>
 
#include "modelcatalogue.h"
 

	
 
/* #define _xstr_(s) _str_(s)
 
#define _str_(s) #s
 
#include _xstr_(REACTIONS_HEADER)
 
   #define _str_(s) #s
 
   #include _xstr_(REACTIONS_HEADER)
 
*/
 

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

	
 
extern Parameter par;
 

	
 
MainBase *main_window = 0;
 
//double auxin_account = 0.;
 

	
 

	
 

	
 
#ifdef XFIGGRAPHICS
 
#define TIMESTEP double Graphics::TimeStep(void)
 
#endif
 

	
 
class PrintNode {
 
public:
 
@@ -93,13 +92,12 @@ public:
 
      cerr << "Cell " << c.Index() << " is a source cell.\n";
 
      c.SetSource(0,par.source);
 
    } else {
 
      cerr << "Cell " << c.Index() << " is _not_ a source cell.\n";
 
    }
 
  }
 
	
 
};
 

	
 

	
 

	
 
class CellInfo {
 
public:
 
@@ -113,51 +111,43 @@ public:
 
    }
 
    cerr << endl;
 
  }
 
};
 

	
 
double PINSum(Cell &c) {
 
	
 
	return c.Chemical(1) + c.SumTransporters(1);// + c.ReduceCellAndWalls<double>( complex_PijAj );
 
	
 
  return c.Chemical(1) + c.SumTransporters(1);// + c.ReduceCellAndWalls<double>( complex_PijAj );
 
}
 

	
 

	
 
class DrawCell {
 
public:
 
  void operator() (Cell &c,QGraphicsScene &canvas, MainBase &m) const {
 
    if (m.ShowBorderCellsP() || c.Boundary()==Cell::None) {
 
      if (!m.ShowBoundaryOnlyP() && !m.HideCellsP()) 
 
	if (m.ShowToolTipsP()) {
 
	  QString info_string=QString("Cell %1, chemicals: ( %2, %3, %4, %5, %6)\n %7 of PIN1 at walls.\n Area is %8\n PIN sum is %9\n Circumference is %10\n Boundary type is %11").arg(c.Index()).arg(c.Chemical(0)).arg(c.Chemical(1)).arg(c.Chemical(2)).arg(c.Chemical(3)).arg(c.Chemical(4)).arg(c.SumTransporters(1)).arg(c.Area()).arg(PINSum(c)).arg(c.Circumference()).arg(c.BoundaryStr());
 
					
 
	  info_string += "\n" + c.printednodelist();
 
					
 
	  c.Draw(&canvas, info_string);
 
	} else {
 
	  c.Draw(&canvas);
 
	}
 
      if (m.ShowCentersP())
 
	c.DrawCenter(&canvas);
 
    if (m.ShowFluxesP())
 
      if (m.ShowFluxesP())
 
	c.DrawFluxes(&canvas, par.arrowsize);
 
			
 
       }
 
 
 
    }
 
  }
 
	
 
};
 

	
 
Mesh mesh;
 
bool batch=false;
 

	
 

	
 
void MainBase::Plot(int resize_stride) {
 
	
 
  clear();
 
    
 
	
 
  static int count=0;
 
  if (resize_stride) {
 
    if ( !((++count)%resize_stride) ) {
 
      FitLeafToCanvas();
 
    }
 
@@ -173,89 +163,85 @@ void MainBase::Plot(int resize_stride) {
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &Cell::DrawAxis), &canvas ) );
 
	
 
  if (ShowCellStrainP()) 
 
    mesh.LoopCells( bind2nd (mem_fun_ref ( &Cell::DrawStrain), &canvas ) );
 
	
 
  if (ShowWallsP())
 
  
 
    mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::Draw ), &canvas ) );
 
	
 
	if (ShowApoplastsP()) 
 
		mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::DrawApoplast ), &canvas ) );
 
  if (ShowApoplastsP()) 
 
    mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::DrawApoplast ), &canvas ) );
 
 
 
	if (ShowMeshP()) 
 
  if (ShowMeshP()) 
 
    mesh.DrawNodes(&canvas);
 
	
 
  if (ShowBoundaryOnlyP()) 
 
    mesh.DrawBoundary(&canvas);
 

	
 
  
 
	if ( ( batch || MovieFramesP() )) {
 
  if ( ( batch || MovieFramesP() )) {
 
		
 
		static int frame = 0;
 
		// frame numbers are sequential for the most frequently written file type.
 
		// for the less frequently written file type they match the other type
 
		if (!(count%par.storage_stride) )  {
 
    static int frame = 0;
 
    // frame numbers are sequential for the most frequently written file type.
 
    // for the less frequently written file type they match the other type
 
    if (!(count%par.storage_stride) )  {
 
		
 
			stringstream fname;
 
			fname << par.datadir << "/leaf.";
 
			fname.fill('0');
 
			fname.width(6);
 
      stringstream fname;
 
      fname << par.datadir << "/leaf.";
 
      fname.fill('0');
 
      fname.width(6);
 
	
 
			/* 
 
			 fname << frame << ".pdf";
 
			if (par.storage_stride <= par.xml_storage_stride) {
 
				frame++;
 
			}
 
      /* 
 
	 fname << frame << ".pdf";
 
	 if (par.storage_stride <= par.xml_storage_stride) {
 
	 frame++;
 
	 }
 
			
 
			// Write high-res JPG snapshot every plot step
 
			Save(fname.str().c_str(), "PDF");
 
			*/
 
	 // Write high-res JPG snapshot every plot step
 
	 Save(fname.str().c_str(), "PDF");
 
      */
 
			
 
			fname << frame << ".jpg";
 
			if (par.storage_stride <= par.xml_storage_stride) {
 
				frame++;
 
			}
 
      fname << frame << ".jpg";
 
      if (par.storage_stride <= par.xml_storage_stride) {
 
	frame++;
 
      }
 
			
 
			// Write high-res JPG snapshot every plot step
 
			Save(fname.str().c_str(), "JPEG",1024,768);
 
			
 
		}
 
      // Write high-res JPG snapshot every plot step
 
      Save(fname.str().c_str(), "JPEG",1024,768);
 
    }
 
	
 
		if (!(count%par.xml_storage_stride)) {
 
			stringstream fname;
 
			fname << par.datadir << "/leaf.";
 
			fname.fill('0');
 
			fname.width(6);
 
			fname << frame << ".xml";
 
    if (!(count%par.xml_storage_stride)) {
 
      stringstream fname;
 
      fname << par.datadir << "/leaf.";
 
      fname.fill('0');
 
      fname.width(6);
 
      fname << frame << ".xml";
 
	
 
			if (par.xml_storage_stride < par.storage_stride) {
 
				frame++;
 
			}
 
			// Write XML file every ten plot steps
 
			mesh.XMLSave(fname.str().c_str(), XMLSettingsTree());
 
		}
 
		
 
	}
 
      if (par.xml_storage_stride < par.storage_stride) {
 
	frame++;
 
      }
 
      // 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);
 
  //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()));
 
		
 
  } else {
 
	  mesh.StandardInit();
 
    mesh.StandardInit();
 
  }
 
}
 

	
 
TIMESTEP {
 
	
 
  static int i=0;
 
@@ -280,104 +266,99 @@ TIMESTEP {
 
    // 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
 
      mesh.IncreaseCellCapacityIfNecessary();
 
      mesh.DoCellHouseKeeping();
 
      //mesh.LoopCurrentCells(mem_fun(&plugin->CellHouseKeeping)); // this includes cell division
 
				
 
      // Reaction diffusion	
 
		/*CelltoCellTransport *transport_f = &TestPlugin::CelltoCellTransport;
 
      CellReaction *cellreaction_f = new plugin->CellDynamics();
 
      WallReaction *wall_f = new WallDynamics();*/
 
      /*CelltoCellTransport *transport_f = &TestPlugin::CelltoCellTransport;
 
	CellReaction *cellreaction_f = new plugin->CellDynamics();
 
	WallReaction *wall_f = new WallDynamics();*/
 
				
 
      mesh.ReactDiffuse(par.rd_dt);
 
		
 
				
 
      t++;
 
				
 
      Plot(par.resize_stride);
 
		
 
		/*QVector< QPair<double, int> > angles=mesh.VertexAnglesValues();
 
		QString afname=QString("Angles/anglesvalues%1.dat").arg(t,6,10,QChar('0'));
 
		ofstream af(afname.toStdString().c_str());
 
		*/
 
      /*QVector< QPair<double, int> > angles=mesh.VertexAnglesValues();
 
	QString afname=QString("Angles/anglesvalues%1.dat").arg(t,6,10,QChar('0'));
 
	ofstream af(afname.toStdString().c_str());
 
      */
 
		
 
		/*for (QVector< QPair<qreal, int> >::const_iterator v=angles.begin();
 
			 v!=angles.end();
 
			 v++) {
 
			af << v->first << " " << v->second << endl;
 
			}
 
			*/
 
			}
 
      /*for (QVector< QPair<qreal, int> >::const_iterator v=angles.begin();
 
	v!=angles.end();
 
	v++) {
 
	af << v->first << " " << v->second << endl;
 
	}
 
      */
 
    }
 
		
 
			} else {
 
  } else {
 
			
 
  /*  TransportFunction *transport_f = new CelltoCellTransport();
 
    CellReaction *cellreaction_f = new CellDynamics();
 
    WallReaction *wall_f = new WallDynamics();
 
    /*  TransportFunction *transport_f = new CelltoCellTransport();
 
	CellReaction *cellreaction_f = new CellDynamics();
 
	WallReaction *wall_f = new WallDynamics();
 
			
 
    mesh.ReactDiffuse_New(transport_f, cellreaction_f, wall_f, par.rd_dt);*/
 
				mesh.ReactDiffuse(par.rd_dt);
 
	mesh.ReactDiffuse_New(transport_f, cellreaction_f, wall_f, par.rd_dt);*/
 
    mesh.ReactDiffuse(par.rd_dt);
 
		
 
    Plot(par.resize_stride);
 
			
 
  }
 
	
 
	
 

	
 
		
 
		
 
  i++;
 
  return mesh.getTime();
 
		
 
}
 
		
 
		
 
				
 
/* Called if a cell is clicked */
 
void Cell::OnClick(QMouseEvent *e) {
 
  /* #ifdef HAVE_QWT
 
	// Launch DataPlot window
 
	QStringList curvenames;
 
    for (int i=0;i<NChem();i++) {
 
		curvenames += QString("Chem #%1").arg(i);
 
	}
 
    PlotDialog *plot = new PlotDialog((Main *)main_window, QString("Monitor for Cell %1").arg(Index()), curvenames);
 
    QObject::connect(this, SIGNAL(ChemMonValue(double, double *)),
 
                     plot, SLOT(AddValue(double,double *)));
 
#endif
 
	*/
 
	//getMesh().plugin->OnClick(*this);
 
  // Launch DataPlot window
 
  QStringList curvenames;
 
  for (int i=0;i<NChem();i++) {
 
  curvenames += QString("Chem #%1").arg(i);
 
  }
 
  PlotDialog *plot = new PlotDialog((Main *)main_window, QString("Monitor for Cell %1").arg(Index()), curvenames);
 
  QObject::connect(this, SIGNAL(ChemMonValue(double, double *)),
 
  plot, SLOT(AddValue(double,double *)));
 
  #endif
 
  */
 
  //getMesh().plugin->OnClick(*this);
 
}
 
				
 

	
 
/* 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();
 
     }
 
 }
 
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) {
 
					
 
@@ -467,42 +448,42 @@ int main(int argc,char **argv) {
 
    QToolTip::setPalette( tooltippalette );
 

	
 
    QGraphicsScene canvas(0,0,8000,6000);
 

	
 
	  
 
    if (useGUI) {
 
         main_window=new Main(canvas, mesh);
 
      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();
 
      }
 
    } else {
 
        ((Main *)main_window)->showMaximized();
 
      main_window=new MainBase(canvas, mesh);
 

	
 
    }
 
  } else {
 
        main_window=new MainBase(canvas, mesh);
 

	
 
 }
 

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

	
 
	  // Load plugins
 
	  /*QVector<SimPluginInterface *> plugins = LoadPlugins();
 
	  InstallPlugin(plugins[0], main_window);
 
    // Load plugins
 
    /*QVector<SimPluginInterface *> plugins = LoadPlugins();
 
      InstallPlugin(plugins[0], main_window);
 
	  
 
	  cerr << "List of models:" << endl;
 
	  foreach (SimPluginInterface *p, plugins) {
 
		  cerr << p->ModelID().toStdString() << endl;
 
	  }
 
	  */
 
      cerr << "List of models:" << endl;
 
      foreach (SimPluginInterface *p, plugins) {
 
      cerr << p->ModelID().toStdString() << endl;
 
      }
 
    */
 

	
 
	 	  
 
    // Install model or read catalogue of models
 
    ModelCatalogue model_catalogue(&mesh, useGUI?(Main *)main_window:0,modelfile);
 
    if (useGUI)
 
      model_catalogue.PopulateModelMenu();
 
@@ -514,17 +495,14 @@ int main(int argc,char **argv) {
 
	  
 
    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);
 
							
 
@@ -551,8 +529,7 @@ int main(int argc,char **argv) {
 
    } else {
 
      QString qmess(error_message.str().c_str());
 
      QMessageBox::critical(0, "I/O Error", qmess );
 
      abort();
 
    }
 
  }
 
					
 
}
src/build_models/Makefile
Show inline comments
 
# $Id$
 

	
 
QMAKE = qmake
 

	
 
all: plugin_auxingrowth plugin_leaf plugin_meinhardt plugin_test
 
all: plugin_auxingrowth plugin_meinhardt plugin_test
 

	
 
plugin_auxingrowth: Makefile.plugin_auxingrowth
 
	make -f Makefile.plugin_auxingrowth
 

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

	
 
plugin_leaf: Makefile.plugin_leaf
 
	make -f Makefile.plugin_leaf
 

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

	
 
plugin_meinhardt: Makefile.plugin_meinhardt
 
	make -f Makefile.plugin_meinhardt
 

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

	
 
@@ -27,15 +21,13 @@ plugin_test: Makefile.plugin_test
 

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

	
 
clean:
 
	make -f Makefile.plugin_auxingrowth clean
 
	make -f Makefile.plugin_leaf clean
 
	make -f Makefile.plugin_meinhardt clean
 
	make -f Makefile.plugin_test clean
 
	touch plugin_auxingrowth.pro
 
	touch plugin_leaf.pro
 
	touch plugin_meinhardt.pro
 
	touch plugin_test.pro
 

	
 
#finis
src/canvas.cpp
Show inline comments
 
@@ -40,12 +40,13 @@
 
#include <qpixmap.h>
 
#include <qfile.h>
 
#include <qdir.h>
 
#include <q3filedialog.h>
 
#include <QGraphicsItem>
 
#include <QList>
 
#include <QDebug>
 

	
 
#include <set>
 

	
 
//Added by qt3to4:
 
#include <Q3ValueList>
 
#include <Q3PopupMenu>
 
@@ -225,14 +226,16 @@ void FigureEditor::mousePressEvent(QMous
 
    for (QList<QGraphicsItem *>::Iterator it=l.begin(); it!=l.end(); ++it) {
 
      /*if ( (*it)->rtti() == imageRTTI ) {
 
	ImageItem *item= (ImageItem*)(*it);
 
	if ( !item->hit( p ) )
 
	continue;
 
	}*/
 
      cerr << typeid(**it).name() << endl;
 
    
 
      #ifdef QDEBUG
 
      qDebug() << typeid(**it).name() << endl;
 
      #endif QDEBUG
 

	
 
      if ( !strcmp(typeid(**it).name(),"8NodeItem")) {
 
	//moving = dynamic_cast<NodeItem*>(*it);
 
	//moving = *it;
 
	//moving_start = p;
 
      
 
	stringstream data_strstream;
 
@@ -345,26 +348,29 @@ void FigureEditor::mouseReleaseEvent(QMo
 
  
 
  emit MouseReleased();
 
  // intersection line for leaf was finished now.
 
  
 
  if (e->button()==Qt::LeftButton) { 
 
    if (intersection_line ) {
 
    
 
      cerr << "Trying to cut leaf\n";
 
      #ifdef QDEBUG
 
      qDebug() << "Trying to cut leaf" << endl;
 
      #endif
 
      QPointF sp = intersection_line -> line().p1(); // startpoint
 
      //QPointF ep = matrix().inverted().map(e->pos()); // endpoint
 
      QPointF ep = mapToScene(e->pos());
 

	
 
      intersection_line -> setLine( QLineF(sp, ep) ); 
 
      intersection_line -> show();
 

	
 
      vector <CellItem *> intersected_cells = getIntersectedCells();
 
    
 
      // no cells selected, do nothing
 
      if (intersected_cells.size()==0) {
 
	cerr << "No cells detected :-( \n";
 
        #ifdef QDEBUG
 
	qDebug() << "No cells detected :-(" << endl;
 
	#endif
 
	return;
 
      }
 
      
 
    
 
      Vector startpoint = Vector(sp.x(), sp.y()) / Cell::Factor() - Cell::Offset();
 
      Vector endpoint = Vector(ep.x(), ep.y()) / Cell::Factor() - Cell::Offset();
 
@@ -385,20 +391,26 @@ void FigureEditor::mouseReleaseEvent(QMo
 
	// next division is called?  so check for it?  let's find a way
 
	// to do this later. Note that this functionality currently
 
	// might result in a segmentation fault for users who are
 
	// quickly dragging and releasing division lines...
 
	scene()->update();
 
	
 
	cerr << "Dividing Cell " << c.Index() << endl;
 
	#ifdef QDEBUG
 
	qDebug() << "Dividing Cell " << c.Index() << endl;
 
	#endif
 

	
 
	c.DivideOverGivenLine( startpoint, endpoint, true, node_set);
 
      }
 
      
 
      node_set->CleanUp();
 
      mesh.AddNodeSet(node_set);
 
      
 
      cerr << "Done DivideOverGivenLine\n";
 
      #ifdef QDEBUG
 
      qDebug() << "Done DivideOverGivenLine" << endl;
 
      #endif
 

	
 
      mesh.TestIllegalWalls();
 
      // Do the actual cutting and removing
 
      if (intersected_cells.size()) {
 
	//      Mesh &m(intersected_cells.front()->getCell().getMesh());
 
	mesh.CutAwayBelowLine( startpoint, endpoint ); 
 
	
 
@@ -422,26 +434,33 @@ void FigureEditor::mouseReleaseEvent(QMo
 
	      c++) {
 
	  (*c)->SetBoundary(Cell::SAM);
 
	}
 

	
 

	
 

	
 
	cerr << "Done CutAwayBelowLine\n";
 
	#ifdef QDEBUG
 
	qDebug() << "Done CutAwayBelowLine" << endl;
 
	#endif
 
	mesh.TestIllegalWalls();
 
	mesh.RepairBoundaryPolygon();
 
	cerr << "Done RepairBoundaryPolygon\n";
 
	#ifdef QDEBUG
 
	qDebug() << "Done RepairBoundaryPolygon" << endl;
 
	#endif
 
	mesh.TestIllegalWalls();
 
	mesh.CleanUpWalls();
 
	cerr << "Done CleanUpWalls\n";
 
	#ifdef QDEBUG
 
	qDebug() << "Done CleanUpWalls" << endl;
 
	#endif
 
	mesh.TestIllegalWalls();
 
      }
 
      
 
      dynamic_cast<Main *>(parent())->Plot();
 
      
 
      cerr << "NodeSet of cutting line: " << *node_set << endl;
 

	
 
        #ifdef QDEBUG
 
	qDebug() << "NodeSet of cutting line: " << *node_set << endl;
 
	#endif
 
    }
 
  } else 
 
    if (e->button()==Qt::RightButton) {
 
      
 
      if (intersection_line /* && !angle_line*/) {
 
	
 
@@ -466,16 +485,21 @@ void FigureEditor::mouseReleaseEvent(QMo
 
vector <CellItem *> FigureEditor::getIntersectedCells(void) { 
 
  
 
  vector <CellItem *> colliding_cells;
 
  
 
  QList<QGraphicsItem *> l = intersection_line->collidingItems( );
 
  
 
  cerr << "l.size() = " << l.size() << endl;
 
  #ifdef QDEBUG
 
  qDebug() <<  "l.size() = " << l.size() << endl;
 
  #endif
 

	
 
  for (QList<QGraphicsItem *>::Iterator it=l.begin(); it!=l.end(); ++it) {
 
    
 
    cerr << typeid(**it).name() << endl;
 
    #ifdef QDEBUG
 
    qDebug() << typeid(**it).name() << endl;
 
    #endif
 
    
 
    if ( !strcmp(typeid(**it).name(),"8CellItem") ) {
 
      
 
      colliding_cells.push_back(dynamic_cast<CellItem *>(*it));
 
      
 
    }
 
@@ -531,13 +555,17 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q
 
  MainBase(c,m),
 
  mesh(m)
 
	   
 
	  //canvas(c)
 
{
 
  editor = new FigureEditor(canvas,mesh, this);
 
  cerr << "Interactive = " << editor->isEnabled();
 

	
 
  #ifdef QDEBUG
 
  qDebug() << "Interactive = " << editor->isEnabled();
 
  #endif
 

	
 
  working_dir = 0;
 
  QObject::connect( editor, SIGNAL(MousePressed()), this, SLOT(PauseIfRunning()));
 
  QObject::connect( editor, SIGNAL(MouseReleased()), this, SLOT(ContIfRunning()));
 
  QMenuBar* menu = menuBar();
 
  
 
  Q3PopupMenu* file = new Q3PopupMenu( menu );
 
@@ -588,15 +616,15 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q
 
	com_id = view->insertItem("Show cell &centers", this, SLOT(toggleShowCellCenters()));
 
  view->setItemChecked(com_id, FALSE);
 
  //view->insertItem("Cell monitor", this, SLOT(cellmonitor()));
 
  mesh_id = view->insertItem("Show &nodes", this, SLOT(toggleShowNodes()), Qt::CTRL+Qt::SHIFT+Qt::Key_N);
 
  view->setItemChecked(mesh_id, TRUE);
 
  node_number_id = view->insertItem("Show node numbers", this, SLOT(toggleNodeNumbers()), Qt::CTRL+Qt::SHIFT+Qt::Key_M);
 
  view->setItemChecked(node_number_id, TRUE);
 
  view->setItemChecked(node_number_id, FALSE);
 
  cell_number_id = view->insertItem("Show cell numbers", this, SLOT(toggleCellNumbers()));
 
  view->setItemChecked(cell_number_id, TRUE);
 
  view->setItemChecked(cell_number_id, FALSE);
 
  hide_cells_id = view->insertItem("Hide cells", this, SLOT(toggleHideCells()));
 
  view->setItemChecked(hide_cells_id, FALSE);
 
  border_id = view->insertItem("Show &border cells", this, SLOT(toggleShowBorderCells()));
 
  view->setItemChecked(border_id, FALSE);
 
  cell_axes_id = view->insertItem("Show cell &axes", this, SLOT(toggleCellAxes()));
 
  cell_strain_id = view->insertItem("Show cell &strain", this, SLOT(toggleCellStrain()));
 
@@ -908,13 +936,15 @@ void Main::readPrevStateXML() {
 

	
 
int Main::readStateXML(const char *filename, bool geometry, bool pars, bool simtime) {
 
 
 
  try {
 
    xmlNode *settings;
 
    mesh.XMLRead((const char *)filename, &settings, geometry, pars, simtime);
 
	cerr << "Reading done.\n";
 
    #ifdef QDEBUG
 
    qDebug() << "Reading done."<< endl;
 
    #endif
 
    XMLReadSettings(settings);
 
    xmlFree(settings);
 
    Cell::SetMagnification(1);
 
    Cell::setOffset(0,0);
 
    
 
    FitLeafToCanvas();
 
@@ -924,13 +954,15 @@ int Main::readStateXML(const char *filen
 
    Plot();
 
    QString status_message = QString("Succesfully read leaf from file %1. Time is %2 h.\n").arg(currentFile).arg(mesh.getTimeHours().c_str());
 
    cerr << status_message.toStdString() << endl;
 
	setCaption(caption_with_file.arg(filename));
 
    statusBar()->message(status_message);
 
    emit ParsChanged();
 
	cerr << "Done. Returning 0.\n";
 
    #ifdef QDEBUG
 
    qDebug() << "Done. Returning 0." << endl;
 
    #endif
 
    return 0;
 
  } catch (const char *error_message) {
 
    QMessageBox mb( "Read leaf from XML file",
 
		    QString(error_message),
 
		    QMessageBox::Critical,
 
		    QMessageBox::Ok | QMessageBox::Default,
 
@@ -1025,13 +1057,15 @@ void Main::readFirstStateXML() {
 

	
 
void Main::readStateXML() {
 

	
 
  //  extern Mesh mesh;
 

	
 
  stopSimulation();
 
  cerr << "Trying to open an OptionFileDialog\n";
 
  #ifdef QDEBUG
 
  qDebug() << "Trying to open an OptionFileDialog" << endl;
 
  #endif
 
  OptionFileDialog *fd = new OptionFileDialog( this, "read dialog", TRUE );
 
  fd->setMode( OptionFileDialog::ExistingFile );
 
  fd->setFilter( "XML files (*.xml)");
 
  if (working_dir) {
 
    fd->setDir(*working_dir);
 
  }
 
@@ -1201,25 +1235,25 @@ void Main::toggleHideCells(void) {
 
    running = true;
 
  }
 

	
 
  void Main::stopSimulation(void) {
 
    //run->setItemChecked(paused_id, true);
 
    timer->stop();
 
    cerr << "Stopping simulation\n";
 
    cerr << "Stopping simulation" << endl;
 
    statusBar()->message("Simulation paused");
 
    running = false;
 
  }
 

	
 
  void Main::togglePaused()
 
  {
 
    bool s = run->isItemChecked(paused_id);
 
    if (s) {
 
      cerr << "Calling start simulation\n";
 
      cerr << "Calling start simulation" << endl;
 
      startSimulation();
 
    } else {
 
      cerr << "Calling stop simulation\n";
 
      cerr << "Calling stop simulation" << endl;
 
      stopSimulation();
 
    }
 
  }
 

	
 
  void Main::setFluxArrowSize(int size) {
 
  
 
@@ -1270,20 +1304,24 @@ void Main::toggleHideCells(void) {
 
    
 
    if ( printer->setup(this) ) {
 
    
 
      //    extern Mesh mesh;
 
      Vector bbll,bbur;
 
      mesh.BoundingBox(bbll,bbur);
 
      cerr << "bbll = " << bbll << endl;
 
      cerr << "bbur = " << bbur << endl;
 

	
 
      #ifdef QDEBUG
 
      qDebug() << "bbll = " << bbll << endl;
 
      qDebug() << "bbur = " << bbur << endl;
 
      #endif
 
      double cw = (bbur.x - bbll.x);
 
      double ch = (bbur.y - bbll.y);
 
      QPainter pp(printer);
 
      QRect vp=pp.viewport();
 
      cerr << "Paper width = " << vp.width() << " x " << vp.height() << endl;
 
    
 
      #ifdef QDEBUG
 
      qDebug() << "Paper width = " << vp.width() << " x " << vp.height() << endl;
 
      #endif
 

	
 
      // Note that Cell is also translated...
 
      pp.translate(-bbur.x,-bbur.y);
 
      if (cw>ch) {
 
	pp.scale(vp.width()/(2*cw*Cell::Magnification()), vp.width()/(2*cw*Cell::Magnification()));
 
      } else {
 
@@ -1313,13 +1351,13 @@ void Main::toggleHideCells(void) {
 
			       this,
 
			       tr("Restart simulation?"),
 
			       tr("Restart simulation.\n"
 
				  "Are you sure?"),
 
							   QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::Yes ) {
 

	
 
		cerr << "Restarting simulation\n";
 
      cerr << "Restarting simulation" << endl;
 
      //    extern Mesh mesh;
 
      mesh.Clear();
 
      Init();
 
		Plot();
 
		editor->FullRedraw();
 
    } 
 
@@ -1394,19 +1432,21 @@ void Main::toggleHideCells(void) {
 
void Main::FitCanvasToWindow(void) {
 
  
 
  double scale_factor_x = (double)editor->width()/(double)canvas.width();
 
  double scale_factor_y = (double)editor->height()/(double)canvas.height();
 
  double scale_factor = scale_factor_x > scale_factor_y ? scale_factor_x : scale_factor_y;
 
  QMatrix m = editor->matrix();
 
  
 
  cerr << "editor->width() = " << editor->width() << endl;
 
  cerr << "editor->height() = " << editor->height() << endl;
 

	
 
  #ifdef QDEBUG  
 
  qDebug() << "editor->width() = " << editor->width() << endl;
 
  qDebug() << "editor->height() = " << editor->height() << endl;
 
  
 
  cerr << "scale_factor = " << scale_factor << endl;
 
  cerr << "scale_factor_x = " << scale_factor_x << endl;
 
  cerr << "scale_factor_y = " << scale_factor_y << endl;
 
  qDebug() << "scale_factor = " << scale_factor << endl;
 
  qDebug() << "scale_factor_x = " << scale_factor_x << endl;
 
  qDebug() << "scale_factor_y = " << scale_factor_y << endl;
 
  #endif
 
  m.scale( scale_factor, scale_factor );
 
  editor->setMatrix( m );
 
  editor->show();
 
}
 

	
 
  void Main::PauseIfRunning(void) {
src/cell.cpp
Show inline comments
 
@@ -16,24 +16,25 @@
 
 *  along with the Virtual Leaf.  If not, see <http://www.gnu.org/licenses/>.
 
 *
 
 *  Copyright 2010 Roeland Merks.
 
 *
 
 */
 

	
 
#include <QDebug>
 

	
 
#include <string>
 
#include "cell.h"
 
#include "node.h"
 
#include "mesh.h"
 
#include "tiny.h"
 
#include "nodeset.h"
 
#include "cellitem.h"
 
#include "nodeitem.h"
 
#include "qcanvasarrow.h"
 
#include "parameter.h"
 

	
 
#include <QDebug>
 

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

	
 
extern Parameter par;
 

	
 
double Cell::factor=1.;
 
@@ -108,19 +109,21 @@ double Cell::MeanArea(void) {
 
}
 

	
 

	
 
void Cell::Apoptose(void) {
 
	
 
	// First kill walls
 
	cerr << "This is cell " << Index() << "\n";
 
	cerr << "Number of walls: " << walls.size() << endl;
 
	
 
	for (list<Wall *>::iterator w=walls.begin();
 
		 w!=walls.end();
 
		 w++) {
 
		cerr << "Before apoptosis, wall " << (*w)->Index() << " says: c1 = " << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl;
 
        #ifdef QDEBUG
 
        qDebug() << "This is cell " << Index() << endl;
 
	qDebug() << "Number of walls: " << walls.size() << endl;
 
	#endif
 
	for (list<Wall *>::iterator w=walls.begin(); w!=walls.end(); w++) {
 
             #ifdef QDEBUG
 
	     qDebug() << "Before apoptosis, wall " << (*w)->Index() << " says: c1 = "
 
		      << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl;
 
             #endif
 
	}
 
	for (list<Wall *>::iterator w=walls.begin();
 
		 w!=walls.end();
 
		 w++) {
 
		
 
		bool illegal_flag = false;
 
@@ -137,31 +140,41 @@ void Cell::Apoptose(void) {
 
			(*w)->n2 = n1;
 
			
 
		} else {
 
			(*w)->c2 = m->boundary_polygon;
 
		}
 
		
 
		#ifdef QDEBUG
 
		if (illegal_flag && (*w)->c1==(*w)->c2) {
 
			cerr << "I created an illegal wall.\n";
 
		  qDebug() << "I created an illegal wall." << endl;
 
		}
 
		#endif
 

	
 
		if ( ((*w)->N1()->DeadP() || (*w)->N2()->DeadP()) ||
 
			((*w)->C1() == (*w)->C2() ) ){
 
			// kill wall
 
			cerr << "Killing wall.\n";
 
		        #ifdef QDEBUG
 
		        qDebug() << "Killing wall." << endl;
 
			#endif
 
			(*w)->Kill();
 

	
 
			#ifdef QDEBUG
 
			if ((*w)) {
 
				cerr << "Wall " << (*w)->Index() << " says: c1 = " << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl;
 
			  qDebug() << "Wall " << (*w)->Index() << " says: c1 = " 
 
				   << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl;
 
			}
 
			#endif
 
			(*w)=0;
 
		} else {
 
			cerr << "Not killing wall.\n";
 
			cerr << "Wall " << (*w)->Index() << " says: c1 = " << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl;
 
		        #ifdef QDEBUG
 
		        qDebug() << "Not killing wall." << endl;
 
			qDebug() << "Wall " << (*w)->Index() << " says: c1 = " 
 
				 << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl;
 
                        #endif
 
		}
 
		
 
		
 
		
 
	}
 
	walls.remove(0);
 
	
 
	// Unregister me from my nodes, and delete the node if it no longer belongs to any cells
 
	list<Node *> superfluous_nodes;
 
	for (list<Node *>::iterator n=nodes.begin();
 
@@ -325,13 +338,15 @@ bool Cell::DivideOverGivenLine(const Vec
 
	
 
	
 
	
 
	// check each edge for intersection with the line
 
	ItList new_node_locations;
 
	
 
	cerr << "Cell " << Index() << " is doing DivideOverGivenLine \n";
 
	#ifdef QDEBUG
 
	qDebug() << "Cell " << Index() << " is doing DivideOverGivenLine" << endl;
 
	#endif
 
	for (list<Node *>::iterator i=nodes.begin();
 
		 i!=nodes.end();
 
		 i++) {
 
		
 
		Vector v3 = *(*i);
 
		list<Node *>::iterator nb=i;
 
@@ -358,35 +373,37 @@ bool Cell::DivideOverGivenLine(const Vec
 
			// yes, intersection detected. Push the location to the list of iterators
 
			new_node_locations.push_back(nb);
 
			
 
		} 
 
	}
 
	
 
        #ifdef QDEBUG
 
	if (new_node_locations.size()<2) { 
 
		
 
		cerr << "Line does not intersect with two edges of Cell " << Index() << endl;
 
		cerr << "new_node_locations.size() = " << new_node_locations.size() << endl;
 
		return false;
 
	  qDebug() << "Line does not intersect with two edges of Cell " << Index() << endl;
 
	  qDebug() << "new_node_locations.size() = " << new_node_locations.size() << endl;
 
	  return false;
 
	}
 
	
 
	ItList::iterator i = new_node_locations.begin();
 
	list< Node *>::iterator j;
 
	cerr << "-------------------------------\n";
 
	cerr << "Location of new nodes: " << (**i)->Index() << " and ";
 
	qDebug() << "-------------------------------" << endl;
 
	qDebug() << "Location of new nodes: " << (**i)->Index() << " and ";
 

	
 
	++i;
 
	j = *i; 
 
	if (j==nodes.begin()) j=nodes.end(); j--;
 
	
 
	cerr << (*j)->Index() << endl;
 
	cerr << "-------------------------------\n";
 
	qDebug() << (*j)->Index() << endl;
 
	qDebug() << "-------------------------------" << endl;
 
    
 
	if ( **new_node_locations.begin() == *j ) {
 
		cerr << "Rejecting proposed division (cutting off zero area).\n";
 
	  qDebug() << "Rejecting proposed division (cutting off zero area)." << endl;
 
		return false;
 
	}
 
	
 
	#endif
 

	
 
	DivideWalls(new_node_locations, v1, v2, fix_cellwall, node_set);
 
	
 
	return true;
 
	
 
}
 

	
 
@@ -448,15 +465,18 @@ void Cell::DivideWalls(ItList new_node_l
 
		// again. We can do this here because it is the last cell added.
 
		// Never, ever try to fully erase a cell elsewhere, because we
 
		// make heavy use of cell indices in this project; if you erase a
 
		// Cell somewhere in the middle of Mesh::Cells the indices will
 
		// get totally messed up...! (e.g. the indices used in Nodes::cells)
 
		
 
		cerr << "new_node_locations.size() = " << new_node_locations.size() <<endl;
 
		cerr << "daughter->index = " << daughter->index << endl;
 
		cerr << "cells.size() = " << m->cells.size() << endl;
 
		#ifdef QDEBUG
 
		qDebug() << "new_node_locations.size() = " << new_node_locations.size() <<endl;
 
		qDebug() << "daughter->index = " << daughter->index << endl;
 
		qDebug() << "cells.size() = " << m->cells.size() << endl;
 
		#endif
 

	
 
		m->cells.pop_back();
 
		Cell::NCells()--;
 
		m->shuffled_cells.pop_back();
 
		return;
 
	}
 
	
 
@@ -526,13 +546,13 @@ void Cell::DivideWalls(ItList new_node_l
 
		
 
		double elem_length = ( (*(**i)) - (*(*nb)) ).Norm();
 
		if ( ( *(**i) - *n ).Norm() < collapse_node_threshold  * elem_length ) {
 
			new_node_flag[nnc]=1;
 
			new_node[nnc] = *(**i);
 
			new_node_ind[nnc] = **i;
 
			//cerr << **i << "\n" ;
 
			//cerr << **i << endl ;
 
		} else 
 
			if ( (*(*nb) - *n).Norm() < collapse_node_threshold * elem_length ) {
 
				new_node_flag[nnc]=2;
 
				new_node[nnc] = *(*nb);
 
				new_node_ind[nnc] = *nb;
 
			} else {
 
@@ -782,16 +802,17 @@ void Cell::DivideWalls(ItList new_node_l
 
				// Find wall between this cell and neighbor cell
 
				w = find_if( start_search, walls.end(), bind2nd (mem_fun( &Wall::is_wall_of_cell_p ), neighbor_cell ) );
 
				start_search = w; start_search++; // continue searching at next element
 
			} while ( w!=walls.end() && !(*w)->IntersectsWithDivisionPlaneP( from, to ) ); // go on until we find the right one.
 
			
 
			if (w == walls.end()) {
 
				cerr << "Whoops, wall element not found...!\n";
 
				cerr << "Cell ID: " << neighbor_cell->Index() << endl;
 
				cerr << "My cell ID: " << Index() << endl;
 
				
 
			        #ifdef QDEBUG
 
			  qDebug() << "Whoops, wall element not found...!" << endl;
 
			        qDebug() << "Cell ID: " << neighbor_cell->Index() << endl;
 
				qDebug() << "My cell ID: " << Index() << endl;
 
                                #endif
 
			} else {
 
				
 
				// 2. Split it up, if we should (sometimes, the new node coincides with an existing node so
 
				// we should not split up the Wall)
 
				
 
				if (new_node_ind[i]!=(*w)->n1 && new_node_ind[i]!=(*w)->n2) {
 
@@ -892,13 +913,15 @@ void Cell::DivideWalls(ItList new_node_l
 
			// and remove them)
 
			list<Neighbor>::iterator neighb_with_this_cell=
 
			find_if((*i)->owners.begin(),
 
					(*i)->owners.end(),
 
				bind2nd(mem_fun_ref( &Neighbor::CellEquals ),this->Index() )  );
 
			if (neighb_with_this_cell==(*i)->owners.end()) {
 
				cerr << "not found\n";
 
			        #ifdef QDEBUG
 
			  qDebug() << "not found" << endl;
 
                                #endif
 
				abort();
 
			}
 
			
 
			(*i)->owners.erase(neighb_with_this_cell);
 
			
 
			daughter->nodes.push_back( *i );
 
@@ -1616,15 +1639,17 @@ void Cell::Flux(double *flux, double *D)
 
		
 
		
 
		// flux depends on edge length and concentration difference
 
		for (int c=0;c<NChem();c++) {
 
			double phi = (*i)->length * ( D[c] ) * ( ((Cell *)(*i)->c2)->chem[c] - chem[c] );
 
			
 
			#ifdef QDEBUG
 
			if ((*i)->c1!=this) {
 
				cerr << "Warning, bad cells boundary: " << (*i)->c1->Index() << ", " << index << endl;
 
			  qDebug() << "Warning, bad cells boundary: " << (*i)->c1->Index() << ", " << index << endl;
 
			}
 
			#endif
 
			
 
			flux[c] += phi;
 
		}    
 
	}
 
	
 
}
 
@@ -1637,13 +1662,15 @@ void Cell::Flux(double *flux, double *D)
 

	
 
void Cell::Draw(QGraphicsScene *c, QString tooltip) {
 
	
 
	// Draw the cell on a QCanvas object
 
	
 
	if (DeadP()) { 
 
		cerr << "Cell " << index << " not drawn, because dead.\n";
 
	        #ifdef QDEBUG
 
	  qDebug() << "Cell " << index << " not drawn, because dead." << endl;
 
		#endif
 
		return;
 
	}
 
	
 
	CellItem* p = new CellItem(this, c);
 
	
 
	QPolygonF pa(nodes.size());
 
@@ -1937,17 +1964,18 @@ void Cell::SetWallLengths(void) {
 

	
 

	
 
//! Add Wall w to the list of Walls
 
void Cell::AddWall( Wall *w ) {
 
	
 
	// if necessary, we could try later inserting it at the correct position
 
        #ifdef QDEBUG
 
	if (w->c1 == w->c2 ){
 
		
 
		cerr << "Wall between identical cells: " << w->c1->Index()<< endl;
 
		
 
	  qDebug() << "Wall between identical cells: " << w->c1->Index()<< endl;
 
	}
 
	#endif
 

	
 
	// Add Wall to Cell's list
 
	walls.push_back( w );
 
	
 
	// Add wall to Mesh's list if it isn't there yet
 
	
 
	if (find (
src/cellbase.h
Show inline comments
 
@@ -62,16 +62,20 @@ class CellsStaticDatamembers {
 
	
 
public:
 
	CellsStaticDatamembers(void) {
 
		ncells = 0;
 
		nchem = 0;
 
		base_area = 0.;
 
		cerr << "Constructor of CellsStaticDatamembers\n";
 
                #ifdef QDEBUG
 
		qDebug() << "Constructor of CellsStaticDatamembers" << endl;
 
		#endif
 
	}
 
	~CellsStaticDatamembers() {
 
		cerr << "Oops! Desctructor of CellsStaticDatamembers called\n";
 
                #ifdef QDEBUG
 
	        qDebug() << "Oops! Desctructor of CellsStaticDatamembers called" << endl;
 
                #endif
 
	}
 
	int ncells;
 
	int nchem;
 
	double base_area;
 

	
 

	
src/data_plot.cpp
Show inline comments
 
@@ -29,17 +29,19 @@
 
#include <qwt_legend.h>
 
#include <qwt_scale_draw.h>
 
#include <qwt_math.h>
 
#include <QDialog>
 
#include <QString>
 
#include <QStringList>
 
#include <QDebug>
 
#include <iostream>
 

	
 
#include "data_plot.h"
 

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

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

	
 
//
 
//  Initialize main window
 
//
 
DataPlot::DataPlot(QWidget *parent, const QString title, const QStringList curvenames ):
 
  QwtPlot(parent),
 
@@ -87,13 +89,17 @@ DataPlot::DataPlot(QWidget *parent, cons
 
  for (int i=0;i<ncurves;i++) {
 

	
 
    curves[i].setTitle(curvenames[i]);
 
    curves[i].attach(this);
 
    curves[i].setPen(QPen(curvecolors[i]));
 
    QString col(curvecolors[i]);
 
    std::cerr << "Curvecolor " << col.toStdString() << std::endl;
 

	
 
    #ifdef QDEBUG
 
    qDebug() << "Curvecolor " << col.toStdString() << endl;
 
    #endif
 

	
 
    curves[i].setRawData(d_t, d_x[i], PLOT_SIZE);
 
  }
 
    
 
  // Axis 
 
  setAxisTitle(QwtPlot::xBottom, "Time");
 

	
src/forwardeuler.cpp
Show inline comments
 
@@ -23,13 +23,15 @@
 
#include <iostream> 
 
#include "forwardeuler.h"
 
#include "warning.h"
 
#include "maxmin.h"
 
#include <string>
 

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

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

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

	
 
/* static float maxarg1,maxarg2;
 
   #define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?	\
 
   (maxarg1) : (maxarg2))
 
@@ -63,13 +65,13 @@ void ForwardEuler::odeint(double *ystart
 
  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;
 
  if (!warning_issued) {
 
    std::cerr << "Using inaccurate method ForwardEuler\n";
 
    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.
 
  
src/mesh.cpp
Show inline comments
 
@@ -391,15 +391,16 @@ Cell &Mesh::LeafPrimordium(int nnodes, d
 
  AddNodeToCell(petiole,
 
		n4,
 
		n3,
 
		n1);
 

	
 
  
 
  
 
  cerr << circle << endl;
 
  cerr << petiole << endl;
 
  #ifdef QDEBUG  
 
  qDebug() << circle << endl;
 
  qDebug() << petiole << endl;
 
  #endif
 
  
 
  AddNodeToCell(boundary_polygon, *it_n1, 
 
		n4,
 
		*it_n2 + ((*it_n1-*it_n2)+1)%nnodes); // is this gonna work?
 
  
 
  (*it_n1)->boundary=true;
 
@@ -575,16 +576,18 @@ void Mesh::Clear(void) {
 
	 shuffled_cells.clear();
 
	 shuffled_nodes.clear();
 
	 node_insertion_queue.empty();
 
	 
 
	 cerr << "Meshed cleared: cells: " << cells.size() << ", nodes: " << nodes.size() << endl;
 
	 */
 
	
 
	cerr << "cells.size() = " << cells.size() << endl;
 
	cerr << "walls.size() = " << walls.size() << endl;
 
	cerr << "nodes.size() = " << nodes.size() << endl;
 

	
 
	#ifdef QDEBUG
 
	qDebug() << "cells.size() = " << cells.size() << endl;
 
	qDebug << "walls.size() = " << walls.size() << endl;
 
	qDebug << "nodes.size() = " << nodes.size() << endl;
 
        #endif
 
}
 

	
 
double Mesh::DisplaceNodes(void) {
 

	
 
  MyUrand r(shuffled_nodes.size());
 
  random_shuffle(shuffled_nodes.begin(),shuffled_nodes.end(),r);
 
@@ -1442,14 +1445,16 @@ void Mesh::CleanUpCellNodeLists(void) {
 
void Mesh::CutAwayBelowLine( Vector startpoint, Vector endpoint) {
 
  
 
  // Kills all cells below the line startpoint -> endpoint
 
  
 
  Vector perp = (endpoint-startpoint).Perp2D().Normalised();
 
  
 
  
 
  cerr << "Before Apoptose\n";
 
  #ifdef QDEBUG
 
  qDebug() << "Before Apoptose" << endl;
 
  #endif
 

	
 
  TestIllegalWalls();
 
  for (vector<Cell *>::iterator i=cells.begin();
 
       i!=cells.end();
 
       i++) {
 
    
 
    // do some vector geometry to check whether the cell is below the cutting line
 
@@ -1458,13 +1463,15 @@ void Mesh::CutAwayBelowLine( Vector star
 
    if ( InnerProduct(perp, cellvec) < 0 ) {
 
      // remove those cells
 
      (*i)->Apoptose();
 
    }
 
  }
 

	
 
  cerr << "Before CleanUpCellNodeLists\n";
 
  #ifdef QDEBUG
 
  qDebug() << "Before CleanUpCellNodeLists" << endl;
 
  #endif
 
  TestIllegalWalls();
 
  
 
  CleanUpCellNodeLists();
 

	
 
}
 

	
 
@@ -1489,13 +1496,15 @@ void Mesh::CutAwaySAM(void) {
 
void Mesh::TestIllegalWalls(void) {
 

	
 
  for (list<Wall *>::iterator w = walls.begin();
 
       w!=walls.end();
 
       w++) {
 
    if ((*w)->IllegalP() ) {
 
      cerr << "Wall " << **w << " is illegal.\n";
 
      #ifdef QDEBUG
 
      qDebug() << "Wall " << **w << " is illegal." << endl;
 
      #endif
 
    }
 
  }
 

	
 
}
 

	
 

	
 
@@ -1614,13 +1623,13 @@ void Mesh::RepairBoundaryPolygon(void) {
 
    }
 
  }
 
  boundary_polygon->walls.remove(0);
 
  boundary_polygon->ConstructNeighborList();
 
  
 
#ifdef QDEBUG
 
  cerr << "Repaired Boundary Polygon node indices: ";
 
  qDebug() << "Repaired Boundary Polygon node indices: ";
 
  foreach (Node* node, boundary_polygon->nodes){
 
    qDebug() << node->Index() << " " ;
 
  }
 
  qDebug() << endl ;
 

	
 
  #ifdef _undefined_
src/mesh.h
Show inline comments
 
@@ -37,12 +37,13 @@
 
#endif
 
#include "cell.h"
 
#include "node.h"
 
#include "simplugin.h"
 
#include <QVector>
 
#include <QPair>
 
#include <QDebug>
 

	
 
using namespace std;
 
// new queue which rejects duplicate elements
 
template<class T, class C = deque<T> > class unique_queue : public queue<T,C> {
 
	
 
public:
 
@@ -107,14 +108,16 @@ public:
 
	//void RandPoints(int npoints);
 
	
 
	inline Cell &getCell(int i) {
 
		if ((unsigned)i<cells.size())
 
			return *cells[i];
 
		else {
 
			cerr << i << endl;
 
			cerr << "size is " << cells.size() << endl;
 
                        #ifdef QDEBUG
 
                        qDebug() << i << endl;
 
                        qDebug() << "size is " << cells.size() << endl;
 
                        #endif
 
			abort();
 
			//	throw("Index out of range in Mesh::getCell");
 
		}
 
	}
 
	
 
	inline Node &getNode(int i) {
src/random.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
 *  along with the Virtual Leaf.  If not, see <http://www.gnu.org/licenses/>.
 
 *
 
 *  Copyright 2010 Roeland Merks.
 
 *
 
 */
 
 
#include <QDebug>
 
#include <string>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <sys/timeb.h>
 
#include <iostream>
 
#include "random.h"
 
@@ -81,15 +82,16 @@ double RANDOM(void)
 
/*! \param An integer random seed
 
  \return the random seed
 
**/
 
int Seed(int seed)
 
{
 
  if (seed < 0) {
 
    cerr << "Randomizing random generator, seed is ";
 
    int rseed=Randomize();
 
    cerr << rseed << "\n";
 
    #ifdef QDEBUG
 
    qDebug() << "Randomizing random generator, seed is " << rseed << endl;
 
    #endif
 
    return rseed;
 
  } else {
 
    int i;
 
    idum = -seed;
 
    for (i=0; i <100; i++)
 
      RANDOM();
src/wall.cpp
Show inline comments
 
@@ -58,13 +58,15 @@ bool Wall::CorrectWall( void ) {
 
	
 
	// For the first division, wall finds three "owners", including the boundary_polygon.
 
	// Remove that one from the list.
 
	//cerr << "wall_owners.size() = " << wall_owners.size() << endl;
 
	if (wall_owners.size() == 3 && nwalls==1 /* bug-fix 22/10/2007; confine this condition to first division only */) {
 
		
 
		cerr << "nwalls = " << nwalls << endl;
 
	        #ifdef QDEBUG
 
	        qDebug() << "nwalls = " << nwalls << endl;
 
		#endif
 
		// special case for first cleavage
 
		
 
		// find boundary polygon in the wall owners list
 
		list<CellBase *>::iterator bpit = find_if (
 
												   wall_owners.begin(), wall_owners.end(), 
 
												   mem_fun( &CellBase::BoundaryPolP )
 
@@ -83,41 +85,41 @@ bool Wall::CorrectWall( void ) {
 
			((Cell *)c2)->AddWall( bp_wall2);
 
			((Cell *)(*bpit))->AddWall(bp_wall2);
 
			
 
			wall_owners.erase(bpit); 
 
			
 
		}else {
 

	
 
		  #ifdef QDEBUG
 
		  qDebug() << "Wall::CorrectWall says: Wall has three owners, but none of them is the BoundaryPolygon. I have no clue what to do with this case... Sorry!" << endl;
 
		  qDebug() << "Wall: " << *this << endl;
 
		  qDebug() << "Owners are: ";
 
		  transform(wall_owners.begin(), wall_owners.end(), ostream_iterator<int>(qDebug(), "  "), mem_fun (&CellBase::Index) );
 
		  qDebug() << endl;
 
		  qDebug() << "Owners node " << n1->Index() << ": ";
 
		  for (list<Neighbor>::iterator i = n1->owners.begin(); i!=n1->owners.end(); i++) {
 
		    qDebug() << i->getCell()->Index() << " ";
 
		  }
 
		  qDebug() << endl;
 
		  qDebug() << "Owners node " << n2->Index() << ": ";
 
			
 
			cerr << "Wall::CorrectWall says: Wall has three owners, but none of them is the BoundaryPolygon. I have no clue what to do with this case... Sorry!\n";
 
			cerr << "Wall: " << *this << endl;
 
			cerr << "Owners are: ";
 
			transform(wall_owners.begin(), wall_owners.end(), ostream_iterator<int>(cerr, "  "), mem_fun (&CellBase::Index) );
 
			cerr << endl;
 
			cerr << "Owners node " << n1->Index() << ": ";
 
			for (list<Neighbor>::iterator i = n1->owners.begin();
 
				 i!=n1->owners.end();
 
				 i++) {
 
				cerr << i->getCell()->Index() << " ";
 
			}
 
			cerr << endl;
 
			cerr << "Owners node " << n2->Index() << ": ";
 
			
 
			for (list<Neighbor>::iterator i = n2->owners.begin();
 
				 i!=n2->owners.end();
 
				 i++) {
 
				cerr << i->getCell()->Index() << " ";
 
			}
 
			cerr << endl;
 
			std::exit(1);
 
		  for (list<Neighbor>::iterator i = n2->owners.begin(); i!=n2->owners.end(); i++) {
 
		    qDebug() << i->getCell()->Index() << " ";
 
		  }
 
		  qDebug() << endl;
 
                  #endif
 
		  std::exit(1);
 
		}
 
		
 
	}
 
	
 
	#ifdef QDEBUG
 
	if (wall_owners.size() == 1) {
 
		cerr << "Corner point. Special case.\n";
 
	  qDebug() << "Corner point. Special case." << endl;
 
	}
 
	#endif
 
	
 
	CellBase *cell1 = wall_owners.front();
 
	CellBase *cell2 = wall_owners.back();
 
	
 
	if ( (c1 == cell1 && c2==cell2) || (c1 == cell2 && c2 == cell1) ) {
 
		
 
@@ -145,13 +147,15 @@ bool Wall::CorrectWall( void ) {
 
				if ( c2 == cell2) {
 
					((Cell *)c1)->RemoveWall(this);
 
					c1 = cell1;
 
					((Cell *)c1)->AddWall(this);
 
					//	  cerr << "Block 3\n";
 
				} else {
 
					cerr << "Warning, cell wall was not corrected.\n";
 
				        #ifdef QDEBUG
 
				        qDebug() << "Warning, cell wall was not corrected." << endl;
 
					#endif
 
					return false;
 
				}
 
			}
 
		}
 
	}
 
	
src/wallbase.cpp
Show inline comments
 
@@ -16,12 +16,14 @@
 
 *  along with the Virtual Leaf.  If not, see <http://www.gnu.org/licenses/>.
 
 *
 
 *  Copyright 2010 Roeland Merks.
 
 *
 
 */
 

	
 
#include <QDebug>
 

	
 
#include "wall.h"
 
#include "wallbase.h"
 
#include "node.h"
 
#include "mesh.h"
 
#include "parameter.h"
 
#include <sstream>
 
@@ -50,15 +52,17 @@ ostream &operator<<(ostream &os, const W
 
	return os;
 
}
 

	
 

	
 
WallBase::WallBase(Node *sn1, Node *sn2, CellBase *sc1, CellBase *sc2) {
 
	
 
        #ifdef QDEBUG
 
	if (sc1==sc2) { 
 
		cerr << "Attempting to build a wall between identical cells: " << sc1->Index() << endl; 
 
	  qDebug() << "Attempting to build a wall between identical cells: " << sc1->Index() << endl; 
 
	}
 
	#endif
 
	
 
	c1 = sc1;
 
	c2 = sc2;
 
	
 
	n1 = sn1;
 
	n2 = sn2;
src/wallitem.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
 *  along with the Virtual Leaf.  If not, see <http://www.gnu.org/licenses/>.
 
 *
 
 *  Copyright 2010 Roeland Merks.
 
 *
 
 */
 

	
 
#include <QDebug>
 
#include <string>
 
#include <QGraphicsScene>
 
#include <QVector>
 
#include "canvas.h"
 
#include "wallitem.h"
 
#include "parameter.h"
 
@@ -122,16 +123,18 @@ void WallItem::setColor(void) {
 
}
 

	
 
void WallItem::OnClick(QMouseEvent *e) {
 
  
 

	
 
	Wall *w=&getWall();
 
	cerr << "Wall ID = " << w->Index() << ", this = " << w << "\n";
 
	cerr << "Wall item = " << this << "\n";
 
	cerr << "C1 = " << w->C1()->Index() << ", C2 = " << w->C2()->Index() << endl;
 
	cerr << "N1 = " << w->N1()->Index() << ", N2 = " << w->N2()->Index() << endl;
 
	#ifdef QDEBUG
 
	qDebug() << "Wall ID = " << w->Index() << ", this = " << w << endl;
 
	qDebug() << "Wall item = " << this << endl;
 
	qDebug() << "C1 = " << w->C1()->Index() << ", C2 = " << w->C2()->Index() << endl;
 
	qDebug() << "N1 = " << w->N1()->Index() << ", N2 = " << w->N2()->Index() << endl;
 
	#endif
 
	//double tr = wn==1?w->Transporters1(1):w->Transporters2(1);
 
	CellBase *c = wn==1?w->C1():w->C2();
 

	
 
	TransporterDialog dialog(w, c, wn);
 
	dialog.exec();
 

	
0 comments (0 inline, 0 general)