# HG changeset patch # User Michael Guravage # Date 2010-06-17 12:25:40 # Node ID a58b80c85b6f11fefdf9bdfd30a37644d4aa838f # Parent 121f7720db6288cfbec7dbe0e9da43e7a9f01aa9 Cleanup: e.g. removed commented out and otherwise disabled code. -- user: Michael Guravage branch 'default' changed src/OptionFileDialog.cpp changed src/OptionFileDialog.h changed src/UniqueMessage.cpp changed src/VirtualLeaf.cpp changed src/apoplastitem.cpp changed src/apoplastitem.h changed src/build_models/auxingrowthplugin.cpp changed src/build_models/meinhardtplugin.cpp changed src/build_models/testplugin.h changed src/canvas.cpp changed src/canvas.h changed src/cell.cpp changed src/cell.h changed src/cellbase.cpp changed src/cellbase.h changed src/data_plot.cpp changed src/data_plot.h changed src/flux_function.h changed src/forwardeuler.cpp changed src/infobar.h changed src/mainbase.cpp changed src/mainbase.h changed src/matrix.cpp changed src/mesh.h changed src/modelcatalogue.cpp changed src/node.cpp changed src/node.h changed src/nodeitem.cpp changed src/nodeset.h changed src/output.cpp changed src/output.h changed src/parse.cpp changed src/parse.h changed src/random.cpp changed src/random.h changed src/sqr.h changed src/vector.h changed src/vleafmodel.h changed src/wall.cpp changed src/wallbase.cpp changed src/wallbase.h changed src/wallitem.cpp changed src/wallitem.h changed src/warning.cpp changed src/warning.h changed src/xmlwrite.cpp diff --git a/src/OptionFileDialog.cpp b/src/OptionFileDialog.cpp --- a/src/OptionFileDialog.cpp +++ b/src/OptionFileDialog.cpp @@ -36,11 +36,7 @@ OptionFileDialog::OptionFileDialog(QWidg parcheck = new QCheckBox("parameters", this); parcheck -> setCheckState(Qt::Checked); - //timecheck = new QCheckBox("time",this); - //timecheck -> setCheckState(Qt::Checked); - addToolButton(geometrycheck); - //addToolButton(timecheck); addToolButton(parcheck); }; diff --git a/src/OptionFileDialog.h b/src/OptionFileDialog.h --- a/src/OptionFileDialog.h +++ b/src/OptionFileDialog.h @@ -20,6 +20,9 @@ * */ +#ifndef _OPTIONFILEDIALOG_H_ +#define _OPTIONFILEDIALOG_H_ + #include #include @@ -35,7 +38,6 @@ public: private: QCheckBox *geometrycheck; QCheckBox *parcheck; - //QCheckBox *timecheck; - +}; -}; +#endif diff --git a/src/UniqueMessage.cpp b/src/UniqueMessage.cpp --- a/src/UniqueMessage.cpp +++ b/src/UniqueMessage.cpp @@ -42,8 +42,6 @@ QDialog(parent, f) { boxtext = text; show_again = new QCheckBox(tr("Do not show this message again")); - //addButton(show_again, QMessageBox::ActionRole); - //addButton(QMessageBox::Ok); okButton = new QPushButton(tr("Ok")); if (issued_messages.contains(boxtext) ) { @@ -51,8 +49,6 @@ QDialog(parent, f) { cerr << "Saw message before\n"; display = false; } else { - //cerr << "First time message\n"; - //issued_messages << text; display=true; } diff --git a/src/VirtualLeaf.cpp b/src/VirtualLeaf.cpp --- a/src/VirtualLeaf.cpp +++ b/src/VirtualLeaf.cpp @@ -57,18 +57,11 @@ #include #include "modelcatalogue.h" -/* #define _xstr_(s) _str_(s) - #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) @@ -192,16 +185,6 @@ void MainBase::Plot(int resize_stride) { fname.fill('0'); fname.width(6); - /* - 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"); - */ - fname << frame << ".jpg"; if (par.storage_stride <= par.xml_storage_stride) { frame++; @@ -277,36 +260,16 @@ TIMESTEP { //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();*/ - mesh.ReactDiffuse(par.rd_dt); t++; Plot(par.resize_stride); - /*QVector< QPair > 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 >::const_iterator v=angles.begin(); - v!=angles.end(); - v++) { - af << v->first << " " << v->second << endl; - } - */ } } else { - /* 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); Plot(par.resize_stride); @@ -322,21 +285,7 @@ TIMESTEP { /* Called if a cell is clicked */ void Cell::OnClick(QMouseEvent *e) { - e = NULL; // use assignment merely to obviate compilation warning - - /* #ifdef HAVE_QWT - // Launch DataPlot window - QStringList curvenames; - for (int i=0;iOnClick(*this); } @@ -478,17 +427,6 @@ int main(int argc,char **argv) { QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) ); } - // Load plugins - /*QVector plugins = LoadPlugins(); - InstallPlugin(plugins[0], main_window); - - 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) diff --git a/src/apoplastitem.cpp b/src/apoplastitem.cpp --- a/src/apoplastitem.cpp +++ b/src/apoplastitem.cpp @@ -43,8 +43,8 @@ ApoplastItem::ApoplastItem( Wall *w, QGr Vector offs = Cell::Offset(); double factor = Cell::Factor(); - Vector from = ( offs + *(w->N1()) ) * factor;// + (wn==1?-1:1) * par.outlinewidth;// * 0.2 * factor * perp; - Vector to = ( offs + *(w->N2()) ) *factor;// + (wn==1?-1:1) * par.outlinewidth;// * 0.2 * factor * perp; + Vector from = ( offs + *(w->N1()) ) * factor; + Vector to = ( offs + *(w->N2()) ) *factor; setLine(( from.x ), @@ -70,6 +70,6 @@ void ApoplastItem::setColor(void) { } void ApoplastItem::OnClick(QMouseEvent *e) { - e = NULL; // merely to obviate compile time warning + e = NULL; // merely to obviate compilation warnings } diff --git a/src/apoplastitem.h b/src/apoplastitem.h --- a/src/apoplastitem.h +++ b/src/apoplastitem.h @@ -40,8 +40,6 @@ public: virtual ~ApoplastItem() {} Wall &getWall(void) const { return *class_cast(obj); } void OnClick(QMouseEvent *e); - //virtual void userMove(double dx, double dy); - //virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); void setColor(void); private: int wn; diff --git a/src/build_models/auxingrowthplugin.cpp b/src/build_models/auxingrowthplugin.cpp --- a/src/build_models/auxingrowthplugin.cpp +++ b/src/build_models/auxingrowthplugin.cpp @@ -58,16 +58,6 @@ void AuxinGrowthPlugin::OnDivide(ParentI w->setTransporter(daughter1, 1, 0.); } - //daughter1.LoopWalls(Wall::setTransporter(&daughter1, 1, 0.)); - - - /* for (list::const_iterator w=daughter2.walls.begin(); - w!=daughter2.walls.end(); - w++) { - // reset transporter value - (*w)->setTransporter(&daughter2, 1, 0.); - } - */ } void AuxinGrowthPlugin::SetCellColor(CellBase *c, QColor *color) { @@ -106,7 +96,6 @@ void AuxinGrowthPlugin::CelltoCellTransp if (w->AuxinSource()) { double aux_flux = par->leaf_tip_source * w->Length(); dchem_c1[0]+= aux_flux; - // dchem_c2 is undefined..! return; } else { return; @@ -119,7 +108,6 @@ void AuxinGrowthPlugin::CelltoCellTransp if (w->AuxinSource()) { double aux_flux = par->leaf_tip_source * w->Length(); dchem_c2[0] += aux_flux; - // dchem_c1 is undefined...! return; } else { @@ -167,7 +155,6 @@ void AuxinGrowthPlugin::WallDynamics(Wal if (w->AuxinSink()) { dw1[0] = 0.; dw2[0] = 0.; - //dw1[2] = 0.; dw2[2] = 0.; // assume high auxin concentration in SAM, to convince PIN1 to polarize to it // exocytosis regulated0 @@ -180,7 +167,7 @@ void AuxinGrowthPlugin::WallDynamics(Wal return; } else { - dw1[0]=dw2[0]=dw1[1]=dw2[1];//=dw1[2]=dw2[2]; + dw1[0]=dw2[0]=dw1[1]=dw2[1]; return; } } @@ -189,7 +176,6 @@ void AuxinGrowthPlugin::WallDynamics(Wal if (w->AuxinSink()) { dw1[0] = 0.; dw2[0] = 0.; - //dw1[2] = 0.; dw2[2] = 0.; // assume high auxin concentration in SAM, to convince PIN1 to polarize to it // exocytosis regulated @@ -201,7 +187,7 @@ void AuxinGrowthPlugin::WallDynamics(Wal return; } else { - dw1[0]=dw2[0]=dw1[1]=dw2[1];//=dw1[2]=dw2[2]; + dw1[0]=dw2[0]=dw1[1]=dw2[1]; return; } } @@ -237,8 +223,6 @@ void AuxinGrowthPlugin::WallDynamics(Wal /* PIN1 of neighboring vascular cell inhibits PIN1 endocytosis */ dw1[0] = 0.; dw2[0] = 0.; - //dw1[2] = 0.; dw2[2] = 0.; - dw1[1] = dPijdt1; dw2[1] = dPijdt2; } @@ -264,14 +248,6 @@ void AuxinGrowthPlugin::CellDynamics(Cel // exocytosis regulated: dPidt = -par->k1 * c->ReduceCellAndWalls( far_3_arg_mem_fun( *this, &AuxinGrowthPlugin::complex_PijAj ) ) + par->k2 * sum_Pij; - /*for ( list::const_iterator w = c->walls.begin(); - w!=walls.end(); - w++) { - if ((*w)->C1() == c) - dPidt += complex_PijAj( (*w)->C1(), (*w)->C2(), *w ); - else - dPidt += complex_PijAj( (*w)->C2(), (*w)->C1(), *w ); - }*/ // production of PIN depends on auxin concentration dPidt += (c->AtBoundaryP()?par->pin_prod_in_epidermis:par->pin_prod) * c->Chemical(0) - c->Chemical(1) * par->pin_breakdown; diff --git a/src/build_models/meinhardtplugin.cpp b/src/build_models/meinhardtplugin.cpp --- a/src/build_models/meinhardtplugin.cpp +++ b/src/build_models/meinhardtplugin.cpp @@ -117,19 +117,13 @@ void MeinhardtPlugin::CellDynamics(CellB double A = c->Chemical(1); double H = c->Chemical(2); double S = c->Chemical(3); - //double expansin = c->Chemical(4); + 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 ); - //dchem[4] = ( -par->expansindecay * expansin ); - //for (int i=0;i<4;i++) { cerr << "[ " << dchem[i] << " ]"; } cerr << endl; - -// cerr << "Chemicals: "; for (int i=0;iChemical(i) << " "; } cerr << endl; - -// test: dchem[0] = 0.01 * c->Chemical(0) * ( 1. - c->Chemical(0)); } diff --git a/src/build_models/testplugin.h b/src/build_models/testplugin.h --- a/src/build_models/testplugin.h +++ b/src/build_models/testplugin.h @@ -20,6 +20,8 @@ * */ +#ifndef _TESTPLUGIN_H_ +#define _TESTPLUGIN_H_ #include #include @@ -55,6 +57,4 @@ public: virtual int NChem(void) { return 0; } }; - - - +#endif diff --git a/src/canvas.cpp b/src/canvas.cpp --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -163,11 +163,6 @@ void FigureEditor::mousePressEvent(QMous #endif - /* if (dynamic_cast
(parent())->RotationModeP()) { - // if in rotation mode, exit it upon a mouse click - dynamic_cast
(parent())->ExitRotationMode(); - }*/ - QList l=scene()->items(p); #ifdef QDEBUG @@ -175,45 +170,6 @@ void FigureEditor::mousePressEvent(QMous qDebug() << "Mouse button modifier: " << e->modifiers() << endl; #endif - - /* if (rotation_mid_point) { - - // calculate rotation angle alpha - QPointF q_v1 = intersection_line->line().p2(); - - intersection_line->line().p1(); - QPointF q_v2 = angle_line->line().p2(); - - angle_line->line().p1(); - - Vector v1(q_v1.x(),q_v1.y()); - Vector v2(q_v2.x(),q_v2.y()); - - cerr << "v1 = " << v1 << endl; - cerr << "v2 = " << v2 << endl; - - - rot_angle = v1.SignedAngle(v2); - cerr << "Angle is " << rot_angle << endl; - - const QPointF &q_c(angle_line->line().p1()); - Vector center = Vector(q_c.x(), q_c.y()) / Cell::Factor() - Cell::Offset(); - - cerr << "Center is " << center << endl; - - mesh.Rotate(rot_angle, center); - delete angle_line; - angle_line=0; - delete intersection_line; - intersection_line=0; - - viewport()->setMouseTracking( FALSE ); - dynamic_cast
(parent())->Plot(); - - - return; - - }*/ - - if (e->button()==Qt::RightButton || l.size()==0) { //cerr << "Drawing an intersection line from " << p.x() << ", " << p.y() << endl; @@ -225,19 +181,11 @@ void FigureEditor::mousePressEvent(QMous } for (QList::Iterator it=l.begin(); it!=l.end(); ++it) { - /*if ( (*it)->rtti() == imageRTTI ) { - ImageItem *item= (ImageItem*)(*it); - if ( !item->hit( p ) ) - continue; - }*/ #ifdef QDEBUG qDebug() << typeid(**it).name() << endl; #endif if ( !strcmp(typeid(**it).name(),"8NodeItem")) { - //moving = dynamic_cast(*it); - //moving = *it; - //moving_start = p; stringstream data_strstream; data_strstream << (dynamic_cast(*it))->getNode(); @@ -249,19 +197,6 @@ void FigureEditor::mousePressEvent(QMous if ( !strcmp(typeid(**it).name(),"8CellItem") ) { Cell &c=((dynamic_cast(*it))->getCell()); - //static int old_stride=100; - //if (!c.Source()) { - /* if (!c.Source()) { - c.SetChemical(0,par.cellsource); - //flag=true; - //c.SetSource(0,par.cellsource); - //c.Fix(); - //cerr << "Setting source\n"; - - } else { - //c.UnsetSource(); - cerr << "Unsetting source\n"; - } */ // OnClick to be defined in end-user code c.OnClick(e); } else { @@ -300,15 +235,13 @@ void FigureEditor::mouseMoveEvent(QMouse mesh.Rotate(d_alpha, ( Vector(rotation_midpoint) + Cell::Offset() ) / Cell::Factor() ); - //viewport()->setMouseTracking( FALSE ); dynamic_cast
(parent())->Plot(0); FullRedraw(); return; } if ( moving ) { - //QPoint p = matrix().inverted().map(e->pos()); + QPointF p = mapToScene(e->pos()); - moving->userMove(p.x() - moving_start.x(), p.y() - moving_start.y()); moving_start = p; @@ -319,28 +252,16 @@ void FigureEditor::mouseMoveEvent(QMouse //cerr << "event"; // keep track of intersection line to interactively cut a growing leaf - /* if (angle_line) { - - QPointF sp = angle_line -> line().p1(); // startpoint - //QPointF ep = matrix().inverted().map(e->pos()); // endpoint - QPointF ep = mapToScene(e->pos()); // endpoint - angle_line -> setLine( QLineF(sp, ep) ); - scene()->update(); - - } else { */ if ( intersection_line ) { QPointF sp = intersection_line -> line().p1(); // startpoint - //QPointF ep = matrix().inverted().map(e->pos()); // endpoint QPointF ep = mapToScene(e->pos()); // endpoint intersection_line -> setLine( QLineF(sp, ep) ); scene()->update(); // Need this for Mac FullRedraw(); } - /* } */ - } //void FigureEditor::contentsMouseReleaseEvent(QMouseEvent* e) @@ -356,7 +277,6 @@ void FigureEditor::mouseReleaseEvent(QMo 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) ); @@ -376,14 +296,12 @@ void FigureEditor::mouseReleaseEvent(QMo Vector startpoint = Vector(sp.x(), sp.y()) / Cell::Factor() - Cell::Offset(); Vector endpoint = Vector(ep.x(), ep.y()) / Cell::Factor() - Cell::Offset(); - // Mesh &m(intersected_cells.front()->getCell().getMesh()); NodeSet *node_set = new NodeSet; for (vector::iterator it = intersected_cells.begin(); it != intersected_cells.end(); it++) { - //(*it)->Mark(); (*it)->setBrush(QBrush("purple")); Cell &c=(*it)->getCell(); @@ -412,7 +330,6 @@ void FigureEditor::mouseReleaseEvent(QMo mesh.TestIllegalWalls(); // Do the actual cutting and removing if (intersected_cells.size()) { - // Mesh &m(intersected_cells.front()->getCell().getMesh()); mesh.CutAwayBelowLine( startpoint, endpoint ); // Correct flags of nodeset @@ -465,19 +382,11 @@ void FigureEditor::mouseReleaseEvent(QMo if (intersection_line /* && !angle_line*/) { - //QPointF p = matrix().inverted().map(e->pos()); QPointF p = mapToScene(e->pos()); QPointF sp = intersection_line->line().p1(); viewport()->setMouseTracking( TRUE ); - /* angle_line = new QGraphicsLineItem( 0, scene() ); - angle_line->setPen( QPen( QColor("Blue"), 3, Qt::DashLine ) ); - angle_line->setLine( QLineF(sp, p) ); - angle_line->setZValue( 100 ); - angle_line->show(); - */ } - } } @@ -500,9 +409,7 @@ vector FigureEditor::getInt #endif if ( !strcmp(typeid(**it).name(),"8CellItem") ) { - colliding_cells.push_back(dynamic_cast(*it)); - } } @@ -555,8 +462,6 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q Q3MainWindow(parent,name,f), MainBase(c,m), mesh(m) - - //canvas(c) { editor = new FigureEditor(canvas,mesh, this); @@ -570,18 +475,16 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q QMenuBar* menu = menuBar(); Q3PopupMenu* file = new Q3PopupMenu( menu ); - // file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F); + file->insertItem("&Read leaf", this, SLOT(readStateXML())); file->insertItem("&Save leaf", this, SLOT(saveStateXML())); file->insertItem("Snapshot", this, SLOT(snapshot()), Qt::CTRL+Qt::SHIFT+Qt::Key_S); - // file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N); + file->insertSeparator(); file->insertItem("Read next leaf", this, SLOT(readNextStateXML()), Qt::Key_PageDown); file->insertItem("Read previous leaf", this, SLOT(readPrevStateXML()), Qt::Key_PageUp); file->insertItem("Read last leaf", this, SLOT(readLastStateXML()), Qt::Key_End); file->insertItem("Read first leaf", this, SLOT(readFirstStateXML()), Qt::Key_Home); - //file->insertItem("Read ¶meters", this, SLOT(readPars())); - //file->insertItem("&Write parameters", this, SLOT(savePars())); file->insertSeparator(); file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P); @@ -598,25 +501,19 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q menu->insertItem("&Edit", edit); run = new Q3PopupMenu( menu ); - // edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), ALT+Key_P); - //edit->insertItem("Add &Line", this, SLOT(addLine()), ALT+Key_L); running = false; paused_id = run->insertItem("&Simulation paused", this, SLOT(togglePaused()), Qt::Key_S); run->setItemChecked(paused_id, FALSE); - //run->insertItem("&Divide Cell", this, SLOT(Divide()), Qt::CTRL+Qt::Key_D); - // run->insertItem("&Restart Simulation", this, SLOT(RestartSim())); menu->insertItem("&Run", run); view = new Q3PopupMenu( menu ); - //view->insertItem("&Enlarge", this, SLOT(enlarge()), SHIFT+CTRL+Key_Plus); - //view->insertItem("Shr&ink", this, SLOT(shrink()), SHIFT+CTRL+Key_Minus); view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Equal); view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus); view->insertSeparator(); com_id = view->insertItem("Show cell ¢ers", 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); @@ -638,7 +535,6 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q view->setItemChecked(apoplasts_id, FALSE); view->insertSeparator(); only_boundary_id = view->insertItem("Show only leaf &boundary", this, SLOT(toggleLeafBoundary())); - //only_boundary_id = view->insertItem("Show only leaf &boundary", 0,0); view->insertSeparator(); movie_frames_id = view->insertItem("Start saving movie &frames", this, SLOT(toggleMovieFrames())); view->setItemChecked(movie_frames_id, par.movie); @@ -648,8 +544,6 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q options = new Q3PopupMenu( menu ); - /* dbf_id = options->insertItem("Double buffer", this, SLOT(toggleDoubleBuffer())); - options->setItemChecked(dbf_id, TRUE);*/ dyn_cells_id = options->insertItem("Cell growth", this, SLOT(toggleDynCells())); options->setItemChecked(dyn_cells_id, true); @@ -673,30 +567,10 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q helpmenu->insertSeparator(); helpmenu->insertItem("&About", this, SLOT(help()) ); //, Key_F1); - //help->insertItem( "What's &This", this , SLOT(whatsThis()), SHIFT+Key_F1); menu->insertItem("&Help",helpmenu); - //QSlider *flux_arrow_slider = new QSlider( 0, 10000, 1, 100, Qt::Horizontal, this, "flux arrow size"); - //QSpinBox *stride = new QSpinBox( 1, 1000, 1, this, "stride"); - - - //QGridLayout *controlgrid = new QGridLayout( this, 1, 2, 10); - // 2x1, 10 pixel border - - //controlgrid->addWidget( stride, 0, 0); - //controlgrid->addWidget( flux_arrow_slider, 0, 1); - //controlgrid->setColStretch( 1, 10 ); - - - //flux_arrow_size = 1.; - //flux_arrow_slider -> setMinimumSize( 200,50); - //connect( flux_arrow_slider, SIGNAL( valueChanged( int ) ), this, SLOT( setFluxArrowSize(int) ) ); - statusBar(); - setCentralWidget(editor); - printer = 0; - init(); // Start timer which repetitively invokes @@ -709,20 +583,6 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q setCaption(caption); gifanim = 0; - // A little bit of PSB/CWI decoration ;-) - /*dockwindow = new Q3DockWindow(); - addDockWindow(dockwindow); - QLabel *viblab = new QLabel; viblab->setPixmap(QPixmap(cwi_xpm)); - QString virtleafstring("

The Virtual Leaf

\n
Model: %1
"); - QLabel *virtleaf = new QLabel(virtleafstring.arg(mesh.ModelID())); - QLabel *psblab = new QLabel; psblab->setPixmap(QPixmap(PSB_xpm)); - dockwindow->setHorizontalStretchable(true); - dockwindow->boxLayout()->addWidget(viblab);//,Qt::AlignLeft); - dockwindow->boxLayout()->addStretch(); - dockwindow->boxLayout()->addWidget(virtleaf);//, Qt::AlignHCenter); - dockwindow->boxLayout()->addStretch(); - dockwindow->boxLayout()->addWidget(psblab);//, Qt::AlignRight);*/ - //QString virtleafstring("

The Virtual Leaf

\n
Model: %1
"); infobar = new InfoBar(); addDockWindow(infobar); @@ -783,9 +643,6 @@ void Main::EditParameters() { void Main::savePars() { - // bool timer_active; - /* if (timer_active=timer->isActive()) - imer->stop();*/ stopSimulation(); Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE ); @@ -826,10 +683,6 @@ void Main::readPars() { void Main::saveStateXML() { - - // bool timer_active; - // if (timer_active=timer->isActive()) - // timer->stop(); stopSimulation(); Q3FileDialog *fd = new Q3FileDialog( this, "file dialog", TRUE ); fd->setMode( Q3FileDialog::AnyFile ); @@ -863,9 +716,6 @@ void Main::saveStateXML() { void Main::snapshot() { - // bool timer_active; - // if (timer_active=timer->isActive()) - // timer->stop(); stopSimulation(); Q3FileDialog *fd = new Q3FileDialog( this, "Save snapshot", TRUE ); fd->setMode( Q3FileDialog::AnyFile ); @@ -931,8 +781,6 @@ void Main::readPrevStateXML() { readStateXML((const char *)next_file); } - - } int Main::readStateXML(const char *filename, bool geometry, bool pars, bool simtime) { @@ -953,7 +801,7 @@ int Main::readStateXML(const char *filen currentFile = QString(filename); Plot(); - QString status_message = QString("Succesfully read leaf from file %1. Time is %2 h.\n").arg(currentFile).arg(mesh.getTimeHours().c_str()); + QString status_message = QString("Successfully read leaf from file %1. Time is %2 h.").arg(currentFile).arg(mesh.getTimeHours().c_str()); cerr << status_message.toStdString() << endl; setCaption(caption_with_file.arg(filename)); statusBar()->message(status_message); @@ -1081,26 +929,6 @@ void Main::readStateXML() { if (readStateXML((const char *)fileName,fd->readGeometryP(), fd->readParametersP()) ) return readStateXML(); // user can try again - -// try { -// mesh.XMLRead((const char *)fileName); -// currentFile = fileName; -// } catch (const char *error_message) { -// QMessageBox mb( "Read leaf from XML file", -// QString(error_message), -// QMessageBox::Critical, -// QMessageBox::Ok | QMessageBox::Default, -// QMessageBox::NoButton, -// QMessageBox::NoButton); -// mb.exec(); -// return readStateXML(); // user can try again -// } - -// Vector bbll,bbur; -// mesh.BoundingBox(bbll,bbur); - -// //FitLeafToCanvas(); -// Plot(); } } @@ -1133,24 +961,13 @@ void Main::help() QMessageBox::aboutQt( this, "Virtual Leaf" ); } -/* void Main::toggleDoubleBuffer() -{ - bool s = !options->isItemChecked(dbf_id); - options->setItemChecked(dbf_id,s); - canvas.setDoubleBuffering(s); -} -*/ void Main::toggleShowCellCenters() { - //bool s = !view->isItemChecked(com_id); - //view->setItemChecked(com_id,s); Plot(); } void Main::toggleShowWalls() { - //bool s = !view->isItemChecked(cell_walls_id); - //view->setItemChecked(cell_walls_id,s); Plot(); } void Main::toggleShowApoplasts() @@ -1159,50 +976,30 @@ void Main::toggleShowApoplasts() } void Main::toggleShowNodes() { - //bool s = !view->isItemChecked(mesh_id); - //view->setItemChecked(mesh_id,s); Plot(); } void Main::toggleNodeNumbers(void) { - - //bool s = !view->isItemChecked(node_number_id); - //view->setItemChecked(node_number_id,s); Plot(); } void Main::toggleCellNumbers(void) { - - //bool s = !view->isItemChecked(cell_number_id); - //view->setItemChecked(cell_number_id,s); Plot(); } void Main::toggleCellAxes(void) { - - //bool s = !view->isItemChecked(cell_axes_id); - //view->setItemChecked(cell_axes_id,s); Plot(); } void Main::toggleCellStrain(void) { - - //bool s = !view->isItemChecked(cell_strain_id); - //view->setItemChecked(cell_strain_id,s); Plot(); } void Main::toggleShowFluxes(void) { - - //bool s = !view->isItemChecked(fluxes_id); - //view->setItemChecked(fluxes_id,s); Plot(); } - void Main::toggleShowBorderCells() - { - //bool s = !view->isItemChecked(border_id); - //view->setItemChecked(border_id,s); + void Main::toggleShowBorderCells(){ Plot(); } @@ -1210,34 +1007,19 @@ void Main::toggleHideCells(void) { Plot(); editor->FullRedraw(); } - void Main::toggleMovieFrames() - { - //bool s = !view->isItemChecked(movie_frames_id); - //view->setItemChecked(movie_frames_id,s); - } + void Main::toggleMovieFrames(){} + + void Main::toggleLeafBoundary(){} - void Main::toggleLeafBoundary() - { - //bool s = !view->isItemChecked(only_boundary_id); - //view->setItemChecked(only_boundary_id,s); - } - - void Main::toggleDynCells() - { - //bool s = !options->isItemChecked(dyn_cells_id); - //options->setItemChecked(dyn_cells_id,s); - } - - + void Main::toggleDynCells() {} + void Main::startSimulation(void) { - //run->setItemChecked(paused_id, false); timer->start( 0 ); statusBar()->message("Simulation started"); running = true; } void Main::stopSimulation(void) { - //run->setItemChecked(paused_id, true); timer->stop(); cerr << "Stopping simulation" << endl; statusBar()->message("Simulation paused"); @@ -1264,19 +1046,14 @@ void Main::toggleHideCells(void) { void Main::enlarge() { - //canvas.resize(canvas.width()*4/3, canvas.height()*4/3); canvas.setSceneRect( QRectF( 0,0, canvas.width()*4./3., canvas.height()*4./3.) ); } void Main::shrink() { canvas.setSceneRect( QRectF( 0,0, canvas.width()*3/4, canvas.height()*3/4) ); - } -/* void Main::scrollBy(int dx, int dy) { - editor->scrollBy(dx,dy); - }*/ void Main::scale(double factor) { QMatrix m = editor->matrix(); @@ -1365,70 +1142,6 @@ void Main::toggleHideCells(void) { //startSimulation(); } - /* - void Main::SaveToGifAnim(void) { - - if (gifanim) { - - QPixmap image(canvas.width(), canvas.height()); - QPainter im(&image); - - - canvas.drawArea(QRect(0,0,canvas.width(),canvas.height()),&im,FALSE); - QFile conversionpipe; - conversionpipe.open ( IO_WriteOnly, popen("pngtopnm | ppmtogif > tmp.gif", "w") ); - image.save( &conversionpipe, "PNG"); - conversionpipe.close(); - - QFile readconvertedimage("tmp.gif"); - readconvertedimage.open(IO_ReadOnly); - int c; - while ( (c=readconvertedimage.getch())!=-1) { - gifanim->putch(c); - } - } - }*/ - - /* void Main::StartGifAnim(QString fname) { - - if (gifanim) { - QMessageBox::information( this, "Animation", - "Already making another animation." - "Please end it and try again.", - QMessageBox::Ok ); - } else { - - QString cmdline("gifsicle --multifile - > "); - cmdline += fname; - - gifanim = new QFile; - gifanim->open( IO_WriteOnly, - popen((const char *)cmdline, "w") ); - - */ /* QStringList cmdline; - cmdline << "gifsicle" << "--multifile" << "-"; - gifanim = new QProcess( cmdline ); - - cmdline.clear(); - cmdline << "pngtopnm"; - pngtopnm = new QProcess( cmdline ); - pngtopnm->start(); - - cmdline.clear(); - cmdline << "ppmtogif"; - ppmtogif = new QProcess( cmdline ); - ppmtogif->start();*/ - /* } - - }*/ - - /*void Main::EndGifAnim(void) { - - if (gifanim) - gifanim->close(); - - }*/ - void Main::FitCanvasToWindow(void) { @@ -1495,8 +1208,6 @@ void Main::CleanMesh(void) { Plot(); editor->FullRedraw(); - - // repaint(); } void Main::CleanMeshChemicals(void) { @@ -1512,8 +1223,6 @@ void Main::CleanMeshChemicals(void) { Plot(); editor->FullRedraw(); - - // repaint(); } void Main::CleanMeshTransporters(void) { @@ -1528,8 +1237,6 @@ void Main::CleanMeshTransporters(void) { Plot(); editor->FullRedraw(); - - // repaint(); } void Main::RandomizeMesh(void) { diff --git a/src/canvas.h b/src/canvas.h --- a/src/canvas.h +++ b/src/canvas.h @@ -75,9 +75,6 @@ class FigureEditor : public QGraphicsVie void FullRedraw(void); protected: - /* void contentsMousePressEvent(QMouseEvent*); - void contentsMouseMoveEvent(QMouseEvent*); - void contentsMouseReleaseEvent(QMouseEvent*);*/ void mousePressEvent(QMouseEvent*); void mouseMoveEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); @@ -134,10 +131,6 @@ class Main : public Q3MainWindow, public virtual double getFluxArrowsize(void) { return flux_arrow_size; } - //void Save(const char *fname, const char *format); - /*void StartGifAnim(QString fname); - void SaveToGifAnim(void); - void EndGifAnim(void);*/ void FitCanvasToWindow(); void FitLeafToCanvas(void); @@ -147,12 +140,9 @@ class Main : public Q3MainWindow, public void help(); void TimeStepWrap(); - //void scrollBy(int dx, int dy); void togglePaused(); void setFluxArrowSize(int size); - //void Divide(void); void RestartSim(void); - //void toggleDoubleBuffer(void); void toggleShowCellCenters(void); void toggleShowNodes(void); void toggleShowBorderCells(void); @@ -162,7 +152,7 @@ class Main : public Q3MainWindow, public void toggleCellAxes(void); void toggleCellStrain(void); void toggleShowWalls(void); - void toggleShowApoplasts(void); + void toggleShowApoplasts(void); void toggleDynCells(void); void toggleMovieFrames(void); void toggleLeafBoundary(void); @@ -214,13 +204,6 @@ class Main : public Q3MainWindow, public void clear(); void init(); virtual void CutSAM() { MainBase::CutSAM(); Refresh();} -/* void cellmonitor() { */ -/* PlotDialog *plot = new PlotDialog(this); */ -/* cerr << "Attempting to launch a cell monitor\n"; */ -/* } */ - - //void addPolygon(); - //void addLine(); void enlarge(); void shrink(); @@ -243,7 +226,6 @@ class Main : public Q3MainWindow, public private: NodeSet *node_set; FigureEditor *editor; - //QCanvas& canvas; Q3PopupMenu* options; Q3PopupMenu *view; Q3PopupMenu *run; diff --git a/src/cell.cpp b/src/cell.cpp --- a/src/cell.cpp +++ b/src/cell.cpp @@ -94,10 +94,7 @@ void Cell::DivideOverAxis(Vector axis) { new_node_locations.push_back(i); - } // else { - // //cerr << "cross.z * prev_cross_z = " << cross.z * prev_cross_z << endl; - // } - + } prev_cross_z=cross.z; } @@ -220,52 +217,6 @@ void Cell::Apoptose(void) { - /* - // correct boundary polygon if this cell touches the boundary - - // find the first living boundary node after a dead node - bool node_found = false; - for (list::iterator n=nodes.begin(); - n!=nodes.end(); - n++) { - - Node &no(*(*n)); - - if (no.DeadP()) { - - list::iterator first_node = n; - if (++next_node == nodes.end()) first_node=nodes.begin(); - - if (!(*(*first_node)).DeadP() && ((*first_node)->boundary)) { - node_found=true; - break; - } - - } - } - - // locate it in the boundary_polygon - if (node_found) { - list::iterator insert_it = find(mesh->boundary_polygon->nodes.begin(), - mesh->boundary_polygon->nodes.end(), - ++first_node); - if (insert_it!=owners.end()) { - - if (insert_it==owners.end()) insert_it=owners.begin(); - - for (list::iterator n=insert_it; - n!=nodes.end(); - n++) { - - Node &no(*(*n)); - - mesh->boundary_polygon->nodes.insert( - - } - - - } - } */ // mark cell as dead MarkDead(); } @@ -364,8 +315,6 @@ bool Cell::DivideOverGivenLine(const Vec double ub = ((v2.x - v1.x)*(v1.y-v3.y) - (v2.y- v1.y)*(v1.x - v3.x))/denominator; - /* double intersec_x = v1.x + ua*(v2.x-v1.x); - double intersec_y = v1.y + ua*(v2.y-v1.y);*/ //cerr << "Edge " << *i << " to " << *nb << ": ua = " << ua << ", ub = " << ub << ": "; // this construction with "TINY" should simulate open/closed interval <0,1] @@ -433,8 +382,6 @@ void Cell::DivideWalls(ItList new_node_l } daughter->cell_type = cell_type; - //extern double auxin_account; - //auxin_account += daughter->chem[0]; for (int i=0;inew_chem[i]=new_chem[i]; @@ -448,7 +395,6 @@ void Cell::DivideWalls(ItList new_node_l target_area/=2; daughter->cellvec=cellvec; -// daughter->BaseArea() = base_area; // Division currently only works for convex cells: i.e. if the division line @@ -617,11 +563,6 @@ void Cell::DivideWalls(ItList new_node_l (new_node_ind[i])->fixed = true; // All this we'll do later for the node set only - /* (new_node_ind[i])->boundary = true; - (new_node_ind[i])->sam = true; - boundary_touched_flag = true; - boundary = SAM; - daughter->boundary = SAM;*/ } // if new node is inserted into the boundary @@ -806,7 +747,7 @@ void Cell::DivideWalls(ItList new_node_l if (w == walls.end()) { #ifdef QDEBUG - qDebug() << "Whoops, wall element not found...!" << endl; + qDebug() << "Whoops, wall element not found...!" << endl; qDebug() << "Cell ID: " << neighbor_cell->Index() << endl; qDebug() << "My cell ID: " << Index() << endl; #endif @@ -839,18 +780,6 @@ void Cell::DivideWalls(ItList new_node_l } - //new_wall->ResetTransporterConcentrations(orig_length); - //(*w)->ResetTransporterConcentrations(orig_length); - - // reset the transporter concentrations - - - /* new_wall->SetLength(); - new_wall->CorrectLength(orig_length); - - (*w)->SetLength(); - (*w)->CorrectLength(orig_length);*/ - // 3. Give wall elements to appropriate cells if (new_wall->n1 != new_wall->n2) { @@ -1001,11 +930,8 @@ void Cell::DivideWalls(ItList new_node_l if (!fix_cellwall) node->boundary = false; - else { // if fix_cellwall is true, that is if we are cutting off - // part of a leaf to make a nice initial condition, we also want to make it part of the boundary - //node->boundary = true; + else { node->fixed = true; - //node->sam = true; } ins_pos=daughter->nodes.insert(ins_pos, node ); @@ -1100,10 +1026,6 @@ void Cell::DivideWalls(ItList new_node_l } } - //neighbors.push_back( daughter ); - //daughter->neighbors.push_back( this ); - - //cerr << "Cell " << index << " has been dividing, and gave birth to Cell " << daughter->index << endl; // now reconstruct neighbor list for all "broken" neighbors @@ -1118,8 +1040,6 @@ void Cell::DivideWalls(ItList new_node_l daughter->ConstructNeighborList(); m->plugin->OnDivide(&parent_info, daughter, this); - // wall->OnWallInsert(); - //daughter->OnDivide(); daughter->div_counter=(++div_counter); @@ -1166,19 +1086,17 @@ double Cell::Displace(double dx, double i!=nodes.end(); i++) { - //if ((*i)->Fixed()) return; // commented out 01/12/05 + for (list::const_iterator n=(*i)->owners.begin(); n!=(*i)->owners.end(); n++) { if (n->getCell()!=this) { - //if (!(m->getNode(n->nb1).Fixed() && m->getNode(n->nb2).Fixed())) { length_edges.push_back( pair (*i, n->nb1) ); length_edges.push_back( pair (*i, n->nb2) ); old_length += DSQR(Node::target_length-(*(*i)-*(n->nb1)).Norm())+ DSQR(Node::target_length-(*(*i)-*(n->nb2)).Norm()); - //} } } } @@ -1230,22 +1148,6 @@ double Cell::Displace(double dx, double //cerr << endl; - /*vector area1; - vector area2; - m->ExtractFromCells( mem_fun_ref(&Cell::Area), back_inserter(area1) ); - m->ExtractFromCells( mem_fun_ref(&Cell::CalcArea), back_inserter(area2)); - vector::iterator i=area1.begin(); - vector::iterator j=area2.begin(); - int c=0; - for (; - i!=area1.end(); - (i++, j++)) { - if ( (*i-*j) > 1e-10) { - cerr << c++ << " " << *i << " " << *j << endl; - abort(); - } - }*/ - } else { Move ( -1*movement); @@ -1351,8 +1253,6 @@ bool Cell::SelfIntersect(void) { double ub = ((v2.x - v1.x)*(v1.y-v3.y) - (v2.y- v1.y)*(v1.x - v3.x))/denominator; - /* double intersec_x = v1.x + ua*(v2.x-v1.x); - double intersec_y = v1.y + ua*(v2.y-v1.y);*/ if ( ( TINY < ua && ua < 1.-TINY ) && ( TINY < ub && ub < 1.-TINY ) ) { //cerr << "ua = " << ua << ", ub = " << ub << endl; @@ -1426,9 +1326,6 @@ bool Cell::MoveSelfIntersectsP(Node *mov double ub = ((neighbor_of_moving_node[j].x - new_pos.x)*(new_pos.y-v3.y) - (neighbor_of_moving_node[j].y- new_pos.y)*(new_pos.x - v3.x))/denominator; - /* double intersec_x = new_pos.x + ua*(neighbor_of_moving_node[j].x-new_pos.x); - double intersec_y = new_pos.y + ua*(neighbor_of_moving_node[j].y-new_pos.y);*/ - if ( ( TINY < ua && ua < 1.-TINY ) && ( TINY < ub && ub < 1.-TINY ) ) { //cerr << "ua = " << ua << ", ub = " << ub << endl; return true; @@ -1472,9 +1369,6 @@ bool Cell::IntersectsWithLineP(const Vec double ub = ((v2.x - v1.x)*(v1.y-v3.y) - (v2.y- v1.y)*(v1.x - v3.x))/denominator; - /* double intersec_x = v1.x + ua*(v2.x-v1.x); - double intersec_y = v1.y + ua*(v2.y-v1.y);*/ - if ( ( TINY < ua && ua < 1.-TINY ) && ( TINY < ub && ub < 1.-TINY ) ) { return true; } @@ -1571,14 +1465,12 @@ void Cell::ConstructWalls(void) { // One Wall for each neighbor, so we should be able to correctly construct neighbor lists here. if (duplicates[0]==this) { - //walls. new Wall(*nb,*i,duplicates[0],duplicates[1]) ); AddWall( new Wall(*nb,*i,duplicates[0],duplicates[1]) ); if (!duplicates[1]->BoundaryPolP()) { neighbors.push_back(duplicates[1]); } } else { - //walls.push_back( new Wall(*nb,*i,duplicates[1],duplicates[0]) ); AddWall ( new Wall(*nb,*i,duplicates[1],duplicates[0]) ); if (!duplicates[0]->BoundaryPolP()) { neighbors.push_back(duplicates[0]); @@ -1724,26 +1616,9 @@ void Cell::DrawNodes(QGraphicsScene *c) n++) { Node *i=*n; - //QCanvasEllipse *item = new QCanvasEllipse( 10, 10, c); + NodeItem *item = new NodeItem ( &(*i), c ); - //QGraphicsRectItem *item = new QGraphicsRectItem(-50, -50, 50, 50, 0, c); - //disk->setBrush( QColor("IndianRed") ); - - /*if (i->sam) { - item->setBrush( purple ); - } else { - if (i->boundary) { - item->setBrush( deep_sky_blue ); - } - else { - item->setBrush( indian_red ); - } - }*/ item->setColor(); - - /*(if (item->getNode().DeadP()) { - item->setBrush( QBrush (Qt::Dense6Pattern) ); - }*/ item->setZValue(5); item->show(); item ->setPos(((offset[0]+i->x)*factor), @@ -1754,16 +1629,6 @@ void Cell::DrawNodes(QGraphicsScene *c) void Cell::DrawIndex(QGraphicsScene *c) const { - // stringstream text; - // text << index; - // Vector centroid = Centroid(); - // QCanvasText *number = new QCanvasText ( QString (text.str()), c ); - // number->setColor( QColor(par.textcolor) ); - // number->setZ(20); - // number->setFont( QFont( "Helvetica", par.cellnumsize, QFont::Bold) ); - // number->show(); - // number -> move((int)((offset[0]+centroid.x)*factor), - // (int)((offset[1]+centroid.y)*factor) ); DrawText( c, QString("%1").arg(index)); } @@ -1775,7 +1640,6 @@ void Cell::DrawText(QGraphicsScene *c, c ctext->setPen( QPen(QColor(par.textcolor)) ); ctext->setZValue(20); ctext->setFont( QFont( "Helvetica", par.cellnumsize, QFont::Bold) ); - //ctext->setTextFlags(Qt::AlignCenter); ctext->show(); ctext ->setPos(((offset[0]+centroid.x)*factor), ((offset[1]+centroid.y)*factor) ); @@ -1815,61 +1679,12 @@ void Cell::DrawAxis(QGraphicsScene *c) c void Cell::DrawStrain(QGraphicsScene *c) const { c = NULL; // assignment merely to obviate compilation warning MyWarning::warning("Sorry, Cell::DrawStrain temporarily not implemented."); - /* Vector long_axis; - double width; - Length(&long_axis, &width); - - //cerr << "Length is " << length << endl; - long_axis.Normalise(); - Vector short_axis=long_axis.Perp2D(); - - // To test method "Strain" temporarily substitute "short_axis" for "strain" - Vector strain = Strain(); - //strain.Normalise(); - //static ofstream strainf("strain.dat"); - //strainf << strain.Norm() << endl; - Vector centroid = Centroid(); - // Vector from = centroid - 0.5 * width * short_axis; - // Vector to = centroid + 0.5 * width *short_axis; - Vector from = centroid - 0.5 * strain; - Vector to = centroid + 0.5 * strain; - - QGraphicsArrowItem *arrow = new QGraphicsArrowItem(0, c); - arrow->setPen( QPen(QColor(par.arrowcolor),100) ); - - 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(); - */ } -// Draw connecting lines to neighbors -/*void Cell::DrawTriangles(QCanvas &c) { - - for (list::const_iterator nb=nb_list.begin(); - nb!=nb_list.end(); - nb++) { - QCanvasLine *line = new QCanvasLine(&c); - line->setPen( QPen(QColor("black"),2) ); - line->setZ(2); - - line->setPoints((offset[0]+x)*factor,(offset[1]+y)*factor, - (offset[0]+nb->c->x)*factor,(offset[1]+nb->c->y)*factor); - line->setZ(10); - line->show(); - } - - }*/ - - void Cell::DrawFluxes(QGraphicsScene *c, double arrowsize) { // get the mean flux through this cell - //Vector vec_flux = ReduceWalls( mem_fun_ref( &Wall::VizFlux ), Vector() ); Vector vec_flux = ReduceCellAndWalls( PINdir ); vec_flux.Normalise(); @@ -2012,7 +1827,6 @@ list::iterator Cell::RemoveWall( void Cell::EmitValues(double t) { // cerr << "Attempting to emit " << t << ", " << chem[0] << ", " << chem[1] << endl; - //chem[3] = SumTransporters( 1 ); emit ChemMonValue(t, chem); } diff --git a/src/cell.h b/src/cell.h --- a/src/cell.h +++ b/src/cell.h @@ -91,10 +91,6 @@ public: return factor; } - // return node "i" - // wrapped around, i.e. node n==node 0 - // will not work if i < -nodes.size() - //Node &getNode(int i) const; void DivideOverAxis(Vector axis); // divide cell over axis bool DivideOverGivenLine(const Vector v1, const Vector v2, bool wall_fixed = false, NodeSet *node_set = 0); // divide over the line (if line and cell intersect) diff --git a/src/cellbase.cpp b/src/cellbase.cpp --- a/src/cellbase.cpp +++ b/src/cellbase.cpp @@ -40,9 +40,7 @@ #endif #include "nodeset.h" -//#include "cond_operator.h" #include "cellbase.h" -//#include "node.h" #include "wall.h" #include "random.h" #include "parameter.h" @@ -56,12 +54,6 @@ extern Parameter par; const char* CellBase::boundary_type_names[4] = {"None", "NoFlux", "SourceSink", "SAM"}; -// These statics have moved to class "CellsStaticDatamembers" - -//double CellBase::static_base_area = 0.; -//int CellBase::ncells=0; -//int CellBase::NChem()=0; - #ifndef VLEAFPLUGIN CellsStaticDatamembers *CellBase::static_data_members = new CellsStaticDatamembers(); #else @@ -188,7 +180,7 @@ CellBase::CellBase(const CellBase &src) CellBase CellBase::operator=(const CellBase &src) { Vector::operator=(src); - // QObject::operator=(src); + for (int i=0;i::const_iterator i) const { - -if (i== - return m->getNode(i); - }*/ - - void CellBase::SetIntegrals(void) const { @@ -408,17 +393,9 @@ void CellBase::SetIntegrals(void) const (*nb)->x*(*i)->y); } - //area/=2.0; + area = fabs(area)/2.0; - /* intgrl_x/=6.; - intgrl_y/=6.; - - intgrl_xx/=12.; - intgrl_xy/=24.; - intgrl_yy/=12.;*/ - - } double CellBase::Length(Vector *long_axis, double *width) const { @@ -447,9 +424,6 @@ double CellBase::Length(Vector *long_axi // see: http://scienceworld.wolfram.com/physics/MomentofInertiaEllipse.html // cerr << "n = " << n << "\n"; - // Vector eigenvectors[2]; - // eigenvectors[0] = Vector(-(-ixx + iyy ) + rhs2, ixy, 0); - // eigenvectors[1] = Vector(-(-ixx + iyy ) - rhs2, ixy, 0); if (long_axis) { *long_axis = Vector(-ixy, lambda_b - ixx, 0); // cerr << "ixx = " << ixx << ", ixy = " << ixy << ", iyy = " << iyy << ", area = " << area << endl; @@ -531,9 +505,6 @@ double CellBase::CalcLength(Vector *long // see: http://scienceworld.wolfram.com/physics/MomentofInertiaEllipse.html // cerr << "n = " << n << "\n"; - // Vector eigenvectors[2]; - // eigenvectors[0] = Vector(-(-ixx + iyy ) + rhs2, ixy, 0); - // eigenvectors[1] = Vector(-(-ixx + iyy ) - rhs2, ixy, 0); if (long_axis) { *long_axis = Vector(-ixy, lambda_b - ixx, 0); // cerr << "ixx = " << ixx << ", ixy = " << ixy << ", iyy = " << iyy << ", my_area = " << my_area << endl; @@ -550,15 +521,6 @@ double CellBase::CalcLength(Vector *long } -// void CellBase::NodeRemoved(int n) { -// for (list::iterator i=nodes.begin(); -// i!=nodes.end(); -// i++) { -// if ((*i)->Index()>n) { -// (*i)->index--; -// } -// } -// } void CellBase::ConstructNeighborList(void) { @@ -567,7 +529,7 @@ void CellBase::ConstructNeighborList(voi list::const_iterator wit=walls.begin(); // somehow the reverse_iterator returns by walls needs to be casted to const to let this work. // it seems to me it is a bug in the STL implementation... - //wit!=(list::const_reverse_iterator)walls.rend(); + wit!=walls.end(); wit++) { @@ -580,20 +542,7 @@ void CellBase::ConstructNeighborList(voi } - /* - for (list::iterator e=neighbors.begin(); - e!=neighbors.end(); - e++) { - cerr << (*e)->Index() << " "; - if ((*e)->CellBase::BoundaryPolP()) { - cerr << " b "; - } - } - */ // remove all boundary_polygons from the list - - - list ::iterator e=neighbors.begin(); at_boundary=false; @@ -614,334 +563,6 @@ void CellBase::ConstructNeighborList(voi } while(1); } - -// CellBase constructs its neighbor list from its node lists -// Assumes, obviously, that the node lists are up to date -// (i.e. call ConstructConnections before calling this method) -// We'll keep this one private, anyway. -/* void CellBase::ConstructNeighborList(void) { - -// extern ofstream debug_stream; - -neighbors.clear(); - -// debug_stream << "Nodes: "; -// copy(nodes.begin(),nodes.end(),ostream_iterator(debug_stream, " ")); -//debug_stream << endl; - -for (list::const_iterator i=nodes.begin(); - i!=nodes.end(); - i++) { - - // collect all cells to which my nodes are connected on one list - //transform((*i)->cells.begin(),(*i)->cells.end(), back_inserter(neighbors), mem_fun_ref(&Neighbor::CellBase)); - - // index of next node - list::const_iterator nn=i; - ++nn; - if (nn==nodes.end()) - nn=nodes.begin(); - - // debug_stream << "Node " << *i << ", Neighbor " << *nn << endl; - // debug_stream << "Owners: "; - // copy((*i)->cells.begin(),(*i)->cells.end(),ostream_iterator(debug_stream, " ")); - // debug_stream << endl; - - for (list::const_iterator nb=(*i)->owners.begin(); - nb!=(*i)->owners.end(); - nb++) { - - // collect info about neighboring cells, not about myself - if (nb->CellBase!=this) { - - // make sure the whole edge touches this putative neighbor - // if (*nn == nb->nb1 || *nn == nb->nb2) { - //walls.push_back( new Wall(*i,*nn,this,nb->CellBase) ); - //debug_stream << "Adding edge " << walls.back() << " to CellBase " << index << endl; - //} - - neighbors.push_back( nb->CellBase ); - } - } - - -} - -neighbors.sort(); - -list::iterator e=unique(neighbors.begin(),neighbors.end()); - -// iterator e point to the end of the subsequence of unique elements -// remove every thing that comes after it - -neighbors.erase(e, neighbors.end()); - -// okay, now neighbors contains all neighbors of this CellBase, including itself - -// A future optimization for the diffusion algorithm: now we list -// each of the edges of a (curved) CellBase boundary separately. We -// could keep track just of the total length per CellBase boundary - -// the following is not necessary anymore. Is -// checked at earlier stage -// // remove myself from the list -// e = find(neighbors.begin(),neighbors.end(),index); -// if (e!=neighbors.end()) -// neighbors.erase(e); -// - -// remove boundary_polygon from the list (CellBase identity <0 ) -e=neighbors.begin(); -at_boundary=false; -do { - e = find_if(neighbors.begin(),neighbors.end(),mem_fun(&CellBase::BoundaryPolP)); - if (e!=neighbors.end()) { - e=neighbors.erase(e); - at_boundary=true; - } else { - break; - } -} while(1); - - -}*/ - - -/*void Cell::print_nblist(void) const { -// cerr << "{ "; - -for (list::const_iterator i=nb_list.begin(); - i!=nb_list.end(); - i++) { - // cerr << "(" << i->c->index << " " << i->Dij << ")"; - -} -// cerr << "}" << endl; -} -*/ - - -// Tests whether Cell p (given as Vector, remember that Cell is a -// Vector) is within polygon formed by nearest neighbor cells -// -// Based on algorithm and code by Paul Bourke, see -// http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/ -// -// Note: works for 2D only; projects everything on z=0; -/* -#define MIN(x,y) (x < y ? x : y) -#define MAX(x,y) (x > y ? x : y) - */ -/*bool Cell::CellInsidePolygonP(Vector &p) -{ - int counter = 0; - double xinters; - Vector p1,p2; - - //p1 = polygon[0]; - p1 = *(nb_list.begin()->c); - - int N=nb_list.size(); - list::const_iterator nb=nb_list.begin(); - - for (int i=1;i<=N;i++) { - - nb++; - - if (nb!=nb_list.end()) { - p2 = *(nb->c); - } else { - p2 = *(nb_list.begin()->c); - } - - if (p.y > MIN(p1.y,p2.y)) { - if (p.y <= MAX(p1.y,p2.y)) { - if (p.x <= MAX(p1.x,p2.x)) { - if (p1.y != p2.y) { - xinters = (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x; - if (p1.x == p2.x || p.x <= xinters) - counter++; - } - } - } - } - p1 = p2; - } - - if (counter % 2 == 0) - return false; - else - return true; - -}*/ - - -/* // at new position cell should be able to "see" all polygon sides -bool Cell::NewPointValidP(Vector &p) { - - //int ninvtri=0; - for (list::const_iterator nb=nb_list.begin(); - nb!=nb_list.end(); - nb++) { - - Vector p1=*(nb->c); // first neighbor - list::const_iterator nextv=nb; nextv++; - - - if (nextv==nb_list.end()) { - if (Boundary()==None) { - nextv=nb_list.begin(); - } else continue; - } - - Vector p2=*(nextv->c); - - Vector v1=(p1-p); - Vector v2=(p2-p1); - - Vector cross=v1*v2; - // //cerr << "[" << cross << "]" << endl; - - if (cross.z<0) { - // One of the triangles has "inverted". - //if (Boundary()==None || ninvtri) - return false; - //else - // accept one "inverted" triangle - //ninvtri++; - } - } - return true; - -}*/ - - - - -// void Cell::CheckForDivision(void) { -// // if (/* Chemical(0)<0.4 && */ /* differentiated cells do not divide */ area > 2*base_area /* || Length()>50 */) { - -// if (area > par.rel_cell_div_threshold * base_area ) { -// /* remark no longer valid? //m->IncreaseCellCapacityIfNecessary(); -// // Note that calling Divide as follows prevents trouble if cell -// // vector is relocated */ -// Divide(); -// } -//} - -/* void Cell::CheckForGFDrivenDivision(void) { -if (area > base_area && chem[0]>par.gf_div_threshold) { - //int ind=index; - if (index==1) return; // petiole does not divide - - // remark no longer valid? - //m->IncreaseCellCapacityIfNecessary(); - // Note that calling Divide as follows prevents trouble if cell - // vector is relocated - Vector horizontal(1,0,0); - Vector vertical(0,1,0); - double r; - if ((r=RANDOM())>par.vertdivprob) { - DivideOverAxis(horizontal); - } else { - cerr << "[" << r << "]"; - DivideOverAxis(vertical); - } -} -} -*/ - - - -// return (a measure of) the strain of this cell -/*Vector CellBase::Strain(void) const { - - cerr << "Sorry, CellBase::strain currently not implemented" << endl; - std::exit(1); - - // Reason: we do not want to include "Node" in the plugins (Node::target_length below), and we do need Strain anyway... - - - // go over all wall elements of the cell - Vector Fvec; - - for (list::const_iterator n=nodes.begin(); - n!=nodes.end(); - n++) { - - list::const_iterator nn=n; nn++; - if (nn==nodes.end()) nn=nodes.begin(); - - Vector wall_element = *(*n) - *(*nn); - - // assume k=1 (Hooke's constant), for now - double Fscal = (Node::target_length - wall_element.Norm())/Node::target_length; - - - Fvec += Fscal * wall_element.Normalised(); - - } - - return Fvec; -} */ - - - -/* void Cell::Flux(double *flux, double D) { - -// Algorithm according to Rudge & Haseloff 2005 -// (will we need to take cell area into account?) -// For the time being, we don't: assume cell area is -// mainly determined by vacuole. - -// Currently implements Rolland-Lagan-Mitchison algorithm -// Rolland-Lagan and Prusinkiewicz, The Plant Journal (2005), 44, 854-865 - -// currently I only implemented passive, diffusive transport -// active transport will be added later - -// loop over cell edges - -for (int c=0;c::iterator i=walls.begin(); - i!=walls.end(); - i++) { - - - // leaf cannot take up chemicals from environment ("no flux boundary") - if (i->c2 < 0) continue; - - // calculate edge length - // (will later be updated during node displacement for efficiency) - double edge_length = (m->nodes[i->n1]-m->nodes[i->n2]).Norm(); - - // D is "background diffusion coefficient" (Rolland-Lagan) - - - // flux depends on edge length and concentration difference */ - // i->phi = edge_length * ( /* i->D +*/ D ) * ( m->cells[i->c2].chem[0] - chem[0] ); - /* - if (m->cells[i->c1].index!=index) { - cerr << "Warning, bad cells boundary: " << m->cells[i->c1].index << ", " << index << endl; - } - - flux[0] += i->phi; - //double deltaD = par.alpha * (i->phi*i->phi) - par.gamma * i->D; // Note beta=0 - //i->D += par.dt*deltaD; - - //cerr << "[ i->D = " << i->D << ", deltaD = " << deltaD << "]"; - //if (i->D > par.Dmax) i->D=par.Dmax; - - // first calculate all fluxes, we update diffusion coefficient afterwards. - - // cerr << "[ " << edge_length << ", " << m->cells[i->c2].chem[0] << " - " << chem[0] << "]"; - -} - - -} -*/ // Save the cell to a stream so we can reconstruct its state later void CellBase::Dump(ostream &os) const { diff --git a/src/cellbase.h b/src/cellbase.h --- a/src/cellbase.h +++ b/src/cellbase.h @@ -108,8 +108,6 @@ class CellBase : public QObject, public virtual bool BoundaryPolP(void) const { return false; } - // CellBase(const Vector &src); // not allowed (we cannot know to which mesh - /// the CellBase will belong...) CellBase operator=(const CellBase &src); // assignment operator CellBase operator=(const Vector &src); @@ -158,8 +156,6 @@ class CellBase : public QObject, public boundary_type SetBoundary(boundary_type bound) { if (bound!=None) { - //area=0.; - //length=0.; } return boundary=bound; } @@ -229,7 +225,6 @@ class CellBase : public QObject, public flag_for_divide = true; } - //Vector Strain(void) const; inline double Circumference(void) const { double sum=0.; @@ -251,13 +246,11 @@ class CellBase : public QObject, public } return wall_list; } - // void XFigPrint(std::ostream &os) const; void Dump(ostream &os) const; QString printednodelist(void); - // void OnDivide(ParentInfo &parent_info, CellBase &daughter); inline bool DeadP(void) { return dead; } @@ -343,13 +336,6 @@ class CellBase : public QObject, public return sum; } - /* template void LoopWalls(Op f) { - for (list::const_iterator w=walls.begin(); - w!=walls.end(); - w++) { - ( **w)->f; - } - }*/ //! Sum transporters at this CellBase's side of the walls double SumTransporters(int ch) { @@ -463,9 +449,6 @@ protected: int cell_type; - //double length; - //Vector meanflux; - //int valence; // for length constraint mutable double intgrl_xx, intgrl_xy, intgrl_yy, intgrl_x, intgrl_y; diff --git a/src/data_plot.cpp b/src/data_plot.cpp --- a/src/data_plot.cpp +++ b/src/data_plot.cpp @@ -63,10 +63,6 @@ DataPlot::DataPlot(QWidget *parent, cons // Disable polygon clipping QwtPainter::setDeviceClipping(false); - // We don't need the cache here - //canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false); - //canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false); - alignScales(); // Initialize data @@ -105,24 +101,8 @@ DataPlot::DataPlot(QWidget *parent, cons setAxisTitle(QwtPlot::yLeft, "Level"); setAxisScale(QwtPlot::yLeft, 0, 10); - - // setTimerInterval(0.0); data_pos = 0; - - - // open file for writing - /* QString fname(title); - fname.replace(QString(" "),QString()); - fname.append(".dat"); - std::cerr << "Writing to file " << fname.toStdString() << std::endl; - - datfile = new QFile(fname); - if (!datfile->open(QIODevice::WriteOnly | QIODevice::Text)) - return; - - datstream.setDevice(datfile); - */ } @@ -156,19 +136,6 @@ void DataPlot::alignScales() } } -/* void DataPlot::setTimerInterval(double ms) -{ - d_interval = qRound(ms); - - if ( d_timerId >= 0 ) - { - killTimer(d_timerId); - d_timerId = -1; - } - if (d_interval >= 0 ) - d_timerId = startTimer(d_interval); -} -*/ // Generate new values void DataPlot::AddValue(double t,double *x) @@ -192,16 +159,11 @@ void DataPlot::AddValue(double t,double d_t[data_pos] = t; - // datstream << t; - for ( int i=0;iAddValue(t,x); diff --git a/src/flux_function.h b/src/flux_function.h --- a/src/flux_function.h +++ b/src/flux_function.h @@ -1,12 +1,30 @@ /* - * flux_function.h - * VirtualLeaf + * + * $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. * - * Created by Roeland Merks on 07-06-10. - * Copyright 2010 __MyCompanyName__. All rights reserved. + * 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 . + * + * Copyright 2010 Roeland Merks. * */ + +#ifndef _FLUX_FUNCTION_h_ +#define _FLUX_FUNCTION_h_ + // This header file defines a macro "SumFluxFromWalls" that attempts to hide this // horrendously confusing member function wrapper construct from VirtualLeaf's end users @@ -20,3 +38,4 @@ #define SumFluxFromWalls( _vleafcellp_, _flux_function_ ) \ (( _vleafcellp_->ReduceCellAndWalls( far_3_arg_mem_fun( *this, &_flux_function_ ) ) )) +#endif diff --git a/src/forwardeuler.cpp b/src/forwardeuler.cpp --- a/src/forwardeuler.cpp +++ b/src/forwardeuler.cpp @@ -32,16 +32,6 @@ 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)) - static float minarg1,minarg2; - #define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ? \ - (minarg1) : (minarg2)) - #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) -*/ - - const double ForwardEuler::Safety = 0.9; const double ForwardEuler::PGrow = -0.2; const double ForwardEuler::Pshrnk = -0.25; diff --git a/src/infobar.h b/src/infobar.h --- a/src/infobar.h +++ b/src/infobar.h @@ -41,12 +41,9 @@ public: SetText("undefined"); setHorizontalStretchable(true); - //dockwindow->boxLayout()->addWidget(viblab);//,Qt::AlignLeft); boxLayout()->addStretch(); boxLayout()->addWidget(virtleaf);//, Qt::AlignHCenter); boxLayout()->addStretch(); - - //dockwindow->boxLayout()->addWidget(psblab);//, Qt::AlignRight); } void SetText(QString text) { @@ -54,7 +51,6 @@ public: } private: - //Q3DockWindow *dockwindow; QLabel *virtleaf; }; diff --git a/src/mainbase.cpp b/src/mainbase.cpp --- a/src/mainbase.cpp +++ b/src/mainbase.cpp @@ -220,14 +220,11 @@ void MainBase::Save(const char *fname, c // give the leaf some space Vector border = ((ur-ll)/5.); - //QRectF bb( ll.x - border.x, ll.y - border.y, ur.x-ll.x + 2*border.x, ur.y-ll.y + 2*border.y ); - if (!QString(format).contains("pdf", Qt::CaseInsensitive)) { QImage *image = new QImage(QSize(sizex, sizey), QImage::Format_RGB32); image->fill(QColor(Qt::white).rgb()); QPainter *painter=new QPainter(image); - //canvas.render(painter,QRectF(),QRectF(-5000,-5000, 10000, 10000)); canvas.render(painter); if (!image->save(QString(fname))) { MyWarning::warning("Image not saved successfully. Is the disk full or the extension not recognized?"); @@ -238,15 +235,7 @@ void MainBase::Save(const char *fname, c QPrinter pdf(QPrinter::HighResolution); pdf.setOutputFileName(fname); pdf.setOutputFormat(QPrinter::PdfFormat); - //pdf.setPageSize(QPrinter::Custom); QPainter painter(&pdf); - // cerr << "Cell::Magnification() = " << Cell::Magnification() << endl; - //if (sizex==0 || sizey==0) { - // always fit to page - // canvas.render(&painter); - //} else { - // canvas.render(&painter,QRectF(),QRectF(-5000,-5000, 10000, 10000)); - //} canvas.render(&painter, QRectF(), QRectF(-5000,-5000, 10000, 10000)); cerr << "Rendering to printer\n"; diff --git a/src/mainbase.h b/src/mainbase.h --- a/src/mainbase.h +++ b/src/mainbase.h @@ -58,7 +58,7 @@ class MainBase { showfluxesp = false; dynamicscellsp = true; showtooltipsp = false; - hidecellsp = false; + hidecellsp = false; } virtual ~MainBase() {}; @@ -77,12 +77,12 @@ class MainBase { 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 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 bool HideCellsP(void) { return hidecellsp; } virtual void clear(void) { QList list = canvas.items(); QList::Iterator it = list.begin(); @@ -94,26 +94,6 @@ class MainBase { virtual void XMLReadSettings(xmlNode *settings); virtual double getFluxArrowsize(void) { return 10.;} - /* void Save(const char *fname, const char *format, int width=640) { - - //cerr << "Initializing Pixmap\n"; - - cerr << "Saving to file " << fname << endl; - QPixmap *image=new QPixmap(width, (int) (((double)canvas.height()/ - (double)canvas.width())*((double)width))); - - //QPicture *image = new QPicture(); - - //cerr << "Done initializing QPixmap image(640, " << (((double)canvas.height()/(double)canvas.width())*640.) << ")\n"; - QPainter im(image); - //cerr << "Done initializing image\n"; - im.scale((double)width/canvas.width(),(double)width/canvas.width()); - canvas.render(&im, QRectF(0,0,canvas.width(),canvas.height()) ); - //im.end(); - image->save(QString(fname), format); - }*/ - - void Save(const char *fname, const char *format, int sizex=640, int sizey=480); void CutSAM(void); @@ -140,11 +120,11 @@ class MainBase { bool movieframesp; bool showboundaryonlyp; bool showwallsp; - bool showapoplastsp; + bool showapoplastsp; bool showfluxesp; bool dynamicscellsp; bool showtooltipsp; - bool hidecellsp; + bool hidecellsp; }; //#include diff --git a/src/matrix.cpp b/src/matrix.cpp --- a/src/matrix.cpp +++ b/src/matrix.cpp @@ -42,8 +42,6 @@ Matrix::Matrix(const Vector &c1, const V void Matrix::Alloc(void) { // constructor -// mat=(double **)malloc(3*sizeof(double *)); -// mat[0]=(double *)malloc(9*sizeof(double)); mat = new double*[3]; mat[0] = new double[9]; for (int i=1;i<3;i++) @@ -54,8 +52,6 @@ void Matrix::Alloc(void) { Matrix::~Matrix() { // destructor - //free(mat[0]); - //free(mat); delete[] mat[0]; delete[] mat; } diff --git a/src/mesh.h b/src/mesh.h --- a/src/mesh.h +++ b/src/mesh.h @@ -59,7 +59,6 @@ public: } }; -//template P& deref_ptr

( P *obj) { return *obj; } template P& deref_ptr ( P *obj) { return *obj; } @@ -80,19 +79,14 @@ public: cells.reserve(2); nodes.reserve(500); - //boundary_polygon = new BoundaryPolygon(); - time = 0.; plugin = 0; }; ~Mesh(void) { delete boundary_polygon; - /* if (plugin) - delete plugin;*/ }; void Clean(void); - //void Plane(int xwidth, int ywidth, int nx, int ny, bool randomP=false); Cell &EllipticCell(double xc, double yc, double ra, double rb, int nnodes=10, double rotation=0); Cell &CircularCell(double xc, double yc, double r, int nnodes=10) { return EllipticCell(xc, yc, r, r, nnodes, 0); @@ -102,11 +96,6 @@ public: Cell *RectangularCell(const Vector ll, const Vector ur, double rotation = 0); void CellFiles(const Vector ll, const Vector ur); - /* void GMVoutput(ostream &os, - const char *codename=0, const char *codever=0, - const char *comments=0);*/ - //void RandPoints(int npoints); - inline Cell &getCell(int i) { if ((unsigned)i= nodes.size() || i < 0) { - // cerr << "Mesh::getNode: Warning. Index " << i << " out of range.\n"; - // } return *nodes[i]; } @@ -134,35 +119,13 @@ public: inline int nnodes(void) { return nodes.size(); } - //void SortNBLists(void); - - /*template void LoopCells(Op f) { - for (vector::iterator i=cells.begin(); - i!=cells.end(); - i++) { - f(*i); - } - }*/ - - /*! \brief Calls function f for all Cells f. - - Using this template requires some fiddling with function adaptors bind2nd and mem_fun_ref. - - Example usage for calling a member function on each cell: - - mesh.LoopCells( bind2nd (mem_fun_ref( &Cell::DrawDiffEdges), &canvas ) ); - - This calls Cell's member function DrawDiffEdges, taking one - argument canvas, on all Cell objects in the current Mesh. - - */ + template void LoopCells(Op f) { for (vector ::iterator i=cells.begin(); i!=cells.end(); i++) { f(**i); } - //for_each(cells.begin(),cells.end(),f); } template void LoopWalls(Op f) { @@ -182,7 +145,6 @@ public: f(**i); } - //for_each(cells.begin(),cells.end(),f); } template void LoopNodes(Op f) { @@ -256,13 +218,6 @@ public: } } } -/* template void ExtractFromCells(Op1 f, Cont res) { - for (vector::iterator i=cells.begin(); - i!=cells.end(); - i++) { - *(res++) = ( f(*i) ); - } - }*/ // Apply "f" to cell i // i.e. this is an adapter which allows you to call a function @@ -335,7 +290,6 @@ public: os << node_insertion_queue.front() << endl; node_insertion_queue.pop(); } - //copy (node_insertion_queue.begin(),node_insertion_queue.end(),ostream_iterator(cerr, " ")); } void InsertNodes(void) { @@ -351,9 +305,7 @@ public: void Clear(); - // template ReactDiffuse(const double D, ReactFunction& react) { void ReactDiffuse( double delta_t = 1 ); - //void Diffuse(const double D); double SumChemical(int ch); void SetChemical(int ch, double value) { for (vector::iterator c=cells.begin(); @@ -427,8 +379,6 @@ public: QVector VertexAngles(void); QVector< QPair > VertexAnglesValues(void); void SetSimPlugin(SimPluginInterface *new_plugin) { - /* if (plugin) - delete plugin;*/ plugin=new_plugin; } QString ModelID(void) { return plugin?plugin->ModelID():QString("undefined"); } @@ -473,12 +423,7 @@ private: return c; } - //int Delaunay(void); void CircumCircle(double x1,double y1,double x2,double y2,double x3,double y3, double *xc,double *yc,double *r); - - - // void RenumberCells(void); - }; #endif diff --git a/src/modelcatalogue.cpp b/src/modelcatalogue.cpp --- a/src/modelcatalogue.cpp +++ b/src/modelcatalogue.cpp @@ -104,9 +104,6 @@ void ModelCatalogue::LoadPlugin(const ch MyWarning::error("Directory 'models' not found!"); } - - //QVector plugins; - QStringList modelnames=pluginDir.entryList(QDir::Files); if (modelnames.empty()) { MyWarning::error("Model %s not found - hint: do not include path in filename.",model); @@ -160,6 +157,4 @@ void ModelCatalogue::InstallModel(SimPlu mainwin->RefreshInfoBar(); mainwin->Init(0); } - // mesh->StandardInit(); - } diff --git a/src/node.cpp b/src/node.cpp --- a/src/node.cpp +++ b/src/node.cpp @@ -185,8 +185,6 @@ QVector Node::NeighbourAngles(voi Vector v1 = (*this - *i->nb1).Normalised(); Vector v2 = (*this - *i->nb2).Normalised(); - //angles.push_back(atan2(v2.y,v2.x)-atan2(v1.y,v1.x)); - //angles.push_back(atan2(v2.y,v2.x)-atan2(v1.y,v1.x)); double angle = v1.SignedAngle(v2); if (angle<0) { //cerr << "Changing sign of angle " << angle << endl; diff --git a/src/node.h b/src/node.h --- a/src/node.h +++ b/src/node.h @@ -125,11 +125,9 @@ public: boundary = !boundary; } - //void Displace(void); Cell &getCell(const Neighbor &i); - //Node &getNode(int i); ostream &print(ostream &os) const; void XMLAdd(xmlNodePtr nodes_node) const; @@ -164,24 +162,6 @@ public: return dead; } - /*void UpdateAfterNodeRemoved(int n) { - for (list::iterator i=owners.begin(); - i!=owners.end(); - i++) { - if (i->nb1>=n) i->nb1--; - if (i->nb2>=n) i->nb2--; - } - } - - void UpdateAfterCellRemoved(int n) { - for (list::iterator i=owners.begin(); - i!=owners.end(); - i++) { - if (i->cell>=n) i->cell--; - } - } - */ - inline void Mark(void) { marked=true; } @@ -198,7 +178,6 @@ public: z = p.z; } inline bool SamP(void) const { return sam; } - //enum boundary_type {NoBoundary, Noflux, SourceSink, SAM}; //!\brief Calculate angles with neighboring vertices //! Sum of angles should be 2*Pi diff --git a/src/nodeitem.cpp b/src/nodeitem.cpp --- a/src/nodeitem.cpp +++ b/src/nodeitem.cpp @@ -54,29 +54,10 @@ void NodeItem::userMove(double dx, doubl void NodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { - // from Qt4.2 example: "elastic nodes" - //painter->setPen(Qt::NoPen); - //painter->setBrush(Qt::darkGray); - //painter->drawEllipse(-70, -70, 200, 200); - - /* QRadialGradient gradient(-30, -30, 100); - - if (option->state & QStyle::State_Sunken) { - gradient.setCenter(30, 30); - gradient.setFocalPoint(30, 30); - gradient.setColorAt(1, QColor(Qt::yellow).light(120)); - gradient.setColorAt(0, QColor(Qt::darkYellow).light(120)); - } else { - gradient.setColorAt(0, Qt::yellow); - gradient.setColorAt(1, Qt::darkYellow); - } - - painter->setBrush(gradient); */ option = NULL; // use assignment merely to obviate compilation warning painter->setBrush(brush); painter->setPen(Qt::NoPen); - // const static double mag=20.; painter->drawEllipse(ellipsesize); } diff --git a/src/nodeset.h b/src/nodeset.h --- a/src/nodeset.h +++ b/src/nodeset.h @@ -31,8 +31,6 @@ #include #include "node.h" -//class xmlNode; - class NodeSet : public list { public: @@ -48,10 +46,6 @@ class NodeSet : public list { n->node_set = this; } - // list getCells(void) { list cellset; @@ -156,7 +150,6 @@ class NodeSet : public list { (*n)->x-=rx; (*n)->y-=ry; - // (*n)->z -= rz; } @@ -166,7 +159,6 @@ class NodeSet : public list { void XMLAdd(xmlNode *root) const; void XMLRead(xmlNode *root, Mesh *m); private: - // list set; bool done; }; diff --git a/src/output.cpp b/src/output.cpp --- a/src/output.cpp +++ b/src/output.cpp @@ -24,7 +24,6 @@ #include #include #include -//#include #include #include #include "warning.h" @@ -85,31 +84,6 @@ int YesNoP(const char *message) { } -/* //FILE *OpenWriteFile(char *filename) -// { -// FILE *fp; -// fprintf(stderr,"Opening %s for writing\n",filename); - -// if((OpenFileAndCheckExistance(&fp,filename,"r"))==TRUE) { -// if (!YesNoP("File exists, overwrite?")) { -// fprintf(stderr," Could not open file %s for writing, exiting... \n" -// ,filename); -// exit(0); -// } -// } - -// if (fp!=NULL) // file existed, but user wants to overwrite -// fclose(fp); - -// if ((fp=fopen(filename,"w"))==NULL) { -// fprintf(stderr," Could not open file %s for writing, exiting... \n" -// ,filename); -// exit(0); -// } - -// return fp; -// } -*/ FILE *OpenWriteFile(const char *filename) { @@ -151,55 +125,6 @@ FILE *OpenWriteFile(const char *filename return fp; } -/*FILE *OpenGZippedWriteFile(const char *filename) -{ - - // Open file that is zipped while it is written - // uses a pipe - - char fname[FNAMESIZE]; - char gzname[FNAMESIZE]; - - FILE *fp; - extern Parameter par; - - // step 1, add ".gz" to the filename - sprintf(gzname, "%s.gz", filename); - - // and check whether it already exists - fprintf(stderr,"Opening %s for writing\n",gzname); - - if(FileExistsP(gzname)==TRUE) { - - if (par.interactive) { - if (!YesNoP("File exists, overwrite?")) { - fprintf(stderr," Could not open file %s for writing, exiting... \n" - ,gzname); - exit(0); - } - } else { - // Rename old file - snprintf(fname, FNAMESIZE-1, "%s~",gzname); - rename(gzname, fname); - - } - } - - // strncpy(fname, gzname, FNAMESIZE-1); - char *command=new char[20+sizeof(gzname)]; - sprintf(command, "gzip -c > %s", gzname); - - if ((fp=popen(command,"w"))==NULL) { - fprintf(stderr," Could not open file %s for writing: " - ,fname); - perror(""); - exit(-1); - } - - delete[] command; - return fp; -} -*/ FILE *OpenReadFile(const char *filename) { @@ -331,8 +256,7 @@ char *Chext(char *filename) { } void MakeDir(const char *dirname) { - - cerr << "Entering MakeDir for name " << dirname << "\n"; + #ifdef QTGRAPHICS QFileInfo file_info(dirname); @@ -341,7 +265,7 @@ void MakeDir(const char *dirname) { if (file_info.isDir()) { // OK - cerr << "Using existing directory " << dirname << " for data storage.\n"; + cerr << "Using existing directory " << dirname << " for data storage." << endl; return; } else { char *message = new char[MESS_BUF_SIZE+1]; @@ -415,49 +339,3 @@ void MakeDir(const char *dirname) { #endif } -/*bool CanWeWriteP(char *filename) { - - // check for the existance of file "filename" - // if it exists, ask the user whether we may overwrite it - //false: do not overwrite. true: do overwrite - - - char message[MESS_BUF_SIZE]; - char fname[FNAMESIZE]; - - extern const Parameter par; - - int status; - status=access(filename, F_OK); - if (status < 0) {// file does not exist, or something else is wrong - // check error code - if (errno!=ENOENT) { - - // another error occured - snprintf(message, MESS_BUF_SIZE, "Error checking for existance of %s",filename); - perror(message); - exit(1); - } - - } else { - - // file exists, ask for permission to overwrite if interactive - if (par.interactive) { - snprintf(message, MESS_BUF_SIZE, "File %s exists. Overwrite? ",filename); - if (!YesNoP(message)) - return false; - else - return true; - } else { - // Rename old file - snprintf(fname, FNAMESIZE-1, "%s~",filename); - rename(filename, fname); - } - - return true; - } - - // file does not exist, or user permits overwriting - return true; - -}*/ diff --git a/src/output.h b/src/output.h --- a/src/output.h +++ b/src/output.h @@ -1,55 +1,55 @@ -/* - * - * $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 . - * - * Copyright 2010 Roeland Merks. - * - */ - - -#ifndef _OUTPUT_H_ -#define _OUTPUT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int OpenFileAndCheckExistance(FILE **fp,const char *fname,char *ftype); -int YesNoP(const char *message); -FILE *OpenWriteFile(const char *filename); -FILE *OpenGZippedWriteFile(const char *filename); -FILE *OpenReadFile(const char *filename); -char *ReadLine(FILE *fp); -void CheckFile(FILE *fp); -int FileExistsP(const char *fname); -char *Chext(char *filename); -void MakeDir(const char *dirname); -bool CanWeWriteP(char *filename); - -#ifdef __cplusplus -} -#endif - - -#define MESS_BUF_SIZE 160 -#ifndef FALSE -#define FALSE 0 -#define TRUE 1 -#endif - -#endif +/* + * + * $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 . + * + * Copyright 2010 Roeland Merks. + * + */ + + +#ifndef _OUTPUT_H_ +#define _OUTPUT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int OpenFileAndCheckExistance(FILE **fp,const char *fname,char *ftype); +int YesNoP(const char *message); +FILE *OpenWriteFile(const char *filename); +FILE *OpenGZippedWriteFile(const char *filename); +FILE *OpenReadFile(const char *filename); +char *ReadLine(FILE *fp); +void CheckFile(FILE *fp); +int FileExistsP(const char *fname); +char *Chext(char *filename); +void MakeDir(const char *dirname); +bool CanWeWriteP(char *filename); + +#ifdef __cplusplus +} +#endif + + +#define MESS_BUF_SIZE 160 +#ifndef FALSE +#define FALSE 0 +#define TRUE 1 +#endif + +#endif diff --git a/src/parse.cpp b/src/parse.cpp --- a/src/parse.cpp +++ b/src/parse.cpp @@ -71,8 +71,7 @@ char *ParsePar(FILE *fp, char *parameter int igetpar(FILE *fp,char *parameter, bool wrapflag) { // overloaded compatibility function. Doesn't need default parameter - // default = 0 - + return igetpar(fp, parameter, 0, wrapflag); } @@ -102,10 +101,7 @@ int igetpar(FILE *fp,char *parameter, in float fgetpar(FILE *fp,char *parameter, bool wrapflag) { // overloaded compatibility function. Doesn't need default parameter - // default = 0 - return fgetpar(fp, parameter, 0., wrapflag); - } float fgetpar(FILE *fp, char *parameter, double default_val, bool wrapflag) @@ -296,8 +292,6 @@ char *SearchToken(FILE *fp, char *token, int wrapped=false; long initial_position; - /* rewind(fp); */ - char *tokenplusspace = (char *)malloc( (strlen(token)+3)*sizeof(char)); strcpy(tokenplusspace, token); strcat(tokenplusspace," "); diff --git a/src/parse.h b/src/parse.h --- a/src/parse.h +++ b/src/parse.h @@ -1,46 +1,46 @@ -/* - * - * $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 . - * - * Copyright 2010 Roeland Merks. - * - */ - - -#ifndef _PARSE_H_ -#define _PARSE_H_ - -char *ParsePar(FILE *fp, char *parameter, bool wrapflag); -int igetpar(FILE *fp,char *parameter, bool wrapflag); -int igetpar(FILE *fp,char *parameter, int default_val, bool wrapflag); -float fgetpar(FILE *fp,char *parameter, bool wrapflag); -float fgetpar(FILE *fp,char *parameter, double default_val, bool wrapflag); - -/* Get a list of n comma separated doubles */ -double *dgetparlist(FILE *fp,char *parameter, int n, bool wrapflag); -char *sgetpar(FILE *fp,char *parameter, bool wrapflag); -char *sgetpar(FILE *fp,char *parameter,const char *default_val, bool wrapflag); -bool bgetpar(FILE *fp, char *parameter, bool wrapflag); -bool bgetpar(FILE *fp, char *parameter, int default_val, bool wrapflag); -char *SearchToken(FILE *fp, char *token, bool wrapflag); -int TokenInLineP(char *line,char *token); -void SkipToken(FILE *fp,char *token, bool wrapflag); -void SkipLine(FILE *fp); -char *bool_str(bool bool_var); - -#endif +/* + * + * $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 . + * + * Copyright 2010 Roeland Merks. + * + */ + + +#ifndef _PARSE_H_ +#define _PARSE_H_ + +char *ParsePar(FILE *fp, char *parameter, bool wrapflag); +int igetpar(FILE *fp,char *parameter, bool wrapflag); +int igetpar(FILE *fp,char *parameter, int default_val, bool wrapflag); +float fgetpar(FILE *fp,char *parameter, bool wrapflag); +float fgetpar(FILE *fp,char *parameter, double default_val, bool wrapflag); + +/* Get a list of n comma separated doubles */ +double *dgetparlist(FILE *fp,char *parameter, int n, bool wrapflag); +char *sgetpar(FILE *fp,char *parameter, bool wrapflag); +char *sgetpar(FILE *fp,char *parameter,const char *default_val, bool wrapflag); +bool bgetpar(FILE *fp, char *parameter, bool wrapflag); +bool bgetpar(FILE *fp, char *parameter, int default_val, bool wrapflag); +char *SearchToken(FILE *fp, char *token, bool wrapflag); +int TokenInLineP(char *line,char *token); +void SkipToken(FILE *fp,char *token, bool wrapflag); +void SkipLine(FILE *fp); +char *bool_str(bool bool_var); + +#endif diff --git a/src/random.cpp b/src/random.cpp --- a/src/random.cpp +++ b/src/random.cpp @@ -141,24 +141,9 @@ int Randomize(void) { seed=abs((int)((t.time*t.millitm)%655337)); Seed(seed); - fprintf(stderr,"Random seed is %d\n",seed); +#ifdef QDEBUG + qdebug() << "Random seed is " << seed << endl; +#endif return seed; } -/** TESTING random generator -#include -#include -int main(void) { - - MyUrand r(-1); - - vector bucket(100); - for (int i = 0; i<1000000 ; i++) { - bucket[r(100)]++; - } - ofstream out("randomtest.dat"); - for (int i = 0; i<=100; i++) { - out << i << " " << bucket[i] << endl; - } -} -***/ diff --git a/src/random.h b/src/random.h --- a/src/random.h +++ b/src/random.h @@ -1,66 +1,66 @@ -/* - * - * $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 . - * - * Copyright 2010 Roeland Merks. - * - */ - - -#ifndef _RANDOM_H_ -#define _RANDOM_H_ - -#define MBIG 1000000000 -#define MSEED 161803398 -#define MZ 0 -#define FAC (1.0/MBIG) - -double RANDOM(); -int Seed(int seed); -long RandomNumber(long max); -void AskSeed(); -int Randomize(void); -int RandomCounter(void); - - - -// Class MyUrand, so we can pass the random generator to STL's random_shuffle, -// and get identical simulations for a given random seed. -class MyUrand { - - long n; - public: - MyUrand(long nn) { - n=nn; - } - MyUrand(void){}; - - void seed(long s) { - Seed(s); - } - - long operator()(long nn) { return RandomNumber(nn)-1; } - long operator()(void) { return RandomNumber(n); } -}; - - - - - - -#endif +/* + * + * $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 . + * + * Copyright 2010 Roeland Merks. + * + */ + + +#ifndef _RANDOM_H_ +#define _RANDOM_H_ + +#define MBIG 1000000000 +#define MSEED 161803398 +#define MZ 0 +#define FAC (1.0/MBIG) + +double RANDOM(); +int Seed(int seed); +long RandomNumber(long max); +void AskSeed(); +int Randomize(void); +int RandomCounter(void); + + + +// Class MyUrand, so we can pass the random generator to STL's random_shuffle, +// and get identical simulations for a given random seed. +class MyUrand { + + long n; + public: + MyUrand(long nn) { + n=nn; + } + MyUrand(void){}; + + void seed(long s) { + Seed(s); + } + + long operator()(long nn) { return RandomNumber(nn)-1; } + long operator()(void) { return RandomNumber(n); } +}; + + + + + + +#endif diff --git a/src/sqr.h b/src/sqr.h --- a/src/sqr.h +++ b/src/sqr.h @@ -26,13 +26,6 @@ #ifndef _SQR_H_ #define _SQR_H_ -/* static float sqrarg; -#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg) - -static double dsqrarg; -#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg) -*/ - // redefine these macros as inline functions, to prevent scary // behavior. (According to compiler warnings, the above macros from diff --git a/src/vector.h b/src/vector.h --- a/src/vector.h +++ b/src/vector.h @@ -118,7 +118,6 @@ public: Vector operator*(const Vector &v) const; // cross product bool operator==(const Vector &v) const; // comparison bool operator< (const Vector &v) const; // order x,y,z - //double Norm(void) const; // gives the "norm" (| v |) of v inline double Norm(void) const { return sqrt(DSQR(x)+DSQR(y)+DSQR(z)); diff --git a/src/vleafmodel.h b/src/vleafmodel.h --- a/src/vleafmodel.h +++ b/src/vleafmodel.h @@ -1,12 +1,29 @@ /* - * vleafmodel.h - * mymodel + * + * $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. * - * Created by Roeland Merks on 08-06-10. - * Copyright 2010 __MyCompanyName__. All rights reserved. + * 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 . + * + * Copyright 2010 Roeland Merks. * */ +#ifndef _VLEAFMODEL_H_ +#define _VLEAFMODEL_H_ + #include #include #include @@ -18,3 +35,5 @@ #include "cellbase.h" #include "mymodel.h" #include "flux_function.h" + +#endif diff --git a/src/wall.cpp b/src/wall.cpp --- a/src/wall.cpp +++ b/src/wall.cpp @@ -49,13 +49,6 @@ bool Wall::CorrectWall( void ) { duplicates_copy( owners.begin(), owners.end(), back_inserter(wall_owners) ); // duplicates are the cells to which the Wall belongs - /* cerr << "Wall belongs to Cells: "; - transform(wall_owners.begin(), wall_owners.end(), ostream_iterator(cerr, ", "), mem_fun(&Cell::Index)); - cerr << endl; - */ - - //list::iterator f = adjacent_find (++e,owners.end()); - // 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; @@ -214,9 +207,6 @@ void Wall::ShowStructure(QGraphicsScene text1->setPen ( QColor(par.textcolor) ); text2->setPen ( text1->pen() ); - - //text1->setTextFlags(Qt::AlignCenter); - //text2->setTextFlags(Qt::AlignCenter); text1->show(); text2->show(); } diff --git a/src/wallbase.cpp b/src/wallbase.cpp --- a/src/wallbase.cpp +++ b/src/wallbase.cpp @@ -78,7 +78,6 @@ WallBase::WallBase(Node *sn1, Node *sn2, apoplast = new double[CellBase::NChem()]; // not yet in use. - //length = 0; SetLength(); // to visualize flux through WallBase @@ -170,10 +169,6 @@ bool WallBase::SAM_P(void) { #include -/* double WallBase::Length(void){ - return (*n2 - *n1).Norm(); - }*/ - void WallBase::SetLength(void) { //static bool show_nodes = true; @@ -203,11 +198,6 @@ void WallBase::SetLength(void) { n!=second_node_edge_plus_1; (++n == c1->nodes.end()) ? (n=c1->nodes.begin()):n ) { - /* if (n==c1->nodes.end()) { - - n=c1->nodes.begin(); // wrap around - }*/ - list::const_iterator prev_n = n; if (prev_n==c1->nodes.begin()) prev_n=c1->nodes.end(); --prev_n; @@ -222,25 +212,12 @@ void WallBase::SetLength(void) { length += (*(*prev_n) - *(*n)).Norm(); } - - /* if (length > 100) { - ostringstream warn; - warn << "Strange, length is " << length << "...: " << deb_str.str() << endl; - warn << "Strangeness in WallBase: " << *this << endl << endl << deb_str.str() << endl; - MyWarning::warning (warn.str().c_str()); - }*/ - - //cerr << deb_str .str() << ", length is " << length << endl; - //of << length << " " << ((*n2)-(*n1)).Norm() << endl; - - } void WallBase::CorrectTransporters(double orig_length) { double length_factor = length / orig_length; - // cerr << "[ lf = " << length_factor << "]"; - //cerr << "Correcting amount of transporters on WallBase " << *this << ", length factor is " << orig_length << " / " << length << endl; + for (int ch=0;ch=0. && ua <=1.) return true; @@ -309,5 +274,3 @@ bool WallBase::IntersectsWithDivisionPla } - - diff --git a/src/wallbase.h b/src/wallbase.h --- a/src/wallbase.h +++ b/src/wallbase.h @@ -191,57 +191,11 @@ public: */ Vector VizFlux(void); bool IntersectsWithDivisionPlaneP(const Vector &p1, const Vector &p2); - - /*! Function to be defined in leaf.cpp */ - //void OnWallInsert(void); - - - void SetTransToNewTrans( void ); - // implemented in xmlwrite.cpp - //void XMLAdd(xmlNode *parent) const; private: }; -/* class TransportFunction { - - friend class Mesh; -public: - TransportFunction( void ); - virtual ~TransportFunction() { - //delete[] chem_change_c1; - //delete[] chem_change_c2; - } - virtual void operator()(WallBase *w, double *dchem_c1, double *dchem_c2) = 0;// { cerr << "This is base class TransportFunction.\n"; } - //virtual void operator()(WallBase *w, double *dchem_c1, double *dchem_c2, double *dapo) =0; -protected: - int wall_index; //double *chem_change_c1; - //double *chem_change_c2; -}; - -class CellReaction { - -public: - CellReaction(void) {}; - virtual ~CellReaction() {}; - - //! Implements the actual, intracellular chemical reactions. - virtual void operator()(CellBase * c, double *dchem ) = 0; - -}; - -class WallReaction { - -public: - WallReaction(void) {}; - virtual ~WallReaction() {}; - - //! Implements the actual, biochemical reactions occuring at the wall. - virtual void operator()(WallBase *, double *dw1, double *dw2) = 0; - -};*/ - ostream &operator<<(ostream &os, const WallBase &w); #endif diff --git a/src/wallitem.cpp b/src/wallitem.cpp --- a/src/wallitem.cpp +++ b/src/wallitem.cpp @@ -37,22 +37,7 @@ WallItem::WallItem( Wall *w, int wallnum wn = wallnumber; extern Parameter par; - //Wall *w=&getWall(); - - // Draw amount of "PIN1" - //double val = wn==1?(w->Transporters1(1)/par.Pi_tot)*255.:(w->Transporters2(1)/par.Pi_tot)*255.; - - /* if (val > 255 || val < 0 ) { - std::cerr << "val = " << val << endl; - if (wn == 1) { - std::cerr << "Transporters1(1) = " << w->Transporters1(1) << endl; - } else { - std::cerr << "Transporters2(1) = " << w->Transporters2(1) << endl; - } - - }*/ - - + setColor(); // line with "PIN1"is a bit inside the cell wall @@ -70,18 +55,6 @@ WallItem::WallItem( Wall *w, int wallnum Vector centroid = ( offs + tmp_centroid ) * factor; QString text=QString("%1").arg(w->Index()); - - /* if (0) { - QGraphicsSimpleTextItem *ctext = new QGraphicsSimpleTextItem ( text, 0, canvas ); - ctext->setPen( QPen(QColor("orange")) ); - ctext->setZValue(20); - ctext->setFont( QFont( "Helvetica", par.nodenumsize, QFont::Bold) ); - //ctext->setTextFlags(Qt::AlignCenter); - ctext->show(); - ctext ->setPos(centroid.x, - centroid.y ); - }*/ - setLine(( from.x ), ( from.y ), ( to.x ), @@ -100,13 +73,6 @@ void WallItem::setColor(void) { double tr = wn==1?w->Transporters1(1):w->Transporters2(1); CellBase *c = wn==1?w->C1():w->C2(); diffcolor.setRgb( (int)( ( tr / (1 + tr) )*255.), 0, 0); - //diffcolor.setRgb( (int)( ((wn==1?w->Transporters1(1):w->Transporters2(1)))*255.), 0, 0); - /* if (wn==1) { - cerr << "Transporter: " << w->Transporters1(1) << endl; - } else { - cerr << "Transporter: " << w->Transporters2(1) << endl; - }*/ - if (w->AuxinSource() && c->BoundaryPolP()) { setPen( QPen(purple , par.outlinewidth) ); } else { @@ -116,10 +82,6 @@ void WallItem::setColor(void) { setPen (QPen(diffcolor, par.outlinewidth) ); } } - -// if (c->BoundaryPolP()) { -// setPen(QPen(QColor("red"), 20)); -// } } void WallItem::OnClick(QMouseEvent *e) { @@ -132,7 +94,6 @@ void WallItem::OnClick(QMouseEvent *e) { 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); @@ -147,7 +108,6 @@ void WallItem::OnClick(QMouseEvent *e) { } //extern MainBase *main_window; - //((Main *)main_window)->UserMessage(message); } else { if (e->button() == Qt::LeftButton) { @@ -166,11 +126,5 @@ void WallItem::OnClick(QMouseEvent *e) { setColor(); update(boundingRect()); } - /* else { - if (e->button() == Qt::MidButton && (e->modifiers == Qt::ShiftModifier & Qt::ControlModifier)) { - // hidden feature for correcting - }*/ - - } } diff --git a/src/wallitem.h b/src/wallitem.h --- a/src/wallitem.h +++ b/src/wallitem.h @@ -42,8 +42,6 @@ public: virtual ~WallItem() {} Wall &getWall(void) const { return *class_cast(obj); } void OnClick(QMouseEvent *e); - //virtual void userMove(double dx, double dy); - //virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); void setColor(void); private: int wn; diff --git a/src/warning.cpp b/src/warning.cpp --- a/src/warning.cpp +++ b/src/warning.cpp @@ -66,8 +66,6 @@ void MyWarning::error(const char *fmt, . QString qmess(message); - // bool batch = false; - if (qApp->type()==QApplication::Tty) { // batch mode: print the message to stderr fprintf(stderr, "Fatal error: %s\n",qmess.toStdString().c_str()); diff --git a/src/warning.h b/src/warning.h --- a/src/warning.h +++ b/src/warning.h @@ -1,60 +1,47 @@ -/* - * - * $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 . - * - * Copyright 2010 Roeland Merks. - * - */ - - -#ifndef _WARNING_H_ -#define _WARNING_H_ - -#define MEMORYCHECK(x) if ((x)==NULL) { fprintf(stderr, "Out of Memory error in "#x" \n"); exit(0); } - -#define UNIDENTIFIED 2353996 -//static int last_value=UNIDENTIFIED; -/*#define WATCH(x) if (last_value==UNIDENTIFIED) { last_value=x; -} else { if (x!=last_value) { fprintf(stderr,"WATCH value changed. Suspending execution. \n Interrupt within debugger to examine position in program.\n"); - last_value=x; - while(1); - } else { - last_value=x; - } - }*/ - - -/* These functions were a gift from Josh Barnes */ -/* I changed the name "eprintf" to "warning" */ - -#ifdef __cplusplus -extern "C" { -#endif - // namespace MyWarning needed because libxml2 also defines a warning token. - - namespace MyWarning { - void error(const char *, ...); - void warning(const char *, ...); - void unique_warning(const char *, ...); - } - -#ifdef __cplusplus -} -#endif - -#endif +/* + * + * $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 . + * + * Copyright 2010 Roeland Merks. + * + */ + + +#ifndef _WARNING_H_ +#define _WARNING_H_ + +#define MEMORYCHECK(x) if ((x)==NULL) { fprintf(stderr, "Out of Memory error in "#x" \n"); exit(0); } + +#define UNIDENTIFIED 2353996 + +#ifdef __cplusplus +extern "C" { +#endif + // namespace MyWarning needed because libxml2 also defines a warning token. + + namespace MyWarning { + void error(const char *, ...); + void warning(const char *, ...); + void unique_warning(const char *, ...); + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/xmlwrite.cpp b/src/xmlwrite.cpp --- a/src/xmlwrite.cpp +++ b/src/xmlwrite.cpp @@ -187,7 +187,6 @@ void Cell::XMLAddCore(xmlNodePtr xmlcell { ostringstream text; xmlNodePtr wall_xml = xmlNewChild(xmlcell, NULL, BAD_CAST "wall", NULL); - //text <walls.begin(), m->walls.end(), *i ); xmlNewProp(wall_xml, BAD_CAST "w", BAD_CAST text.str().c_str()); } @@ -362,7 +361,6 @@ int Cell::XMLRead(xmlNode *cur) { { stringstream text; text << "Exception in Mesh::XMLRead: Too many chemical values given for cell(s). Ignoring remaining values."; - //ThrowStringStream(text); unique_warning(text.str().c_str()); break; } @@ -373,7 +371,6 @@ int Cell::XMLRead(xmlNode *cur) { if (nc==0) { unique_warning("Token \"v\" not found in xmlwrite.cpp at or around line no. 1002"); } - //double v = strtod( (char *)nc, 0 ); double v=standardlocale.toDouble((char *)nc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(char *)nc); chem[nv++]=v; @@ -393,7 +390,6 @@ int Cell::XMLRead(xmlNode *cur) { unique_warning("Token \"area\" not found in xmlwrite.cpp at or around line no. 1018"); } if (v_str != NULL) { - //area = strtod( (char *)v_str, 0); area=standardlocale.toDouble((char *)v_str, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(char *)v_str); xmlFree(v_str); @@ -407,7 +403,6 @@ int Cell::XMLRead(xmlNode *cur) { unique_warning("Token \"target_area\" not found in xmlwrite.cpp at or around line no. 1029"); } if (v_str != NULL) { - //target_area = strtod( (char *)v_str, 0); target_area=standardlocale.toDouble((char *)v_str, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(char *)v_str); xmlFree(v_str); @@ -422,7 +417,6 @@ int Cell::XMLRead(xmlNode *cur) { unique_warning("Token \"target_length\" not found in xmlwrite.cpp at or around line no. 1041"); } if (v_str != NULL) { - //target_length = strtod( (char *)v_str, 0); target_length=standardlocale.toDouble((char *)v_str, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(char *)v_str); xmlFree(v_str); @@ -436,7 +430,6 @@ int Cell::XMLRead(xmlNode *cur) { unique_warning("Token \"lambda_celllength\" not found in xmlwrite.cpp at or around line no. 1052"); } if (v_str != NULL) { - //lambda_celllength = strtod( (char *)v_str, 0); lambda_celllength=standardlocale.toDouble((char *)v_str, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(char *)v_str); xmlFree(v_str); @@ -450,7 +443,6 @@ int Cell::XMLRead(xmlNode *cur) { unique_warning("Token \"stiffness\" not found in xmlwrite.cpp at or around line no. 1063"); } if (v_str != NULL) { - //stiffness = strtod( (char *)v_str, 0); stiffness=standardlocale.toDouble((char *)v_str, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(char *)v_str); xmlFree(v_str); @@ -598,12 +590,6 @@ void Wall::XMLAdd(xmlNode *parent) const // Save the node to a stream so we can reconstruct its state later xmlNodePtr xmlwall = xmlNewChild(parent, NULL, BAD_CAST "wall",NULL); - /* { - ostringstream text; - text << index; - xmlNewProp(xmlnode, BAD_CAST "index", BAD_CAST text.str().c_str()); - }*/ - { ostringstream text; text << Index(); @@ -657,12 +643,6 @@ void Wall::XMLAdd(xmlNode *parent) const xmlNodePtr tr1_xml = xmlNewChild(xmlwall, NULL, BAD_CAST "transporters1", NULL); - // { - // ostringstream text; - // text << Cell::nchem; - // xmlNewProp(tr1_xml, BAD_CAST "n", BAD_CAST text.str().c_str()); - // } - if (transporters1) { for (int i=0;inext; } - //cur = root_node; // allocate Cells cur = root_node; @@ -975,10 +957,10 @@ void Mesh::XMLReadGeometry(const xmlNode if ((!xmlStrcmp(cur->name, (const xmlChar *)"cells"))){ xmlChar *offsetxc = xmlGetProp(cur, BAD_CAST "offsetx"); xmlChar *offsetyc = xmlGetProp(cur, BAD_CAST "offsety"); - //double ox = strtod((const char*)offsetxc, 0); + double ox=standardlocale.toDouble((const char *)offsetxc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)offsetxc); - //double oy = strtod((const char*)offsetyc, 0); + double oy=standardlocale.toDouble((const char *)offsetyc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)offsetyc); Cell::setOffset(ox, oy); @@ -986,13 +968,13 @@ void Mesh::XMLReadGeometry(const xmlNode xmlFree(offsetyc); xmlChar *magnificationc = xmlGetProp(cur, BAD_CAST "magnification"); - //Cell::SetMagnification(strtod((const char*)magnificationc, 0 )); + Cell::SetMagnification(standardlocale.toDouble((const char *)magnificationc, &ok)); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)magnificationc); xmlFree(magnificationc); xmlChar *baseareac = xmlGetProp(cur, BAD_CAST "base_area"); - //Cell::BaseArea()= strtod((const char *)baseareac, 0 ); + Cell::BaseArea() = standardlocale.toDouble((const char *)baseareac, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)baseareac); xmlFree(baseareac); @@ -1071,7 +1053,7 @@ void Mesh::XMLReadNodes(xmlNode *root) { xmlChar *tlc = xmlGetProp(root, BAD_CAST "target_length"); if (tlc != 0) { - //Node::target_length = strtod( (const char *)tlc, 0 ); + Node::target_length = standardlocale.toDouble((const char *)tlc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)tlc); @@ -1112,11 +1094,10 @@ void Mesh::XMLReadNodes(xmlNode *root) { unique_warning("Token \"sam\" not found in xmlwrite.cpp at or around line."); } - //double x = strtod( (char *)xc , 0); + double x = standardlocale.toDouble((const char *)xc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)xc); - //double y = strtod( (char *)yc , 0 ); double y = standardlocale.toDouble((const char *)yc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)yc); @@ -1162,8 +1143,6 @@ void Mesh::XMLReadWalls(xmlNode *root, v walls.clear(); Wall::nwalls = 0; tmp_walls->clear(); - //Node::nnodes=0; - QLocale standardlocale(QLocale::C); bool ok; @@ -1211,7 +1190,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v if ( nc==0) { unique_warning("Token \"length\" not found in xmlwrite.cpp at or around line no. 809"); } - //double length = strtod( (char *)nc, 0); + double length = standardlocale.toDouble((const char *)nc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)nc); @@ -1222,7 +1201,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v double viz_flux = 0.0; if (nc!=0) { - //viz_flux = strtod( (char *)nc, 0); + viz_flux = standardlocale.toDouble((const char *)nc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)nc); } @@ -1288,7 +1267,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v { stringstream text; text << "Exception in Mesh::XMLRead: Too many transporter values given for wall(s). Ignoring remaining values."; - //ThrowStringStream(text); + unique_warning(text.str().c_str()); break; } @@ -1298,7 +1277,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v if (nc==0) { unique_warning("Token \"v\" not found in xmlwrite.cpp at or around line no. 835"); } - //double v = strtod( (char *)nc, 0 ); + double v = standardlocale.toDouble((const char *)nc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)nc); @@ -1324,7 +1303,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v text << "Exception in Mesh::XMLRead: Too many transporter values given for wall(s). Ignoring remaining values."; unique_warning(text.str().c_str()); break; - // ThrowStringStream(text); + } } @@ -1333,7 +1312,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v if (nc==0) { unique_warning("Token \"v\" not found in xmlwrite.cpp at or around line no. 861"); } - //double v = strtod( (char *)nc, 0 ); + double v = standardlocale.toDouble((const char *)nc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)nc); @@ -1356,7 +1335,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v { stringstream text; text << "Exception in Mesh::XMLRead: Too many transporter values given for wall(s). Ignoring remaining values."; - //ThrowStringStream(text); + unique_warning(text.str().c_str()); break; } @@ -1366,7 +1345,7 @@ void Mesh::XMLReadWalls(xmlNode *root, v if (nc==0) { unique_warning("Token \"v\" not found in xmlwrite.cpp at or around line no. 887"); } - //double v = strtod( (char *)nc, 0 ); + double v = standardlocale.toDouble((const char *)nc, &ok); if (!ok) MyWarning::error("Could not convert \"%s\" to double in XMLRead.",(const char *)nc); @@ -1375,17 +1354,13 @@ void Mesh::XMLReadWalls(xmlNode *root, v } v_node = v_node->next; } - } w_node=w_node->next; } - } cur = cur->next; } - } - // CleanUpWalls(); } @@ -1402,8 +1377,6 @@ void Mesh::XMLReadWallsToCells(xmlNode * while (cur!=NULL) { - //Cell *new_cell=0; - if ((!xmlStrcmp(cur->name, (const xmlChar *)"cell")) || (!xmlStrcmp(cur->name, (const xmlChar *)"boundary_polygon" ))) { @@ -1584,12 +1557,10 @@ void Mesh::XMLRead(const char *docname, /*Get the root element node */ xmlNode *root_element = xmlDocGetRootElement(doc); - - //XMLParseTree(root_element); + if (geometry) XMLReadGeometry(root_element); if (pars) XMLReadPars(root_element); if (simtime) XMLReadSimtime(root_element); - //print_element_names(root_element); // If pointer settings defined, return a copy of the settings tree if (settings) { @@ -1617,11 +1588,6 @@ void Mesh::XMLRead(const char *docname, } -/* int Mesh::XMLReadWall(xmlNode *cur) { - - - return w; - }*/ void Parameter::XMLRead(xmlNode *root) { xmlNode *cur = root->xmlChildrenNode;