# HG changeset patch # User Michael Guravage # Date 2010-06-15 11:06:33 # Node ID 18e4f7f50259418d7bf744bad8782bfd803328c6 # Parent 5fe3d9e82275508aeebe95504c9066ffa2e4cb89 Wrapped diagnostic messages in QDEBUG blocks. Information messages still go to stderr. -- user: Michael Guravage branch 'default' changed src/ChangeLog changed src/VirtualLeaf.cpp changed src/build_models/Makefile changed src/canvas.cpp changed src/cell.cpp changed src/cellbase.h changed src/data_plot.cpp changed src/forwardeuler.cpp changed src/mesh.cpp changed src/mesh.h changed src/random.cpp changed src/wall.cpp changed src/wallbase.cpp changed src/wallitem.cpp diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2010-06-15 + + * cell.cpp: Wrapped diagnostic output in QDEBUG blocks. + * VirtualLeaf.cpp ditto. + * canvas.cpp ditto. + * cell.cpp ditto. + * cellbase.h + * data_plot.cpp ditto. + * forwardeuler.cpp ditto. + * mesh.cpp ditto. + * mesh.h + * random.cpp ditto. + * wall.cpp ditto. + * wallbase.cpp ditto. + * wallitem.cpp ditto. + + 2010-06-07 * VirtualLeaf.pro: Removed explicit perl invocation to regerenerate parameter files. diff --git a/src/VirtualLeaf.cpp b/src/VirtualLeaf.cpp --- a/src/VirtualLeaf.cpp +++ b/src/VirtualLeaf.cpp @@ -58,8 +58,8 @@ #include "modelcatalogue.h" /* #define _xstr_(s) _str_(s) -#define _str_(s) #s -#include _xstr_(REACTIONS_HEADER) + #define _str_(s) #s + #include _xstr_(REACTIONS_HEADER) */ static const std::string _module_id("$Id$"); @@ -70,7 +70,6 @@ MainBase *main_window = 0; //double auxin_account = 0.; - #ifdef XFIGGRAPHICS #define TIMESTEP double Graphics::TimeStep(void) #endif @@ -96,7 +95,6 @@ public: cerr << "Cell " << c.Index() << " is _not_ a source cell.\n"; } } - }; @@ -116,9 +114,7 @@ public: }; double PINSum(Cell &c) { - - return c.Chemical(1) + c.SumTransporters(1);// + c.ReduceCellAndWalls( complex_PijAj ); - + return c.Chemical(1) + c.SumTransporters(1);// + c.ReduceCellAndWalls( complex_PijAj ); } @@ -131,30 +127,24 @@ public: QString info_string=QString("Cell %1, chemicals: ( %2, %3, %4, %5, %6)\n %7 of PIN1 at walls.\n Area is %8\n PIN sum is %9\n Circumference is %10\n Boundary type is %11").arg(c.Index()).arg(c.Chemical(0)).arg(c.Chemical(1)).arg(c.Chemical(2)).arg(c.Chemical(3)).arg(c.Chemical(4)).arg(c.SumTransporters(1)).arg(c.Area()).arg(PINSum(c)).arg(c.Circumference()).arg(c.BoundaryStr()); info_string += "\n" + c.printednodelist(); - c.Draw(&canvas, info_string); } else { c.Draw(&canvas); } if (m.ShowCentersP()) c.DrawCenter(&canvas); - if (m.ShowFluxesP()) + if (m.ShowFluxesP()) c.DrawFluxes(&canvas, par.arrowsize); - - } - + } } - }; Mesh mesh; bool batch=false; - void MainBase::Plot(int resize_stride) { clear(); - static int count=0; if (resize_stride) { @@ -176,83 +166,79 @@ void MainBase::Plot(int resize_stride) { mesh.LoopCells( bind2nd (mem_fun_ref ( &Cell::DrawStrain), &canvas ) ); if (ShowWallsP()) - mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::Draw ), &canvas ) ); - if (ShowApoplastsP()) - mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::DrawApoplast ), &canvas ) ); + if (ShowApoplastsP()) + mesh.LoopWalls( bind2nd( mem_fun_ref( &Wall::DrawApoplast ), &canvas ) ); - if (ShowMeshP()) + if (ShowMeshP()) mesh.DrawNodes(&canvas); if (ShowBoundaryOnlyP()) mesh.DrawBoundary(&canvas); - - if ( ( batch || MovieFramesP() )) { + if ( ( batch || MovieFramesP() )) { - static int frame = 0; - // frame numbers are sequential for the most frequently written file type. - // for the less frequently written file type they match the other type - if (!(count%par.storage_stride) ) { + static int frame = 0; + // frame numbers are sequential for the most frequently written file type. + // for the less frequently written file type they match the other type + if (!(count%par.storage_stride) ) { - stringstream fname; - fname << par.datadir << "/leaf."; - fname.fill('0'); - fname.width(6); + stringstream fname; + fname << par.datadir << "/leaf."; + fname.fill('0'); + fname.width(6); - /* - fname << frame << ".pdf"; - if (par.storage_stride <= par.xml_storage_stride) { - frame++; - } + /* + fname << frame << ".pdf"; + if (par.storage_stride <= par.xml_storage_stride) { + frame++; + } - // Write high-res JPG snapshot every plot step - Save(fname.str().c_str(), "PDF"); - */ + // Write high-res JPG snapshot every plot step + Save(fname.str().c_str(), "PDF"); + */ - fname << frame << ".jpg"; - if (par.storage_stride <= par.xml_storage_stride) { - frame++; - } + fname << frame << ".jpg"; + if (par.storage_stride <= par.xml_storage_stride) { + frame++; + } - // Write high-res JPG snapshot every plot step - Save(fname.str().c_str(), "JPEG",1024,768); - - } + // Write high-res JPG snapshot every plot step + Save(fname.str().c_str(), "JPEG",1024,768); + } - if (!(count%par.xml_storage_stride)) { - stringstream fname; - fname << par.datadir << "/leaf."; - fname.fill('0'); - fname.width(6); - fname << frame << ".xml"; + if (!(count%par.xml_storage_stride)) { + stringstream fname; + fname << par.datadir << "/leaf."; + fname.fill('0'); + fname.width(6); + fname << frame << ".xml"; - if (par.xml_storage_stride < par.storage_stride) { - frame++; - } - // Write XML file every ten plot steps - mesh.XMLSave(fname.str().c_str(), XMLSettingsTree()); - } - - } + if (par.xml_storage_stride < par.storage_stride) { + frame++; + } + // Write XML file every ten plot steps + mesh.XMLSave(fname.str().c_str(), XMLSettingsTree()); + } + } } INIT { - //mesh.SetSimPlugin(plugin); - if (leaffile) { - xmlNode *settings; - mesh.XMLRead(leaffile, &settings); + //mesh.SetSimPlugin(plugin); + if (leaffile) { + xmlNode *settings; + mesh.XMLRead(leaffile, &settings); main_window->XMLReadSettings(settings); xmlFree(settings); main_window->UserMessage(QString("Ready. Time is %1").arg(mesh.getTimeHours().c_str())); } else { - mesh.StandardInit(); + mesh.StandardInit(); } } @@ -283,51 +269,46 @@ TIMESTEP { if ( (-dh) < par.energy_threshold) { - mesh.IncreaseCellCapacityIfNecessary(); - mesh.DoCellHouseKeeping(); - //mesh.LoopCurrentCells(mem_fun(&plugin->CellHouseKeeping)); // this includes cell division + mesh.IncreaseCellCapacityIfNecessary(); + mesh.DoCellHouseKeeping(); + //mesh.LoopCurrentCells(mem_fun(&plugin->CellHouseKeeping)); // this includes cell division // Reaction diffusion - /*CelltoCellTransport *transport_f = &TestPlugin::CelltoCellTransport; - CellReaction *cellreaction_f = new plugin->CellDynamics(); - WallReaction *wall_f = new WallDynamics();*/ + /*CelltoCellTransport *transport_f = &TestPlugin::CelltoCellTransport; + CellReaction *cellreaction_f = new plugin->CellDynamics(); + WallReaction *wall_f = new WallDynamics();*/ mesh.ReactDiffuse(par.rd_dt); - t++; Plot(par.resize_stride); - /*QVector< QPair > angles=mesh.VertexAnglesValues(); - QString afname=QString("Angles/anglesvalues%1.dat").arg(t,6,10,QChar('0')); - ofstream af(afname.toStdString().c_str()); - */ + /*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; - } - */ - } + /*for (QVector< QPair >::const_iterator v=angles.begin(); + v!=angles.end(); + v++) { + af << v->first << " " << v->second << endl; + } + */ + } - } else { + } else { - /* TransportFunction *transport_f = new CelltoCellTransport(); - CellReaction *cellreaction_f = new CellDynamics(); - WallReaction *wall_f = new WallDynamics(); + /* TransportFunction *transport_f = new CelltoCellTransport(); + CellReaction *cellreaction_f = new CellDynamics(); + WallReaction *wall_f = new WallDynamics(); - mesh.ReactDiffuse_New(transport_f, cellreaction_f, wall_f, par.rd_dt);*/ - mesh.ReactDiffuse(par.rd_dt); + mesh.ReactDiffuse_New(transport_f, cellreaction_f, wall_f, par.rd_dt);*/ + mesh.ReactDiffuse(par.rd_dt); Plot(par.resize_stride); } - - - - i++; return mesh.getTime(); @@ -339,42 +320,42 @@ TIMESTEP { /* Called if a cell is clicked */ void Cell::OnClick(QMouseEvent *e) { /* #ifdef HAVE_QWT - // Launch DataPlot window - QStringList curvenames; - for (int i=0;iOnClick(*this); + // Launch DataPlot window + QStringList curvenames; + for (int i=0;iOnClick(*this); } /* Custom message handler - Default appends a newline character to the end of each line. */ - void vlMessageOutput(QtMsgType type, const char *msg) - { - switch (type) { - case QtDebugMsg: - //fprintf(stderr, "Debug: %s\n", msg); - cerr << msg << flush; - break; - case QtWarningMsg: - //fprintf(stderr, "Warning: %s\n", msg); - cerr << "Warning: " << msg << flush; - break; - case QtCriticalMsg: - fprintf(stderr, "Critical: %s\n", msg); - cerr << "Critical: " << msg << flush; - break; - case QtFatalMsg: - //fprintf(stderr, "Fatal: %s\n", msg); - cerr << "Fatal: " << msg << flush; - abort(); - } - } +void vlMessageOutput(QtMsgType type, const char *msg) +{ + switch (type) { + case QtDebugMsg: + //fprintf(stderr, "Debug: %s\n", msg); + cerr << msg << flush; + break; + case QtWarningMsg: + //fprintf(stderr, "Warning: %s\n", msg); + cerr << "Warning: " << msg << flush; + break; + case QtCriticalMsg: + fprintf(stderr, "Critical: %s\n", msg); + cerr << "Critical: " << msg << flush; + break; + case QtFatalMsg: + //fprintf(stderr, "Fatal: %s\n", msg); + cerr << "Fatal: " << msg << flush; + abort(); + } +} Parameter par; @@ -470,19 +451,19 @@ int main(int argc,char **argv) { if (useGUI) { - main_window=new Main(canvas, mesh); + main_window=new Main(canvas, mesh); if ( QApplication::desktop()->width() > ((Main *)main_window)->width() + 10 && QApplication::desktop()->height() > ((Main *)main_window)->height() +30 ) { ((Main *)main_window)->show(); ((Main *)main_window)->resize( ((Main *)main_window)->sizeHint()); + } else { + ((Main *)main_window)->showMaximized(); + } } else { - ((Main *)main_window)->showMaximized(); + main_window=new MainBase(canvas, mesh); + } - } else { - main_window=new MainBase(canvas, mesh); - - } @@ -491,15 +472,15 @@ int main(int argc,char **argv) { QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) ); } - // Load plugins - /*QVector plugins = LoadPlugins(); - InstallPlugin(plugins[0], main_window); + // Load plugins + /*QVector plugins = LoadPlugins(); + InstallPlugin(plugins[0], main_window); - cerr << "List of models:" << endl; - foreach (SimPluginInterface *p, plugins) { - cerr << p->ModelID().toStdString() << endl; - } - */ + cerr << "List of models:" << endl; + foreach (SimPluginInterface *p, plugins) { + cerr << p->ModelID().toStdString() << endl; + } + */ // Install model or read catalogue of models @@ -517,11 +498,8 @@ int main(int argc,char **argv) { main_window->FitLeafToCanvas(); - main_window->Plot(); - - if (batch) { double t=0.; do { @@ -554,5 +532,4 @@ int main(int argc,char **argv) { abort(); } } - } diff --git a/src/build_models/Makefile b/src/build_models/Makefile --- a/src/build_models/Makefile +++ b/src/build_models/Makefile @@ -2,7 +2,7 @@ QMAKE = qmake -all: plugin_auxingrowth plugin_leaf plugin_meinhardt plugin_test +all: plugin_auxingrowth plugin_meinhardt plugin_test plugin_auxingrowth: Makefile.plugin_auxingrowth make -f Makefile.plugin_auxingrowth @@ -10,12 +10,6 @@ plugin_auxingrowth: Makefile.plugin_auxi Makefile.plugin_auxingrowth: plugin_auxingrowth.pro $(QMAKE) -makefile -o $@ $< -plugin_leaf: Makefile.plugin_leaf - make -f Makefile.plugin_leaf - -Makefile.plugin_leaf: plugin_leaf.pro - $(QMAKE) -makefile -o $@ $< - plugin_meinhardt: Makefile.plugin_meinhardt make -f Makefile.plugin_meinhardt @@ -30,11 +24,9 @@ Makefile.plugin_test: plugin_test.pro clean: make -f Makefile.plugin_auxingrowth clean - make -f Makefile.plugin_leaf clean make -f Makefile.plugin_meinhardt clean make -f Makefile.plugin_test clean touch plugin_auxingrowth.pro - touch plugin_leaf.pro touch plugin_meinhardt.pro touch plugin_test.pro diff --git a/src/canvas.cpp b/src/canvas.cpp --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -228,8 +229,10 @@ void FigureEditor::mousePressEvent(QMous if ( !item->hit( p ) ) continue; }*/ - cerr << typeid(**it).name() << endl; - + #ifdef QDEBUG + qDebug() << typeid(**it).name() << endl; + #endif QDEBUG + if ( !strcmp(typeid(**it).name(),"8NodeItem")) { //moving = dynamic_cast(*it); //moving = *it; @@ -348,8 +351,9 @@ void FigureEditor::mouseReleaseEvent(QMo if (e->button()==Qt::LeftButton) { if (intersection_line ) { - - cerr << "Trying to cut leaf\n"; + #ifdef QDEBUG + qDebug() << "Trying to cut leaf" << endl; + #endif QPointF sp = intersection_line -> line().p1(); // startpoint //QPointF ep = matrix().inverted().map(e->pos()); // endpoint QPointF ep = mapToScene(e->pos()); @@ -361,7 +365,9 @@ void FigureEditor::mouseReleaseEvent(QMo // no cells selected, do nothing if (intersected_cells.size()==0) { - cerr << "No cells detected :-( \n"; + #ifdef QDEBUG + qDebug() << "No cells detected :-(" << endl; + #endif return; } @@ -388,14 +394,20 @@ void FigureEditor::mouseReleaseEvent(QMo // quickly dragging and releasing division lines... scene()->update(); - cerr << "Dividing Cell " << c.Index() << endl; + #ifdef QDEBUG + qDebug() << "Dividing Cell " << c.Index() << endl; + #endif + c.DivideOverGivenLine( startpoint, endpoint, true, node_set); } node_set->CleanUp(); mesh.AddNodeSet(node_set); - cerr << "Done DivideOverGivenLine\n"; + #ifdef QDEBUG + qDebug() << "Done DivideOverGivenLine" << endl; + #endif + mesh.TestIllegalWalls(); // Do the actual cutting and removing if (intersected_cells.size()) { @@ -425,20 +437,27 @@ void FigureEditor::mouseReleaseEvent(QMo - cerr << "Done CutAwayBelowLine\n"; + #ifdef QDEBUG + qDebug() << "Done CutAwayBelowLine" << endl; + #endif mesh.TestIllegalWalls(); mesh.RepairBoundaryPolygon(); - cerr << "Done RepairBoundaryPolygon\n"; + #ifdef QDEBUG + qDebug() << "Done RepairBoundaryPolygon" << endl; + #endif mesh.TestIllegalWalls(); mesh.CleanUpWalls(); - cerr << "Done CleanUpWalls\n"; + #ifdef QDEBUG + qDebug() << "Done CleanUpWalls" << endl; + #endif mesh.TestIllegalWalls(); } dynamic_cast
(parent())->Plot(); - cerr << "NodeSet of cutting line: " << *node_set << endl; - + #ifdef QDEBUG + qDebug() << "NodeSet of cutting line: " << *node_set << endl; + #endif } } else if (e->button()==Qt::RightButton) { @@ -469,10 +488,15 @@ vector FigureEditor::getInt QList l = intersection_line->collidingItems( ); - cerr << "l.size() = " << l.size() << endl; + #ifdef QDEBUG + qDebug() << "l.size() = " << l.size() << endl; + #endif + for (QList::Iterator it=l.begin(); it!=l.end(); ++it) { - cerr << typeid(**it).name() << endl; + #ifdef QDEBUG + qDebug() << typeid(**it).name() << endl; + #endif if ( !strcmp(typeid(**it).name(),"8CellItem") ) { @@ -534,7 +558,11 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q //canvas(c) { editor = new FigureEditor(canvas,mesh, this); - cerr << "Interactive = " << editor->isEnabled(); + + #ifdef QDEBUG + qDebug() << "Interactive = " << editor->isEnabled(); + #endif + working_dir = 0; QObject::connect( editor, SIGNAL(MousePressed()), this, SLOT(PauseIfRunning())); QObject::connect( editor, SIGNAL(MouseReleased()), this, SLOT(ContIfRunning())); @@ -591,9 +619,9 @@ Main::Main(QGraphicsScene& c, Mesh &m, Q mesh_id = view->insertItem("Show &nodes", this, SLOT(toggleShowNodes()), Qt::CTRL+Qt::SHIFT+Qt::Key_N); view->setItemChecked(mesh_id, TRUE); node_number_id = view->insertItem("Show node numbers", this, SLOT(toggleNodeNumbers()), Qt::CTRL+Qt::SHIFT+Qt::Key_M); - view->setItemChecked(node_number_id, TRUE); + view->setItemChecked(node_number_id, FALSE); cell_number_id = view->insertItem("Show cell numbers", this, SLOT(toggleCellNumbers())); - view->setItemChecked(cell_number_id, TRUE); + view->setItemChecked(cell_number_id, FALSE); hide_cells_id = view->insertItem("Hide cells", this, SLOT(toggleHideCells())); view->setItemChecked(hide_cells_id, FALSE); border_id = view->insertItem("Show &border cells", this, SLOT(toggleShowBorderCells())); @@ -911,7 +939,9 @@ int Main::readStateXML(const char *filen try { xmlNode *settings; mesh.XMLRead((const char *)filename, &settings, geometry, pars, simtime); - cerr << "Reading done.\n"; + #ifdef QDEBUG + qDebug() << "Reading done."<< endl; + #endif XMLReadSettings(settings); xmlFree(settings); Cell::SetMagnification(1); @@ -927,7 +957,9 @@ int Main::readStateXML(const char *filen setCaption(caption_with_file.arg(filename)); statusBar()->message(status_message); emit ParsChanged(); - cerr << "Done. Returning 0.\n"; + #ifdef QDEBUG + qDebug() << "Done. Returning 0." << endl; + #endif return 0; } catch (const char *error_message) { QMessageBox mb( "Read leaf from XML file", @@ -1028,7 +1060,9 @@ void Main::readStateXML() { // extern Mesh mesh; stopSimulation(); - cerr << "Trying to open an OptionFileDialog\n"; + #ifdef QDEBUG + qDebug() << "Trying to open an OptionFileDialog" << endl; + #endif OptionFileDialog *fd = new OptionFileDialog( this, "read dialog", TRUE ); fd->setMode( OptionFileDialog::ExistingFile ); fd->setFilter( "XML files (*.xml)"); @@ -1204,7 +1238,7 @@ void Main::toggleHideCells(void) { void Main::stopSimulation(void) { //run->setItemChecked(paused_id, true); timer->stop(); - cerr << "Stopping simulation\n"; + cerr << "Stopping simulation" << endl; statusBar()->message("Simulation paused"); running = false; } @@ -1213,10 +1247,10 @@ void Main::toggleHideCells(void) { { bool s = run->isItemChecked(paused_id); if (s) { - cerr << "Calling start simulation\n"; + cerr << "Calling start simulation" << endl; startSimulation(); } else { - cerr << "Calling stop simulation\n"; + cerr << "Calling stop simulation" << endl; stopSimulation(); } } @@ -1273,14 +1307,18 @@ void Main::toggleHideCells(void) { // extern Mesh mesh; Vector bbll,bbur; mesh.BoundingBox(bbll,bbur); - cerr << "bbll = " << bbll << endl; - cerr << "bbur = " << bbur << endl; + + #ifdef QDEBUG + qDebug() << "bbll = " << bbll << endl; + qDebug() << "bbur = " << bbur << endl; + #endif double cw = (bbur.x - bbll.x); double ch = (bbur.y - bbll.y); QPainter pp(printer); QRect vp=pp.viewport(); - cerr << "Paper width = " << vp.width() << " x " << vp.height() << endl; - + #ifdef QDEBUG + qDebug() << "Paper width = " << vp.width() << " x " << vp.height() << endl; + #endif // Note that Cell is also translated... pp.translate(-bbur.x,-bbur.y); @@ -1316,7 +1354,7 @@ void Main::toggleHideCells(void) { "Are you sure?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton ) == QMessageBox::Yes ) { - cerr << "Restarting simulation\n"; + cerr << "Restarting simulation" << endl; // extern Mesh mesh; mesh.Clear(); Init(); @@ -1397,13 +1435,15 @@ void Main::FitCanvasToWindow(void) { double scale_factor_y = (double)editor->height()/(double)canvas.height(); double scale_factor = scale_factor_x > scale_factor_y ? scale_factor_x : scale_factor_y; QMatrix m = editor->matrix(); - - cerr << "editor->width() = " << editor->width() << endl; - cerr << "editor->height() = " << editor->height() << endl; + + #ifdef QDEBUG + qDebug() << "editor->width() = " << editor->width() << endl; + qDebug() << "editor->height() = " << editor->height() << endl; - cerr << "scale_factor = " << scale_factor << endl; - cerr << "scale_factor_x = " << scale_factor_x << endl; - cerr << "scale_factor_y = " << scale_factor_y << endl; + qDebug() << "scale_factor = " << scale_factor << endl; + qDebug() << "scale_factor_x = " << scale_factor_x << endl; + qDebug() << "scale_factor_y = " << scale_factor_y << endl; + #endif m.scale( scale_factor, scale_factor ); editor->setMatrix( m ); editor->show(); diff --git a/src/cell.cpp b/src/cell.cpp --- a/src/cell.cpp +++ b/src/cell.cpp @@ -19,6 +19,8 @@ * */ +#include + #include #include "cell.h" #include "node.h" @@ -30,7 +32,6 @@ #include "qcanvasarrow.h" #include "parameter.h" -#include static const std::string _module_id("$Id$"); @@ -111,13 +112,15 @@ double Cell::MeanArea(void) { void Cell::Apoptose(void) { // First kill walls - cerr << "This is cell " << Index() << "\n"; - cerr << "Number of walls: " << walls.size() << endl; - - for (list::iterator w=walls.begin(); - w!=walls.end(); - w++) { - cerr << "Before apoptosis, wall " << (*w)->Index() << " says: c1 = " << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl; + #ifdef QDEBUG + qDebug() << "This is cell " << Index() << endl; + qDebug() << "Number of walls: " << walls.size() << endl; + #endif + for (list::iterator w=walls.begin(); w!=walls.end(); w++) { + #ifdef QDEBUG + qDebug() << "Before apoptosis, wall " << (*w)->Index() << " says: c1 = " + << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl; + #endif } for (list::iterator w=walls.begin(); w!=walls.end(); @@ -140,25 +143,35 @@ void Cell::Apoptose(void) { (*w)->c2 = m->boundary_polygon; } + #ifdef QDEBUG if (illegal_flag && (*w)->c1==(*w)->c2) { - cerr << "I created an illegal wall.\n"; + qDebug() << "I created an illegal wall." << endl; } + #endif + if ( ((*w)->N1()->DeadP() || (*w)->N2()->DeadP()) || ((*w)->C1() == (*w)->C2() ) ){ // kill wall - cerr << "Killing wall.\n"; + #ifdef QDEBUG + qDebug() << "Killing wall." << endl; + #endif (*w)->Kill(); + + #ifdef QDEBUG if ((*w)) { - cerr << "Wall " << (*w)->Index() << " says: c1 = " << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl; + qDebug() << "Wall " << (*w)->Index() << " says: c1 = " + << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl; } + #endif (*w)=0; } else { - cerr << "Not killing wall.\n"; - cerr << "Wall " << (*w)->Index() << " says: c1 = " << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl; + #ifdef QDEBUG + qDebug() << "Not killing wall." << endl; + qDebug() << "Wall " << (*w)->Index() << " says: c1 = " + << (*w)->c1->Index() << ", c2 = " << (*w)->c2->Index() << endl; + #endif } - - } walls.remove(0); @@ -328,7 +341,9 @@ bool Cell::DivideOverGivenLine(const Vec // check each edge for intersection with the line ItList new_node_locations; - cerr << "Cell " << Index() << " is doing DivideOverGivenLine \n"; + #ifdef QDEBUG + qDebug() << "Cell " << Index() << " is doing DivideOverGivenLine" << endl; + #endif for (list::iterator i=nodes.begin(); i!=nodes.end(); i++) { @@ -361,29 +376,31 @@ bool Cell::DivideOverGivenLine(const Vec } } + #ifdef QDEBUG if (new_node_locations.size()<2) { - - cerr << "Line does not intersect with two edges of Cell " << Index() << endl; - cerr << "new_node_locations.size() = " << new_node_locations.size() << endl; - return false; + qDebug() << "Line does not intersect with two edges of Cell " << Index() << endl; + qDebug() << "new_node_locations.size() = " << new_node_locations.size() << endl; + return false; } ItList::iterator i = new_node_locations.begin(); list< Node *>::iterator j; - cerr << "-------------------------------\n"; - cerr << "Location of new nodes: " << (**i)->Index() << " and "; + qDebug() << "-------------------------------" << endl; + qDebug() << "Location of new nodes: " << (**i)->Index() << " and "; + ++i; j = *i; if (j==nodes.begin()) j=nodes.end(); j--; - cerr << (*j)->Index() << endl; - cerr << "-------------------------------\n"; + qDebug() << (*j)->Index() << endl; + qDebug() << "-------------------------------" << endl; if ( **new_node_locations.begin() == *j ) { - cerr << "Rejecting proposed division (cutting off zero area).\n"; + qDebug() << "Rejecting proposed division (cutting off zero area)." << endl; return false; } - + #endif + DivideWalls(new_node_locations, v1, v2, fix_cellwall, node_set); return true; @@ -451,9 +468,12 @@ void Cell::DivideWalls(ItList new_node_l // Cell somewhere in the middle of Mesh::Cells the indices will // get totally messed up...! (e.g. the indices used in Nodes::cells) - cerr << "new_node_locations.size() = " << new_node_locations.size() <index = " << daughter->index << endl; - cerr << "cells.size() = " << m->cells.size() << endl; + #ifdef QDEBUG + qDebug() << "new_node_locations.size() = " << new_node_locations.size() <index = " << daughter->index << endl; + qDebug() << "cells.size() = " << m->cells.size() << endl; + #endif + m->cells.pop_back(); Cell::NCells()--; m->shuffled_cells.pop_back(); @@ -529,7 +549,7 @@ void Cell::DivideWalls(ItList new_node_l new_node_flag[nnc]=1; new_node[nnc] = *(**i); new_node_ind[nnc] = **i; - //cerr << **i << "\n" ; + //cerr << **i << endl ; } else if ( (*(*nb) - *n).Norm() < collapse_node_threshold * elem_length ) { new_node_flag[nnc]=2; @@ -785,10 +805,11 @@ void Cell::DivideWalls(ItList new_node_l } while ( w!=walls.end() && !(*w)->IntersectsWithDivisionPlaneP( from, to ) ); // go on until we find the right one. if (w == walls.end()) { - cerr << "Whoops, wall element not found...!\n"; - cerr << "Cell ID: " << neighbor_cell->Index() << endl; - cerr << "My cell ID: " << Index() << endl; - + #ifdef QDEBUG + qDebug() << "Whoops, wall element not found...!" << endl; + qDebug() << "Cell ID: " << neighbor_cell->Index() << endl; + qDebug() << "My cell ID: " << Index() << endl; + #endif } else { // 2. Split it up, if we should (sometimes, the new node coincides with an existing node so @@ -895,7 +916,9 @@ void Cell::DivideWalls(ItList new_node_l (*i)->owners.end(), bind2nd(mem_fun_ref( &Neighbor::CellEquals ),this->Index() ) ); if (neighb_with_this_cell==(*i)->owners.end()) { - cerr << "not found\n"; + #ifdef QDEBUG + qDebug() << "not found" << endl; + #endif abort(); } @@ -1619,9 +1642,11 @@ void Cell::Flux(double *flux, double *D) for (int c=0;clength * ( D[c] ) * ( ((Cell *)(*i)->c2)->chem[c] - chem[c] ); + #ifdef QDEBUG if ((*i)->c1!=this) { - cerr << "Warning, bad cells boundary: " << (*i)->c1->Index() << ", " << index << endl; + qDebug() << "Warning, bad cells boundary: " << (*i)->c1->Index() << ", " << index << endl; } + #endif flux[c] += phi; } @@ -1640,7 +1665,9 @@ void Cell::Draw(QGraphicsScene *c, QStri // Draw the cell on a QCanvas object if (DeadP()) { - cerr << "Cell " << index << " not drawn, because dead.\n"; + #ifdef QDEBUG + qDebug() << "Cell " << index << " not drawn, because dead." << endl; + #endif return; } @@ -1940,11 +1967,12 @@ void Cell::SetWallLengths(void) { void Cell::AddWall( Wall *w ) { // if necessary, we could try later inserting it at the correct position + #ifdef QDEBUG if (w->c1 == w->c2 ){ - - cerr << "Wall between identical cells: " << w->c1->Index()<< endl; - + qDebug() << "Wall between identical cells: " << w->c1->Index()<< endl; } + #endif + // Add Wall to Cell's list walls.push_back( w ); diff --git a/src/cellbase.h b/src/cellbase.h --- a/src/cellbase.h +++ b/src/cellbase.h @@ -65,10 +65,14 @@ public: ncells = 0; nchem = 0; base_area = 0.; - cerr << "Constructor of CellsStaticDatamembers\n"; + #ifdef QDEBUG + qDebug() << "Constructor of CellsStaticDatamembers" << endl; + #endif } ~CellsStaticDatamembers() { - cerr << "Oops! Desctructor of CellsStaticDatamembers called\n"; + #ifdef QDEBUG + qDebug() << "Oops! Desctructor of CellsStaticDatamembers called" << endl; + #endif } int ncells; int nchem; diff --git a/src/data_plot.cpp b/src/data_plot.cpp --- a/src/data_plot.cpp +++ b/src/data_plot.cpp @@ -32,11 +32,13 @@ #include #include #include +#include #include - #include "data_plot.h" -static const std::string _module_id("$Id$"); +using namespace std; + +static const string _module_id("$Id$"); // // Initialize main window @@ -90,7 +92,11 @@ DataPlot::DataPlot(QWidget *parent, cons curves[i].attach(this); curves[i].setPen(QPen(curvecolors[i])); QString col(curvecolors[i]); - std::cerr << "Curvecolor " << col.toStdString() << std::endl; + + #ifdef QDEBUG + qDebug() << "Curvecolor " << col.toStdString() << endl; + #endif + curves[i].setRawData(d_t, d_x[i], PLOT_SIZE); } diff --git a/src/forwardeuler.cpp b/src/forwardeuler.cpp --- a/src/forwardeuler.cpp +++ b/src/forwardeuler.cpp @@ -26,7 +26,9 @@ #include "maxmin.h" #include -static const std::string _module_id("$Id$"); +using namespace std; + +static const string _module_id("$Id$"); // The value Errcon equals (5/Safety) raised to the power (1/PGrow), see use below. @@ -66,7 +68,7 @@ void ForwardEuler::odeint(double *ystart { static bool warning_issued = false; if (!warning_issued) { - std::cerr << "Using inaccurate method ForwardEuler\n"; + cerr << "Using inaccurate method ForwardEuler\n"; warning_issued=true; //MyWarning::warning("Using inaccurate method ForwardEuler"); } diff --git a/src/mesh.cpp b/src/mesh.cpp --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -394,9 +394,10 @@ Cell &Mesh::LeafPrimordium(int nnodes, d n1); - - cerr << circle << endl; - cerr << petiole << endl; + #ifdef QDEBUG + qDebug() << circle << endl; + qDebug() << petiole << endl; + #endif AddNodeToCell(boundary_polygon, *it_n1, n4, @@ -578,10 +579,12 @@ void Mesh::Clear(void) { cerr << "Meshed cleared: cells: " << cells.size() << ", nodes: " << nodes.size() << endl; */ - - cerr << "cells.size() = " << cells.size() << endl; - cerr << "walls.size() = " << walls.size() << endl; - cerr << "nodes.size() = " << nodes.size() << endl; + + #ifdef QDEBUG + qDebug() << "cells.size() = " << cells.size() << endl; + qDebug << "walls.size() = " << walls.size() << endl; + qDebug << "nodes.size() = " << nodes.size() << endl; + #endif } double Mesh::DisplaceNodes(void) { @@ -1445,8 +1448,10 @@ void Mesh::CutAwayBelowLine( Vector star Vector perp = (endpoint-startpoint).Perp2D().Normalised(); - - cerr << "Before Apoptose\n"; + #ifdef QDEBUG + qDebug() << "Before Apoptose" << endl; + #endif + TestIllegalWalls(); for (vector::iterator i=cells.begin(); i!=cells.end(); @@ -1461,7 +1466,9 @@ void Mesh::CutAwayBelowLine( Vector star } } - cerr << "Before CleanUpCellNodeLists\n"; + #ifdef QDEBUG + qDebug() << "Before CleanUpCellNodeLists" << endl; + #endif TestIllegalWalls(); CleanUpCellNodeLists(); @@ -1492,7 +1499,9 @@ void Mesh::TestIllegalWalls(void) { w!=walls.end(); w++) { if ((*w)->IllegalP() ) { - cerr << "Wall " << **w << " is illegal.\n"; + #ifdef QDEBUG + qDebug() << "Wall " << **w << " is illegal." << endl; + #endif } } @@ -1617,7 +1626,7 @@ void Mesh::RepairBoundaryPolygon(void) { boundary_polygon->ConstructNeighborList(); #ifdef QDEBUG - cerr << "Repaired Boundary Polygon node indices: "; + qDebug() << "Repaired Boundary Polygon node indices: "; foreach (Node* node, boundary_polygon->nodes){ qDebug() << node->Index() << " " ; } diff --git a/src/mesh.h b/src/mesh.h --- a/src/mesh.h +++ b/src/mesh.h @@ -40,6 +40,7 @@ #include "simplugin.h" #include #include +#include using namespace std; // new queue which rejects duplicate elements @@ -110,8 +111,10 @@ public: if ((unsigned)i #include #include #include @@ -84,9 +85,10 @@ double RANDOM(void) int Seed(int seed) { if (seed < 0) { - cerr << "Randomizing random generator, seed is "; int rseed=Randomize(); - cerr << rseed << "\n"; + #ifdef QDEBUG + qDebug() << "Randomizing random generator, seed is " << rseed << endl; + #endif return rseed; } else { int i; diff --git a/src/wall.cpp b/src/wall.cpp --- a/src/wall.cpp +++ b/src/wall.cpp @@ -61,7 +61,9 @@ bool Wall::CorrectWall( void ) { //cerr << "wall_owners.size() = " << wall_owners.size() << endl; if (wall_owners.size() == 3 && nwalls==1 /* bug-fix 22/10/2007; confine this condition to first division only */) { - cerr << "nwalls = " << nwalls << endl; + #ifdef QDEBUG + qDebug() << "nwalls = " << nwalls << endl; + #endif // special case for first cleavage // find boundary polygon in the wall owners list @@ -86,35 +88,35 @@ bool Wall::CorrectWall( void ) { wall_owners.erase(bpit); }else { + + #ifdef QDEBUG + qDebug() << "Wall::CorrectWall says: Wall has three owners, but none of them is the BoundaryPolygon. I have no clue what to do with this case... Sorry!" << endl; + qDebug() << "Wall: " << *this << endl; + qDebug() << "Owners are: "; + transform(wall_owners.begin(), wall_owners.end(), ostream_iterator(qDebug(), " "), mem_fun (&CellBase::Index) ); + qDebug() << endl; + qDebug() << "Owners node " << n1->Index() << ": "; + for (list::iterator i = n1->owners.begin(); i!=n1->owners.end(); i++) { + qDebug() << i->getCell()->Index() << " "; + } + qDebug() << endl; + qDebug() << "Owners node " << n2->Index() << ": "; - cerr << "Wall::CorrectWall says: Wall has three owners, but none of them is the BoundaryPolygon. I have no clue what to do with this case... Sorry!\n"; - cerr << "Wall: " << *this << endl; - cerr << "Owners are: "; - transform(wall_owners.begin(), wall_owners.end(), ostream_iterator(cerr, " "), mem_fun (&CellBase::Index) ); - cerr << endl; - cerr << "Owners node " << n1->Index() << ": "; - for (list::iterator i = n1->owners.begin(); - i!=n1->owners.end(); - i++) { - cerr << i->getCell()->Index() << " "; - } - cerr << endl; - cerr << "Owners node " << n2->Index() << ": "; - - for (list::iterator i = n2->owners.begin(); - i!=n2->owners.end(); - i++) { - cerr << i->getCell()->Index() << " "; - } - cerr << endl; - std::exit(1); + for (list::iterator i = n2->owners.begin(); i!=n2->owners.end(); i++) { + qDebug() << i->getCell()->Index() << " "; + } + qDebug() << endl; + #endif + std::exit(1); } } + #ifdef QDEBUG if (wall_owners.size() == 1) { - cerr << "Corner point. Special case.\n"; + qDebug() << "Corner point. Special case." << endl; } + #endif CellBase *cell1 = wall_owners.front(); CellBase *cell2 = wall_owners.back(); @@ -148,7 +150,9 @@ bool Wall::CorrectWall( void ) { ((Cell *)c1)->AddWall(this); // cerr << "Block 3\n"; } else { - cerr << "Warning, cell wall was not corrected.\n"; + #ifdef QDEBUG + qDebug() << "Warning, cell wall was not corrected." << endl; + #endif return false; } } diff --git a/src/wallbase.cpp b/src/wallbase.cpp --- a/src/wallbase.cpp +++ b/src/wallbase.cpp @@ -19,6 +19,8 @@ * */ +#include + #include "wall.h" #include "wallbase.h" #include "node.h" @@ -53,9 +55,11 @@ ostream &operator<<(ostream &os, const W WallBase::WallBase(Node *sn1, Node *sn2, CellBase *sc1, CellBase *sc2) { + #ifdef QDEBUG if (sc1==sc2) { - cerr << "Attempting to build a wall between identical cells: " << sc1->Index() << endl; + qDebug() << "Attempting to build a wall between identical cells: " << sc1->Index() << endl; } + #endif c1 = sc1; c2 = sc2; diff --git a/src/wallitem.cpp b/src/wallitem.cpp --- a/src/wallitem.cpp +++ b/src/wallitem.cpp @@ -19,6 +19,7 @@ * */ +#include #include #include #include @@ -125,10 +126,12 @@ void WallItem::OnClick(QMouseEvent *e) { Wall *w=&getWall(); - cerr << "Wall ID = " << w->Index() << ", this = " << w << "\n"; - cerr << "Wall item = " << this << "\n"; - cerr << "C1 = " << w->C1()->Index() << ", C2 = " << w->C2()->Index() << endl; - cerr << "N1 = " << w->N1()->Index() << ", N2 = " << w->N2()->Index() << endl; + #ifdef QDEBUG + qDebug() << "Wall ID = " << w->Index() << ", this = " << w << endl; + qDebug() << "Wall item = " << this << endl; + qDebug() << "C1 = " << w->C1()->Index() << ", C2 = " << w->C2()->Index() << endl; + qDebug() << "N1 = " << w->N1()->Index() << ", N2 = " << w->N2()->Index() << endl; + #endif //double tr = wn==1?w->Transporters1(1):w->Transporters2(1); CellBase *c = wn==1?w->C1():w->C2();