# HG changeset patch # User Roeland Merks # Date 2010-06-03 18:40:26 # Node ID 413a4067bfff4f1ece82a9e9685972b50624487f # Parent 3663c597352b0a4f8ffbf90c311199c9b9d433e1 Changed interface for model plugins to make usage of pointers and references consistent. Added codes for tutorial belonging to VLeaf manuscript. Something changed in modelcatalogue. I'm not sure what... user: Roeland Merks branch 'default' added src/TutorialCode/Tutorial0/mymodel.cpp added src/TutorialCode/Tutorial0/mymodel.h added src/TutorialCode/Tutorial0/mymodel.pro added src/TutorialCode/Tutorial1/mymodel.cpp added src/TutorialCode/Tutorial1/mymodel.h added src/TutorialCode/Tutorial1/mymodel.pro added src/TutorialCode/Tutorial2/mymodel.cpp added src/TutorialCode/Tutorial2/mymodel.h added src/TutorialCode/Tutorial2/mymodel.pro added src/TutorialCode/Tutorial3/mymodel.cpp added src/TutorialCode/Tutorial3/mymodel.h added src/TutorialCode/Tutorial3/mymodel.pro added src/TutorialCode/Tutorial4/mymodel.cpp added src/TutorialCode/Tutorial4/mymodel.h added src/TutorialCode/Tutorial4/mymodel.pro added src/TutorialCode/Tutorial5/mymodel.cpp added src/TutorialCode/Tutorial5/mymodel.h added src/TutorialCode/Tutorial5/mymodel.pro added src/build_models/translate_plugin.pl changed src/VirtualLeafpar.tmpl changed src/build_models/auxingrowthplugin.cpp changed src/build_models/auxingrowthplugin.h changed src/build_models/meinhardtplugin.cpp changed src/build_models/meinhardtplugin.h changed src/build_models/plugin_auxingrowth.pro changed src/build_models/plugin_leaf.pro changed src/build_models/plugin_meinhardt.pro changed src/build_models/plugin_test.pro changed src/cell.cpp changed src/cellbase.cpp changed src/cellbase.h changed src/libplugin.pro changed src/mesh.cpp changed src/mesh.h changed src/modelcatalogue.cpp changed src/simplugin.h diff --git a/src/TutorialCode/Tutorial0/mymodel.cpp b/src/TutorialCode/Tutorial0/mymodel.cpp new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial0/mymodel.cpp @@ -0,0 +1,69 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include "simplugin.h" + +#include "parameter.h" + +#include "wallbase.h" +#include "cellbase.h" +#include "mymodel.h" + +static const std::string _module_id("$Id$"); + +QString MyModel::ModelID(void) { + // specify the name of your model here + return QString( "My first model in VirtualLeaf" ); +} + +// return the number of chemicals your model uses +int MyModel::NChem(void) { return 0; } + +// To be executed after cell division +void MyModel::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { + // rules to be executed after cell division go here + // (e.g., cell differentiation rules) +} + +void MyModel::SetCellColor(CellBase *c, QColor *color) { + // add cell coloring rules here + +} + +void MyModel::CellHouseKeeping(CellBase *c) { + // add cell behavioral rules here +} + +void MyModel::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) { + // add biochemical transport rules here +} +void MyModel::WallDynamics(Wall *w, double *dw1, double *dw2) { + // add biochemical networks for reactions occuring at walls here +} +void MyModel::CellDynamics(CellBase *c, double *dchem) { + // add biochemical networks for intracellular reactions here +} + + +Q_EXPORT_PLUGIN2(mymodel, MyModel) diff --git a/src/TutorialCode/Tutorial0/mymodel.h b/src/TutorialCode/Tutorial0/mymodel.h new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial0/mymodel.h @@ -0,0 +1,60 @@ +/* + * $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. + * + */ + + +#include +#include +#include +#include "simplugin.h" + + +class MyModel : public QObject, SimPluginInterface { + Q_OBJECT + Q_INTERFACES(SimPluginInterface); + +public: + virtual QString ModelID(void); + + // Executed after the cellular mechanics steps have equillibrized + virtual void CellHouseKeeping (CellBase *c); + // Differential equations describing transport of chemicals from cell to cell + virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); + + // Differential equations describing chemical reactions taking place at or near the cell walls + // (e.g. PIN accumulation) + virtual void WallDynamics(Wall *w, double *dw1, double *dw2); + + // Differential equations describing chemical reactions inside the cells + virtual void CellDynamics(CellBase *c, double *dchem); + + // to be executed after a cell division + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); + + // to be executed for coloring a cell + virtual void SetCellColor(CellBase *c, QColor *color); + // return number of chemicals + virtual int NChem(void); +}; + + + + diff --git a/src/TutorialCode/Tutorial0/mymodel.pro b/src/TutorialCode/Tutorial0/mymodel.pro new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial0/mymodel.pro @@ -0,0 +1,61 @@ +# +# $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. +# + + +TARGET = mymodel +VLEAFHOME = ../../.. + +CONFIG += release +CONFIG -= debug +CONFIG += plugin + +BINDIR = $${VLEAFHOME}/bin +LIBDIR = $${VLEAFHOME}/lib +INCDIR = $${VLEAFHOME}/src +DEFINES = QTGRAPHICS # VLEAFPLUGIN +DESTDIR = $${BINDIR}/models +HEADERS = $${TARGET}.h +INCLUDEPATH += $${INCDIR} + +QMAKE_CXXFLAGS += -fexceptions #-I$${INCDIR} +QMAKE_CXXFLAGS_DEBUG += -g3 +QMAKE_CXXFLAGS_DEBUG += -DQDEBUG +QT += qt3support +SOURCES = $${TARGET}.cpp +TEMPLATE = lib + +unix { + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 + QMAKE_LFLAGS += -fPIC +} + +win32 { + LIBXML2DIR = C:\libxml2 + LIBICONVDIR = C:\libiconv + LIBZDIR = C:\libz + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -DLIBXML_STATIC + QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include + +} + +# finish diff --git a/src/TutorialCode/Tutorial1/mymodel.cpp b/src/TutorialCode/Tutorial1/mymodel.cpp new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial1/mymodel.cpp @@ -0,0 +1,70 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include "simplugin.h" + +#include "parameter.h" + +#include "wallbase.h" +#include "cellbase.h" +#include "mymodel.h" + +static const std::string _module_id("$Id$"); + +QString MyModel::ModelID(void) { + // specify the name of your model here + return QString( "Cell growth" ); +} + +// return the number of chemicals your model uses +int MyModel::NChem(void) { return 0; } + +// To be executed after cell division +void MyModel::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { + // rules to be executed after cell division go here + // (e.g., cell differentiation rules) +} + +void MyModel::SetCellColor(CellBase *c, QColor *color) { + // add cell coloring rules here + +} + +void MyModel::CellHouseKeeping(CellBase *c) { + // add cell behavioral rules here + c->EnlargeTargetArea(par->cell_expansion_rate); +} + +void MyModel::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) { + // add biochemical transport rules here +} +void MyModel::WallDynamics(Wall *w, double *dw1, double *dw2) { + // add biochemical networks for reactions occuring at walls here +} +void MyModel::CellDynamics(CellBase *c, double *dchem) { + // add biochemical networks for intracellular reactions here +} + + +Q_EXPORT_PLUGIN2(mymodel, MyModel) diff --git a/src/TutorialCode/Tutorial1/mymodel.h b/src/TutorialCode/Tutorial1/mymodel.h new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial1/mymodel.h @@ -0,0 +1,60 @@ +/* + * $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. + * + */ + + +#include +#include +#include +#include "simplugin.h" + + +class MyModel : public QObject, SimPluginInterface { + Q_OBJECT + Q_INTERFACES(SimPluginInterface); + +public: + virtual QString ModelID(void); + + // Executed after the cellular mechanics steps have equillibrized + virtual void CellHouseKeeping (CellBase *c); + // Differential equations describing transport of chemicals from cell to cell + virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); + + // Differential equations describing chemical reactions taking place at or near the cell walls + // (e.g. PIN accumulation) + virtual void WallDynamics(Wall *w, double *dw1, double *dw2); + + // Differential equations describing chemical reactions inside the cells + virtual void CellDynamics(CellBase *c, double *dchem); + + // to be executed after a cell division + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); + + // to be executed for coloring a cell + virtual void SetCellColor(CellBase *c, QColor *color); + // return number of chemicals + virtual int NChem(void); +}; + + + + diff --git a/src/TutorialCode/Tutorial1/mymodel.pro b/src/TutorialCode/Tutorial1/mymodel.pro new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial1/mymodel.pro @@ -0,0 +1,61 @@ +# +# $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. +# + + +TARGET = mymodel +VLEAFHOME = ../../.. + +CONFIG += release +CONFIG -= debug +CONFIG += plugin + +BINDIR = $${VLEAFHOME}/bin +LIBDIR = $${VLEAFHOME}/lib +INCDIR = $${VLEAFHOME}/src +DEFINES = QTGRAPHICS # VLEAFPLUGIN +DESTDIR = $${BINDIR}/models +HEADERS = $${TARGET}.h +INCLUDEPATH += $${INCDIR} + +QMAKE_CXXFLAGS += -fexceptions #-I$${INCDIR} +QMAKE_CXXFLAGS_DEBUG += -g3 +QMAKE_CXXFLAGS_DEBUG += -DQDEBUG +QT += qt3support +SOURCES = $${TARGET}.cpp +TEMPLATE = lib + +unix { + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 + QMAKE_LFLAGS += -fPIC +} + +win32 { + LIBXML2DIR = C:\libxml2 + LIBICONVDIR = C:\libiconv + LIBZDIR = C:\libz + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -DLIBXML_STATIC + QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include + +} + +# finish diff --git a/src/TutorialCode/Tutorial2/mymodel.cpp b/src/TutorialCode/Tutorial2/mymodel.cpp new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial2/mymodel.cpp @@ -0,0 +1,73 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include "simplugin.h" + +#include "parameter.h" + +#include "wallbase.h" +#include "cellbase.h" +#include "mymodel.h" + +static const std::string _module_id("$Id$"); + +QString MyModel::ModelID(void) { + // specify the name of your model here + return QString( "Cell growth and cell division" ); +} + +// return the number of chemicals your model uses +int MyModel::NChem(void) { return 0; } + +// To be executed after cell division +void MyModel::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { + // rules to be executed after cell division go here + // (e.g., cell differentiation rules) +} + +void MyModel::SetCellColor(CellBase *c, QColor *color) { + // add cell coloring rules here + +} + +void MyModel::CellHouseKeeping(CellBase *c) { + // add cell behavioral rules here + c->EnlargeTargetArea(par->cell_expansion_rate); + if (c->Area() > par->rel_cell_div_threshold * c->BaseArea()) { + c->Divide(); + } +} + +void MyModel::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) { + // add biochemical transport rules here +} +void MyModel::WallDynamics(Wall *w, double *dw1, double *dw2) { + // add biochemical networks for reactions occuring at walls here +} +void MyModel::CellDynamics(CellBase *c, double *dchem) { + // add biochemical networks for intracellular reactions here +} + + +Q_EXPORT_PLUGIN2(mymodel, MyModel) diff --git a/src/TutorialCode/Tutorial2/mymodel.h b/src/TutorialCode/Tutorial2/mymodel.h new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial2/mymodel.h @@ -0,0 +1,60 @@ +/* + * $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. + * + */ + + +#include +#include +#include +#include "simplugin.h" + + +class MyModel : public QObject, SimPluginInterface { + Q_OBJECT + Q_INTERFACES(SimPluginInterface); + +public: + virtual QString ModelID(void); + + // Executed after the cellular mechanics steps have equillibrized + virtual void CellHouseKeeping (CellBase *c); + // Differential equations describing transport of chemicals from cell to cell + virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); + + // Differential equations describing chemical reactions taking place at or near the cell walls + // (e.g. PIN accumulation) + virtual void WallDynamics(Wall *w, double *dw1, double *dw2); + + // Differential equations describing chemical reactions inside the cells + virtual void CellDynamics(CellBase *c, double *dchem); + + // to be executed after a cell division + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); + + // to be executed for coloring a cell + virtual void SetCellColor(CellBase *c, QColor *color); + // return number of chemicals + virtual int NChem(void); +}; + + + + diff --git a/src/TutorialCode/Tutorial2/mymodel.pro b/src/TutorialCode/Tutorial2/mymodel.pro new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial2/mymodel.pro @@ -0,0 +1,61 @@ +# +# $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. +# + + +TARGET = mymodel +VLEAFHOME = ../../.. + +CONFIG += release +CONFIG -= debug +CONFIG += plugin + +BINDIR = $${VLEAFHOME}/bin +LIBDIR = $${VLEAFHOME}/lib +INCDIR = $${VLEAFHOME}/src +DEFINES = QTGRAPHICS # VLEAFPLUGIN +DESTDIR = $${BINDIR}/models +HEADERS = $${TARGET}.h +INCLUDEPATH += $${INCDIR} + +QMAKE_CXXFLAGS += -fexceptions #-I$${INCDIR} +QMAKE_CXXFLAGS_DEBUG += -g3 +QMAKE_CXXFLAGS_DEBUG += -DQDEBUG +QT += qt3support +SOURCES = $${TARGET}.cpp +TEMPLATE = lib + +unix { + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 + QMAKE_LFLAGS += -fPIC +} + +win32 { + LIBXML2DIR = C:\libxml2 + LIBICONVDIR = C:\libiconv + LIBZDIR = C:\libz + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -DLIBXML_STATIC + QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include + +} + +# finish diff --git a/src/TutorialCode/Tutorial3/mymodel.cpp b/src/TutorialCode/Tutorial3/mymodel.cpp new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial3/mymodel.cpp @@ -0,0 +1,72 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include "simplugin.h" + +#include "parameter.h" + +#include "wallbase.h" +#include "cellbase.h" +#include "mymodel.h" + +static const std::string _module_id("$Id$"); + +QString MyModel::ModelID(void) { + // specify the name of your model here + return QString( "Cell growth and cell division" ); +} + +// return the number of chemicals your model uses +int MyModel::NChem(void) { return 0; } + +// To be executed after cell division +void MyModel::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { + // rules to be executed after cell division go here + // (e.g., cell differentiation rules) +} + +void MyModel::SetCellColor(CellBase *c, QColor *color) { + // add cell coloring rules here +} + +void MyModel::CellHouseKeeping(CellBase *c) { + // add cell behavioral rules here + c->EnlargeTargetArea(par->cell_expansion_rate); + if (c->Area() > par->rel_cell_div_threshold * c->BaseArea()) { + c->DivideOverAxis(Vector(1,0,0)); + } +} + +void MyModel::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) { + // add biochemical transport rules here +} +void MyModel::WallDynamics(Wall *w, double *dw1, double *dw2) { + // add biochemical networks for reactions occuring at walls here +} +void MyModel::CellDynamics(CellBase *c, double *dchem) { + // add biochemical networks for intracellular reactions here +} + + +Q_EXPORT_PLUGIN2(mymodel, MyModel) diff --git a/src/TutorialCode/Tutorial3/mymodel.h b/src/TutorialCode/Tutorial3/mymodel.h new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial3/mymodel.h @@ -0,0 +1,60 @@ +/* + * $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. + * + */ + + +#include +#include +#include +#include "simplugin.h" + + +class MyModel : public QObject, SimPluginInterface { + Q_OBJECT + Q_INTERFACES(SimPluginInterface); + +public: + virtual QString ModelID(void); + + // Executed after the cellular mechanics steps have equillibrized + virtual void CellHouseKeeping (CellBase *c); + // Differential equations describing transport of chemicals from cell to cell + virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); + + // Differential equations describing chemical reactions taking place at or near the cell walls + // (e.g. PIN accumulation) + virtual void WallDynamics(Wall *w, double *dw1, double *dw2); + + // Differential equations describing chemical reactions inside the cells + virtual void CellDynamics(CellBase *c, double *dchem); + + // to be executed after a cell division + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); + + // to be executed for coloring a cell + virtual void SetCellColor(CellBase *c, QColor *color); + // return number of chemicals + virtual int NChem(void); +}; + + + + diff --git a/src/TutorialCode/Tutorial3/mymodel.pro b/src/TutorialCode/Tutorial3/mymodel.pro new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial3/mymodel.pro @@ -0,0 +1,61 @@ +# +# $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. +# + + +TARGET = mymodel +VLEAFHOME = ../../.. + +CONFIG += release +CONFIG -= debug +CONFIG += plugin + +BINDIR = $${VLEAFHOME}/bin +LIBDIR = $${VLEAFHOME}/lib +INCDIR = $${VLEAFHOME}/src +DEFINES = QTGRAPHICS # VLEAFPLUGIN +DESTDIR = $${BINDIR}/models +HEADERS = $${TARGET}.h +INCLUDEPATH += $${INCDIR} + +QMAKE_CXXFLAGS += -fexceptions #-I$${INCDIR} +QMAKE_CXXFLAGS_DEBUG += -g3 +QMAKE_CXXFLAGS_DEBUG += -DQDEBUG +QT += qt3support +SOURCES = $${TARGET}.cpp +TEMPLATE = lib + +unix { + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 + QMAKE_LFLAGS += -fPIC +} + +win32 { + LIBXML2DIR = C:\libxml2 + LIBICONVDIR = C:\libiconv + LIBZDIR = C:\libz + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -DLIBXML_STATIC + QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include + +} + +# finish diff --git a/src/TutorialCode/Tutorial4/mymodel.cpp b/src/TutorialCode/Tutorial4/mymodel.cpp new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial4/mymodel.cpp @@ -0,0 +1,75 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include "simplugin.h" + +#include "parameter.h" + +#include "wallbase.h" +#include "cellbase.h" +#include "mymodel.h" + +static const std::string _module_id("$Id$"); + +QString MyModel::ModelID(void) { + // specify the name of your model here + return QString( "Growth, division, coloring" ); +} + +// return the number of chemicals your model uses +int MyModel::NChem(void) { return 0; } + +// To be executed after cell division +void MyModel::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { + // rules to be executed after cell division go here + // (e.g., cell differentiation rules) +} + +void MyModel::SetCellColor(CellBase *c, QColor *color) { + // add cell coloring rules here + if (c->Area()/c->BaseArea()>1.8) { color->setNamedColor("blue"); } + else { color->setNamedColor("green"); } + +} + +void MyModel::CellHouseKeeping(CellBase *c) { + // add cell behavioral rules here + c->EnlargeTargetArea(par->cell_expansion_rate); + if (c->Area() > par->rel_cell_div_threshold * c->BaseArea()) { + c->Divide(); + } +} + +void MyModel::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) { + // add biochemical transport rules here +} +void MyModel::WallDynamics(Wall *w, double *dw1, double *dw2) { + // add biochemical networks for reactions occuring at walls here +} +void MyModel::CellDynamics(CellBase *c, double *dchem) { + // add biochemical networks for intracellular reactions here +} + + +Q_EXPORT_PLUGIN2(mymodel, MyModel) diff --git a/src/TutorialCode/Tutorial4/mymodel.h b/src/TutorialCode/Tutorial4/mymodel.h new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial4/mymodel.h @@ -0,0 +1,60 @@ +/* + * $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. + * + */ + + +#include +#include +#include +#include "simplugin.h" + + +class MyModel : public QObject, SimPluginInterface { + Q_OBJECT + Q_INTERFACES(SimPluginInterface); + +public: + virtual QString ModelID(void); + + // Executed after the cellular mechanics steps have equillibrized + virtual void CellHouseKeeping (CellBase *c); + // Differential equations describing transport of chemicals from cell to cell + virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); + + // Differential equations describing chemical reactions taking place at or near the cell walls + // (e.g. PIN accumulation) + virtual void WallDynamics(Wall *w, double *dw1, double *dw2); + + // Differential equations describing chemical reactions inside the cells + virtual void CellDynamics(CellBase *c, double *dchem); + + // to be executed after a cell division + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); + + // to be executed for coloring a cell + virtual void SetCellColor(CellBase *c, QColor *color); + // return number of chemicals + virtual int NChem(void); +}; + + + + diff --git a/src/TutorialCode/Tutorial4/mymodel.pro b/src/TutorialCode/Tutorial4/mymodel.pro new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial4/mymodel.pro @@ -0,0 +1,61 @@ +# +# $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. +# + + +TARGET = mymodel +VLEAFHOME = ../../.. + +CONFIG += release +CONFIG -= debug +CONFIG += plugin + +BINDIR = $${VLEAFHOME}/bin +LIBDIR = $${VLEAFHOME}/lib +INCDIR = $${VLEAFHOME}/src +DEFINES = QTGRAPHICS # VLEAFPLUGIN +DESTDIR = $${BINDIR}/models +HEADERS = $${TARGET}.h +INCLUDEPATH += $${INCDIR} + +QMAKE_CXXFLAGS += -fexceptions #-I$${INCDIR} +QMAKE_CXXFLAGS_DEBUG += -g3 +QMAKE_CXXFLAGS_DEBUG += -DQDEBUG +QT += qt3support +SOURCES = $${TARGET}.cpp +TEMPLATE = lib + +unix { + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 + QMAKE_LFLAGS += -fPIC +} + +win32 { + LIBXML2DIR = C:\libxml2 + LIBICONVDIR = C:\libiconv + LIBZDIR = C:\libz + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -DLIBXML_STATIC + QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include + +} + +# finish diff --git a/src/TutorialCode/Tutorial5/mymodel.cpp b/src/TutorialCode/Tutorial5/mymodel.cpp new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial5/mymodel.cpp @@ -0,0 +1,120 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include "simplugin.h" + +#include "parameter.h" + +#include "wallbase.h" +#include "cellbase.h" +#include "mymodel.h" + +static const std::string _module_id("$Id$"); + +QString MyModel::ModelID(void) { + // specify the name of your model here + return QString( "Growth hormones" ); +} + +// return the number of chemicals your model uses +int MyModel::NChem(void) { return 1; } + +// To be executed after cell division +void MyModel::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { + // rules to be executed after cell division go here + // (e.g., cell differentiation rules) + + // set one cell to source after first division + if (CellBase::NCells()==2) { + daughter1->SetCellType(1); + daughter2->SetCellType(0); + } + + // if a source cells has divided, one of the daughters becomes the new source + if (daughter1->CellType()==1) { + + // if both cells are at the tissue perimeter, choose at random + if (daughter1->AtBoundaryP() && daughter2->AtBoundaryP()) { + + if (qrand()%2){ + daughter1->SetCellType(1); + daughter2->SetCellType(0); + } else { + daughter1->SetCellType(0); + daughter2->SetCellType(1); + } + } else { + // otherwise choose the one that is still at the perimeter + if (daughter1->AtBoundaryP()) { + daughter1->SetCellType(1); + daughter2->SetCellType(0); + } else { + daughter1->SetCellType(0); + daughter2->SetCellType(1); + } + } + } + +} + +void MyModel::SetCellColor(CellBase *c, QColor *color) { + // add cell coloring rules here + + // white: high concentration of growth hormone, black low concentration + double val = c->Chemical(0)/(1.+c->Chemical(0)); + color->setRgbF(val, val, val); +} + +void MyModel::CellHouseKeeping(CellBase *c) { + // add cell behavioral rules here + if (CellBase::NCells()==1) + // first cell expands unconditionally + c->EnlargeTargetArea(par->cell_expansion_rate); + else + c->EnlargeTargetArea(c->Chemical(0)*par->cell_expansion_rate); + + if (c->Area() > par->rel_cell_div_threshold * c->BaseArea()) { + c->Divide(); + } +} + +void MyModel::CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2) { + // add biochemical transport rules here + double phi = w->Length() * par->D[0] * ( w->C2()->Chemical(0) - w->C1()->Chemical(0) ); + dchem_c1[0]+=phi; + dchem_c2[0]-=phi; +} + +void MyModel::WallDynamics(Wall *w, double *dw1, double *dw2) { + // add biochemical networks for reactions occuring at walls here +} +void MyModel::CellDynamics(CellBase *c, double *dchem) { + // add biochemical networks for intracellular reactions here + if (c->CellType()==1) { + dchem[0] = par->leaf_tip_source; + } +} + + +Q_EXPORT_PLUGIN2(mymodel, MyModel) diff --git a/src/TutorialCode/Tutorial5/mymodel.h b/src/TutorialCode/Tutorial5/mymodel.h new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial5/mymodel.h @@ -0,0 +1,60 @@ +/* + * $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. + * + */ + + +#include +#include +#include +#include "simplugin.h" + + +class MyModel : public QObject, SimPluginInterface { + Q_OBJECT + Q_INTERFACES(SimPluginInterface); + +public: + virtual QString ModelID(void); + + // Executed after the cellular mechanics steps have equillibrized + virtual void CellHouseKeeping (CellBase *c); + // Differential equations describing transport of chemicals from cell to cell + virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); + + // Differential equations describing chemical reactions taking place at or near the cell walls + // (e.g. PIN accumulation) + virtual void WallDynamics(Wall *w, double *dw1, double *dw2); + + // Differential equations describing chemical reactions inside the cells + virtual void CellDynamics(CellBase *c, double *dchem); + + // to be executed after a cell division + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); + + // to be executed for coloring a cell + virtual void SetCellColor(CellBase *c, QColor *color); + // return number of chemicals + virtual int NChem(void); +}; + + + + diff --git a/src/TutorialCode/Tutorial5/mymodel.pro b/src/TutorialCode/Tutorial5/mymodel.pro new file mode 100644 --- /dev/null +++ b/src/TutorialCode/Tutorial5/mymodel.pro @@ -0,0 +1,61 @@ +# +# $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. +# + + +TARGET = mymodel +VLEAFHOME = ../../.. + +CONFIG += release +CONFIG -= debug +CONFIG += plugin + +BINDIR = $${VLEAFHOME}/bin +LIBDIR = $${VLEAFHOME}/lib +INCDIR = $${VLEAFHOME}/src +DEFINES = QTGRAPHICS # VLEAFPLUGIN +DESTDIR = $${BINDIR}/models +HEADERS = $${TARGET}.h +INCLUDEPATH += $${INCDIR} + +QMAKE_CXXFLAGS += -fexceptions #-I$${INCDIR} +QMAKE_CXXFLAGS_DEBUG += -g3 +QMAKE_CXXFLAGS_DEBUG += -DQDEBUG +QT += qt3support +SOURCES = $${TARGET}.cpp +TEMPLATE = lib + +unix { + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 + QMAKE_LFLAGS += -fPIC +} + +win32 { + LIBXML2DIR = C:\libxml2 + LIBICONVDIR = C:\libiconv + LIBZDIR = C:\libz + LIBS += -L$${LIBDIR} -lvleaf + QMAKE_CXXFLAGS += -DLIBXML_STATIC + QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include + +} + +# finish diff --git a/src/VirtualLeafpar.tmpl b/src/VirtualLeafpar.tmpl --- a/src/VirtualLeafpar.tmpl +++ b/src/VirtualLeafpar.tmpl @@ -8,7 +8,7 @@ nodenumsize = 1 / int node_mag = 1.0 / double outlinewidth = 1.0 / double cell_outline_color = forestgreen / string -resize_stride = 10 / int +resize_stride = 0 / int label = / label label = Cell mechanics / label T = 1.0 / double 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 @@ -37,23 +37,23 @@ bool batch = false; // To be executed after cell division -void AuxinGrowthPlugin::OnDivide(ParentInfo &parent_info, CellBase &daughter1, CellBase &daughter2) { +void AuxinGrowthPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { // Auxin distributes between parent and daughter according to area - double area1 = daughter1.Area(), area2 = daughter2.Area(); + double area1 = daughter1->Area(), area2 = daughter2->Area(); double tot_area = area1 + area2; - daughter1.SetChemical(0,daughter1.Chemical(0)*(area1/tot_area)); - daughter2.SetChemical(0,daughter2.Chemical(0)*(area2/tot_area)); + daughter1->SetChemical(0,daughter1->Chemical(0)*(area1/tot_area)); + daughter2->SetChemical(0,daughter2->Chemical(0)*(area2/tot_area)); // After divisions, parent and daughter cells get a standard stock of PINs. - daughter1.SetChemical(1, par->initval[1]); - daughter2.SetChemical(1, par->initval[1]); + daughter1->SetChemical(1, par->initval[1]); + daughter2->SetChemical(1, par->initval[1]); // Reset transporter values of parent and daughter QList walls; foreach(WallBase *w, walls) { - w->setTransporter(&daughter1, 1, 0.); + w->setTransporter(daughter1, 1, 0.); } //daughter1.LoopWalls(Wall::setTransporter(&daughter1, 1, 0.)); @@ -68,29 +68,29 @@ void AuxinGrowthPlugin::OnDivide(ParentI */ } -void AuxinGrowthPlugin::SetCellColor(CellBase &c, QColor &color) { +void AuxinGrowthPlugin::SetCellColor(CellBase *c, QColor *color) { // Red: PIN1 // Green: Auxin - if (c.CellType()==1) color = QColor("Blue"); - else color.setRgb(c.Chemical(1)/(1+c.Chemical(1)) * 255.,(c.Chemical(0)/(1+c.Chemical(0)) * 255.),/* (chem[2]/(1+chem[2]) *255.) */ 0); + if (c->CellType()==1) color->setNamedColor("Blue"); + else color->setRgb(c->Chemical(1)/(1+c->Chemical(1)) * 255.,(c->Chemical(0)/(1+c->Chemical(0)) * 255.),/* (chem[2]/(1+chem[2]) *255.) */ 0); } -void AuxinGrowthPlugin::CellHouseKeeping(CellBase &c) { +void AuxinGrowthPlugin::CellHouseKeeping(CellBase *c) { - if (c.Boundary()==CellBase::None) { - if (c.Area() > par->rel_cell_div_threshold * c.BaseArea() ) { - c.SetChemical(0,0); - c.Divide(); + if (c->Boundary()==CellBase::None) { + if (c->Area() > par->rel_cell_div_threshold * c->BaseArea() ) { + c->SetChemical(0,0); + c->Divide(); } - if (c.Chemical(0)>0.6) { - c.SetCellType(1); + if (c->Chemical(0)>0.6) { + c->SetCellType(1); } // expand according to auxin concentration - c.EnlargeTargetArea(par->auxin_dependent_growth?(c.Chemical(0)/(1.+c.Chemical(0)))*par->cell_expansion_rate:par->cell_expansion_rate); + c->EnlargeTargetArea(par->auxin_dependent_growth?(c->Chemical(0)/(1.+c->Chemical(0)))*par->cell_expansion_rate:par->cell_expansion_rate); } @@ -241,15 +241,15 @@ void AuxinGrowthPlugin::WallDynamics(Wal dw2[1] = dPijdt2; } -double AuxinGrowthPlugin::complex_PijAj(CellBase &here, CellBase &nb, Wall &w) { +double AuxinGrowthPlugin::complex_PijAj(CellBase *here, CellBase *nb, Wall *w) { // gives the amount of complex "auxinreceptor-Pin1" at the wall (at QSS) //return here.Chemical(1) * nb.Chemical(0) / ( par->km + here.Chemical(1)); - double nb_aux = (nb.BoundaryPolP() && w.AuxinSink()) ? par->sam_auxin : nb.Chemical(0); + double nb_aux = (nb->BoundaryPolP() && w->AuxinSink()) ? par->sam_auxin : nb->Chemical(0); double receptor_level = nb_aux * par->r / (par->kr + nb_aux); - return here.Chemical(1) * receptor_level / ( par->km + here.Chemical(1)); + return here->Chemical(1) * receptor_level / ( par->km + here->Chemical(1)); } diff --git a/src/build_models/auxingrowthplugin.h b/src/build_models/auxingrowthplugin.h --- a/src/build_models/auxingrowthplugin.h +++ b/src/build_models/auxingrowthplugin.h @@ -37,7 +37,7 @@ public: virtual QString ModelID(void) { return QString( "Auxin accumulation and growth" ); } // Executed after the cellular mechanics steps have equillibrized - virtual void CellHouseKeeping (CellBase &c); + virtual void CellHouseKeeping (CellBase *c); // Differential equations describing transport of chemicals from cell to cell virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); @@ -49,15 +49,15 @@ public: virtual void CellDynamics(CellBase *c, double *dchem); // to be executed after a cell division - virtual void OnDivide(ParentInfo &parent_info, CellBase &daughter1, CellBase &daughter2); + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); // to be executed for coloring a cell - virtual void SetCellColor(CellBase &c, QColor &color); + virtual void SetCellColor(CellBase *c, QColor *color); // return number of chemicals virtual int NChem(void) { return 2; } private: - double complex_PijAj(CellBase &here, CellBase &nb, Wall &w); + double complex_PijAj(CellBase *here, CellBase *nb, Wall *w); }; #endif 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 @@ -21,7 +21,7 @@ #include #include -#include "simplugin.h" +#include "../simplugin.h" #include "parameter.h" #include "warning.h" @@ -34,24 +34,24 @@ static const std::string _module_id("$Id bool batch = false; // To be executed after cell division -void MeinhardtPlugin::OnDivide(ParentInfo &parent_info, CellBase &daughter1, CellBase &daughter2) { +void MeinhardtPlugin::OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) { } -void MeinhardtPlugin::SetCellColor(CellBase &c, QColor &color) { +void MeinhardtPlugin::SetCellColor(CellBase *c, QColor *color) { - if (fpclassify(c.Chemical(0))==FP_NAN) { + if (fpclassify(c->Chemical(0))==FP_NAN) { // somehow the function isnan doesn't work properly on my system... SuSE Linux // 10.0 64-bits (isnan seems not be implemented using fpclassify). MyWarning::warning("Whoops! Numerical instability!!"); - color.setNamedColor("red"); + color->setNamedColor("red"); } else { double range_min = 0.;//, range_max = 1.; - if (c.Chemical(0)Chemical(0)setNamedColor("blue"); } else { - color.setRgb(c.Chemical(1)/(1+c.Chemical(1)) * 255.,(c.Chemical(0)/(1+c.Chemical(0)) * 255.),(c.Chemical(3)/(1+c.Chemical(3)) *255.) ); + color->setRgb(c->Chemical(1)/(1+c->Chemical(1)) * 255.,(c->Chemical(0)/(1+c->Chemical(0)) * 255.),(c->Chemical(3)/(1+c->Chemical(3)) *255.) ); } } @@ -59,21 +59,21 @@ void MeinhardtPlugin::SetCellColor(CellB -void MeinhardtPlugin::CellHouseKeeping(CellBase &c) { +void MeinhardtPlugin::CellHouseKeeping(CellBase *c) { - if (c.Area() > par->rel_cell_div_threshold * c.BaseArea() ) { - c.Divide(); + if (c->Area() > par->rel_cell_div_threshold * c->BaseArea() ) { + c->Divide(); } // cell expansion is inhibited by substrate (chem 3) - if (!par->constituous_expansion_limit || c.NCells()constituous_expansion_limit) { - c.EnlargeTargetArea(par->cell_expansion_rate ); + if (!par->constituous_expansion_limit || c->NCells()constituous_expansion_limit) { + c->EnlargeTargetArea(par->cell_expansion_rate ); } else { - if (c.Chemical(0)<0.5) { + if (c->Chemical(0)<0.5) { double tmp; - c.EnlargeTargetArea((tmp=(1.-par->vessel_inh_level*c.Chemical(3))*par->cell_expansion_rate /* + c.Chemical(4)*/)<0?0:tmp); + c->EnlargeTargetArea((tmp=(1.-par->vessel_inh_level*c->Chemical(3))*par->cell_expansion_rate /* + c->Chemical(4)*/)<0?0:tmp); } else { - c.EnlargeTargetArea(par->vessel_expansion_rate); + c->EnlargeTargetArea(par->vessel_expansion_rate); } } diff --git a/src/build_models/meinhardtplugin.h b/src/build_models/meinhardtplugin.h --- a/src/build_models/meinhardtplugin.h +++ b/src/build_models/meinhardtplugin.h @@ -26,7 +26,7 @@ #include #include #include -#include "simplugin.h" +#include "../simplugin.h" class MeinhardtPlugin : public QObject, SimPluginInterface { @@ -37,7 +37,7 @@ public: virtual QString ModelID(void) { return QString( "Meinhardt 1976, with growth" ); } // Executed after the cellular mechanics steps have equillibrized - virtual void CellHouseKeeping (CellBase &c); + virtual void CellHouseKeeping (CellBase *c); // Differential equations describing transport of chemicals from cell to cell virtual void CelltoCellTransport(Wall *w, double *dchem_c1, double *dchem_c2); @@ -49,10 +49,10 @@ public: virtual void CellDynamics(CellBase *c, double *dchem); // to be executed after a cell division - virtual void OnDivide(ParentInfo &parent_info, CellBase &daughter1, CellBase &daughter2); + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2); // to be executed for coloring a cell - virtual void SetCellColor(CellBase &c, QColor &color); + virtual void SetCellColor(CellBase *c, QColor *color); // return number of chemicals virtual int NChem(void) { return 4; } }; diff --git a/src/build_models/plugin_auxingrowth.pro b/src/build_models/plugin_auxingrowth.pro --- a/src/build_models/plugin_auxingrowth.pro +++ b/src/build_models/plugin_auxingrowth.pro @@ -24,6 +24,7 @@ CONFIG -= debug CONFIG += plugin BINDIR = ../../bin +LIBDIR = ../../lib DEFINES = QTGRAPHICS # VLEAFPLUGIN DESTDIR = $${BINDIR}/models TARGET = auxingrowth @@ -37,7 +38,7 @@ SOURCES = $${TARGET}plugin.cpp TEMPLATE = lib unix { - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -lvleaf QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 QMAKE_LFLAGS += -fPIC } @@ -46,7 +47,7 @@ win32 { LIBXML2DIR = C:\libxml2 LIBICONVDIR = C:\libiconv LIBZDIR = C:\libz - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -Llib -lvleaf QMAKE_CXXFLAGS += -DLIBXML_STATIC QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include } diff --git a/src/build_models/plugin_leaf.pro b/src/build_models/plugin_leaf.pro --- a/src/build_models/plugin_leaf.pro +++ b/src/build_models/plugin_leaf.pro @@ -24,6 +24,7 @@ CONFIG -= debug CONFIG += plugin BINDIR = ../../bin +LIBDIR = ../../lib DEFINES = QTGRAPHICS # VLEAFPLUGIN DESTDIR = $${BINDIR}/models TARGET = leaf @@ -37,7 +38,7 @@ SOURCES = $${TARGET}plugin.cpp TEMPLATE = lib unix { - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -lvleaf QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 QMAKE_LFLAGS += -fPIC } @@ -46,7 +47,7 @@ win32 { LIBXML2DIR = C:\libxml2 LIBICONVDIR = C:\libiconv LIBZDIR = C:\libz - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -Llib -lvleaf QMAKE_CXXFLAGS += -DLIBXML_STATIC QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include } diff --git a/src/build_models/plugin_meinhardt.pro b/src/build_models/plugin_meinhardt.pro --- a/src/build_models/plugin_meinhardt.pro +++ b/src/build_models/plugin_meinhardt.pro @@ -24,6 +24,7 @@ CONFIG -= debug CONFIG += plugin BINDIR = ../../bin +LIBDIR = ../../lib DEFINES = QTGRAPHICS # VLEAFPLUGIN DESTDIR = $${BINDIR}/models TARGET = meinhardt @@ -37,7 +38,7 @@ SOURCES = $${TARGET}plugin.cpp TEMPLATE = lib unix { - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -lvleaf QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 QMAKE_LFLAGS += -fPIC } @@ -46,7 +47,7 @@ win32 { LIBXML2DIR = C:\libxml2 LIBICONVDIR = C:\libiconv LIBZDIR = C:\libz - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -Llib -lvleaf QMAKE_CXXFLAGS += -DLIBXML_STATIC QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include } diff --git a/src/build_models/plugin_test.pro b/src/build_models/plugin_test.pro --- a/src/build_models/plugin_test.pro +++ b/src/build_models/plugin_test.pro @@ -25,6 +25,7 @@ CONFIG -= debug CONFIG += plugin BINDIR = ../../bin +LIBDIR = ../../lib DEFINES = QTGRAPHICS # VLEAFPLUGIN DESTDIR = $${BINDIR}/models TARGET = test @@ -38,7 +39,7 @@ SOURCES = $${TARGET}plugin.cpp TEMPLATE = lib unix { - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -lvleaf QMAKE_CXXFLAGS += -fPIC -I/usr/include/libxml2 QMAKE_LFLAGS += -fPIC } @@ -47,7 +48,7 @@ win32 { LIBXML2DIR = C:\libxml2 LIBICONVDIR = C:\libiconv LIBZDIR = C:\libz - LIBS += -Llib -lvleaf + LIBS += -L$${LIBDIR} -Llib -lvleaf QMAKE_CXXFLAGS += -DLIBXML_STATIC QMAKE_CXXFLAGS += -I$${LIBXML2DIR}\include -I$${LIBICONVDIR}\include -I$${LIBZDIR}\include diff --git a/src/build_models/translate_plugin.pl b/src/build_models/translate_plugin.pl new file mode 100755 --- /dev/null +++ b/src/build_models/translate_plugin.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +$cfilename = shift(@ARGV) || die "Usage: translate_plugin.pl [cfile] [hfile] [profile]\n"; +$hfilename = shift(@ARGV) || die "Usage: translate_plugin.pl [cfile] [hfile] [profile]\n"; +$pfilename = shift(@ARGV) || die "Usage: translate_plugin.pl [cfile] [hfile] [profile]\n"; + +$ocfname = $cfilename; $ocfname =~ s/\.cpp/_tl.cpp/g; +$ohfname = $hfilename; $ohfname =~ s/\.h/_tl.h/g; +$opfname = $pfilename; $opfname =~ s/\.pro/_tl.pro/g; + +print STDERR "Translating '$cfilename' to '$ocfname', '$hfilename' to '$ohfname', and '$pfilename' to '$opfname'\n"; + +open cfile,"<$cfilename"; +open ocfile,">$ocfname"; + +while () { + + #s/$hfilename/$ohfname/g; + + # translate function definitions + if (/[a-zA-Z0-9 ]*::OnDivide/) { + s/ParentInfo &parent_info/ParentInfo *parent_info/g; + s/CellBase &daughter1/CellBase *daughter1/g; + s/CellBase &daughter2/CellBase *daughter2/g; + } + + if (/[a-zA-Z0-9 ]*::SetCellColor/) { + s/CellBase &c/CellBase *c/g; + s/QColor &color/QColor *color/g; + } + + if (/[a-zA-Z0-9 ]*::CellHouseKeeping/) { + s/CellBase &c/CellBase *c/g; + } + + # translate member function calls + s/\bparent_info\b\./parent_info->/g; + s/\bdaughter1\b\./daughter1->/g; + s/\bdaughter2\b\./daughter2->/g; + s/\bc\b\./c->/g; + s/\bcolor\b\./color->/g; + print ocfile; + +} + +open hfile,"<$hfilename"; +open ohfile,">$ohfname"; + +while () { + if (/[ \t]*virtual[ \t]+void[ \t]+CellHouseKeeping/) { + s/CellBase &c/CellBase *c/g; + } + if (/[ \t]*virtual[ \t]+void[ \t]+OnDivide/) { + s/ParentInfo &parent_info/ParentInfo *parent_info/g; + s/CellBase &daughter1/CellBase *daughter1/g; + s/CellBase &daughter2/CellBase *daughter2/g; + } + if (/[ \t]*virtual[ \t]+void[ \t]+SetCellColor/) { + s/CellBase &c/CellBase *c/g; + s/QColor &color/QColor *color/g; + } + + + print ohfile; + +} + +open pfile,"<$pfilename"; +open opfile,">$opfname"; + +while () { + + s/\bplugin\b\.h/plugin_tl\.h/g; + s/\bplugin\b\.cpp/plugin_tl\.cpp/g; + + print opfile; + +} \ No newline at end of file diff --git a/src/cell.cpp b/src/cell.cpp --- a/src/cell.cpp +++ b/src/cell.cpp @@ -415,6 +415,7 @@ void Cell::DivideWalls(ItList new_node_l daughter->chem[i]=chem[i]; } + daughter->cell_type = cell_type; //extern double auxin_account; //auxin_account += daughter->chem[0]; @@ -1093,7 +1094,7 @@ void Cell::DivideWalls(ItList new_node_l ConstructNeighborList(); daughter->ConstructNeighborList(); - m->plugin->OnDivide(parent_info,*daughter, *this); + m->plugin->OnDivide(&parent_info, daughter, this); // wall->OnWallInsert(); //daughter->OnDivide(); @@ -1660,7 +1661,7 @@ void Cell::Draw(QGraphicsScene *c, QStri QColor cell_color; - m->plugin->SetCellColor(*this,cell_color); + m->plugin->SetCellColor(this,&cell_color); p->setPolygon(pa); p->setPen(par.outlinewidth>=0?QPen( QColor(par.cell_outline_color),par.outlinewidth):QPen(Qt::NoPen)); diff --git a/src/cellbase.cpp b/src/cellbase.cpp --- a/src/cellbase.cpp +++ b/src/cellbase.cpp @@ -101,6 +101,7 @@ Vector() div_counter=0; cell_type = 0; flag_for_divide = false; + division_axis = 0; } @@ -140,6 +141,7 @@ CellBase::CellBase(double x,double y,dou div_counter = 0; cell_type = 0; flag_for_divide = false; + division_axis = 0; } @@ -180,7 +182,7 @@ CellBase::CellBase(const CellBase &src) cell_type = src.cell_type; div_counter = src.div_counter; flag_for_divide = src.flag_for_divide; - + division_axis = src.division_axis; } @@ -219,6 +221,7 @@ CellBase CellBase::operator=(const CellB cell_type = src.cell_type; div_counter = src.div_counter; flag_for_divide = src.flag_for_divide; + division_axis = src.division_axis; return *this; } diff --git a/src/cellbase.h b/src/cellbase.h --- a/src/cellbase.h +++ b/src/cellbase.h @@ -96,6 +96,7 @@ class CellBase : public QObject, public virtual ~CellBase() { delete[] chem; delete[] new_chem; + if (division_axis) delete division_axis; //cerr << "CellBase " << index << " is dying. " << endl; } @@ -217,7 +218,13 @@ class CellBase : public QObject, public inline void Divide(void) { flag_for_divide = true; } - //Vector Strain(void) const; + + inline void DivideOverAxis(const Vector &v) { + division_axis = new Vector(v); + flag_for_divide = true; + } + + //Vector Strain(void) const; inline double Circumference(void) const { double sum=0.; @@ -324,9 +331,9 @@ class CellBase : public QObject, public for (list::const_iterator w=walls.begin(); w!=walls.end(); w++) { - sum += (*w)->c1 == this ? - f( *((*w)->c1), *((*w)->c2), **w ) : - f( *((*w)->c2), *((*w)->c1), **w ); + sum += ((*w)->c1 == this) ? + f( ((*w)->c1), ((*w)->c2), *w ) : + f( ((*w)->c2), ((*w)->c1), *w ); } return sum; } @@ -447,6 +454,8 @@ protected: bool dead; bool flag_for_divide; + Vector *division_axis; + int cell_type; //double length; @@ -475,8 +484,8 @@ protected: ostream &operator<<(ostream &os, const CellBase &v); -inline Vector PINdir(CellBase &here, CellBase &nb, Wall &w) { - return w.getTransporter( &here, 1) * w.getInfluxVector(&here); +inline Vector PINdir(CellBase *here, CellBase *nb, Wall *w) { + return w->getTransporter( here, 1) * w->getInfluxVector(here); } diff --git a/src/libplugin.pro b/src/libplugin.pro --- a/src/libplugin.pro +++ b/src/libplugin.pro @@ -29,7 +29,7 @@ QMAKE_CXXFLAGS_DEBUG += -DQDEBUG QMAKE_CXXFLAGS_DEBUG -= -finstrument-functions DEFINES = QTGRAPHICS # VLEAFPLUGIN -DESTDIR = build_models/lib +DESTDIR = ../lib PERLDIR = ./perl PARTMPL = VirtualLeafpar.tmpl QT += qt3support diff --git a/src/mesh.cpp b/src/mesh.cpp --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -47,7 +47,7 @@ #include #include -static const std::string _module_id("$Id$"); +static const std::string _module_id("$Id: mesh.cpp,v 79f94eaa3b9e 2010/04/14 07:51:02 michael $"); extern Parameter par; @@ -1983,9 +1983,21 @@ void Mesh::Derivatives(double *derivs) { // (*wr)(*w, &(derivs[i]), &(derivs[i+nchems])); plugin->WallDynamics(*w, &(derivs[i]), &(derivs[i+nchems])); // Transport function adds to derivatives of cell chemicals - plugin->CelltoCellTransport(*w, &(derivs[(*w)->c1->Index() * nchems]), - &(derivs[(*w)->c2->Index() * nchems])); - + double *dchem_c1 = &(derivs[(*w)->c1->Index() * nchems]); + double *dchem_c2 = &(derivs[(*w)->c2->Index() * nchems]); + //plugin->CelltoCellTransport(*w, &(derivs[(*w)->c1->Index() * nchems]), + // &(derivs[(*w)->c2->Index() * nchems])); + // quick fix: dummy values to prevent end user from writing into outer space and causing a crash :-) + // start here if you want to implement chemical input/output into environment over boundaries + double dummy1, dummy2; + if ((*w)->c1->Index()<0) { // tests if c1 is the boundary pol + dchem_c1 = &dummy1; + } + if ((*w)->c2->Index()<0) { + dchem_c2 = &dummy2; + } + plugin->CelltoCellTransport(*w, dchem_c1, dchem_c2); + //(*tf)(*w, &(derivs[(*w)->c1->Index() * nchems]), //&(derivs[(*w)->c2->Index() * nchems] ) ); i+=2*nchems; diff --git a/src/mesh.h b/src/mesh.h --- a/src/mesh.h +++ b/src/mesh.h @@ -238,11 +238,17 @@ public: for (vector::iterator i = current_cells.begin(); i != current_cells.end(); i ++) { - plugin->CellHouseKeeping(**i); + plugin->CellHouseKeeping(*i); // Call functions of Cell that cannot be called from CellBase, including Division if ((*i)->flag_for_divide) { - (*i)->Divide(); + if ((*i)->division_axis) { + (*i)->DivideOverAxis(*(*i)->division_axis); + delete (*i)->division_axis; + (*i)->division_axis = 0; + } else { + (*i)->Divide(); + } (*i)->flag_for_divide=false; } } diff --git a/src/modelcatalogue.cpp b/src/modelcatalogue.cpp --- a/src/modelcatalogue.cpp +++ b/src/modelcatalogue.cpp @@ -68,9 +68,13 @@ void ModelCatalogue::LoadPlugins() { qobject_cast(loader.instance())) { models.append(plugin); } else { - MyWarning::warning("Could not load plugin %s",fileName.toStdString().c_str()); + cerr << loader.errorString().toStdString().c_str() << endl; + MyWarning::warning("Could not load model %s: %s",fileName.toStdString().c_str(), loader.errorString().toStdString().c_str()); } } + if (models.size()==0) { + MyWarning::error("No models could be loaded."); + } } void ModelCatalogue::LoadPlugin(const char *model) { diff --git a/src/simplugin.h b/src/simplugin.h --- a/src/simplugin.h +++ b/src/simplugin.h @@ -44,7 +44,7 @@ public: virtual ~SimPluginInterface() { } // Executed after the cellular mechanics steps have equillibrized - virtual void CellHouseKeeping(CellBase &c) = 0; + virtual void CellHouseKeeping(CellBase *c) = 0; // Differential equations describing transport of chemicals from cell to cell virtual void CelltoCellTransport(Wall *, double *dchem_c1, double *dchem_c2) = 0; @@ -57,10 +57,10 @@ public: virtual void CellDynamics(CellBase *c, double *dchem) = 0; // to be executed after a cell division - virtual void OnDivide(ParentInfo &parent_info, CellBase &daughter1, CellBase &daughter2) = 0; + virtual void OnDivide(ParentInfo *parent_info, CellBase *daughter1, CellBase *daughter2) = 0; // to be executed for coloring a cell - virtual void SetCellColor(CellBase &c, QColor &color) = 0; + virtual void SetCellColor(CellBase *c, QColor *color) = 0; // Number of chemicals virtual int NChem(void) = 0; @@ -75,7 +75,7 @@ protected: }; Q_DECLARE_INTERFACE(SimPluginInterface, - "nl.cwi.VirtualLeaf.SimPluginInterface/1.1") + "nl.cwi.VirtualLeaf.SimPluginInterface/1.2") Q_DECLARE_METATYPE(SimPluginInterface *)