Changeset - aaba9e8828d6
[Not reviewed]
default
0 5 0
Roeland Merks - 15 years ago 2010-06-07 15:50:24
roeland.merks@cwi.nl
Added to new menu options: edit->ResetChemicals and edit->ResetTransporters, which allows you to set only the chemicals or only the transporters to the initial values. I needed this for preparing a suitable initial condition for Tutorial 6 and thought it would be useful for the main distribution.

--
user: Roeland Merks <roeland.merks@cwi.nl>
branch 'default'
changed src/build_models/Makefile
changed src/canvas.cpp
changed src/canvas.h
changed src/mesh.cpp
changed src/mesh.h
5 files changed with 315 insertions and 59 deletions:
0 comments (0 inline, 0 general)
src/build_models/Makefile
Show inline comments
 
# $Id: Makefile,v 3f0977faba37 2010/06/03 15:54:37 michael $
 
#############################################################################
 
# Makefile for building: libauxinsimon.so
 
# Generated by qmake (2.01a) (Qt 4.4.1) on: Mon Jun 7 13:36:27 2010
 
# Project:  auxinsimon.pro
 
# Template: lib
 
# Command: /ufs/merks/Trolltech/Qt-4.4.1/bin/qmake -unix -o Makefile auxinsimon.pro
 
#############################################################################
 

	
 
QMAKE = qmake
 
####### Compiler, tools and options
 

	
 
all: plugin_auxingrowth plugin_leaf plugin_meinhardt plugin_test
 
CC            = gcc
 
CXX           = g++
 
DEFINES       = -DQTGRAPHICS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
 
CFLAGS        = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
 
CXXFLAGS      = -m64 -pipe -fexceptions -I.. -fPIC -I/usr/include/libxml2 -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
 
INCPATH       = -I../../../../Trolltech/Qt-4.4.1/mkspecs/linux-g++-64 -I. -I../../../../Trolltech/Qt-4.4.1/include/QtCore -I../../../../Trolltech/Qt-4.4.1/include/QtCore -I../../../../Trolltech/Qt-4.4.1/include/QtGui -I../../../../Trolltech/Qt-4.4.1/include/QtGui -I../../../../Trolltech/Qt-4.4.1/include/Qt3Support -I../../../../Trolltech/Qt-4.4.1/include/Qt3Support -I../../../../Trolltech/Qt-4.4.1/include -I. -I.
 
LINK          = g++
 
LFLAGS        = -m64 -fPIC -Wl,-rpath,/ufs/merks/Trolltech/Qt-4.4.1/lib -shared
 
LIBS          = $(SUBLIBS)  -L/ufs/merks/Trolltech/Qt-4.4.1/lib -L../../lib -lvleaf -lQt3Support -L/ufs/merks/Trolltech/Qt-4.4.1/lib -lQtSql -pthread -pthread -pthread -pthread -lQtXml -pthread -pthread -pthread -pthread -L/usr/X11R6/lib64 -pthread -pthread -pthread -pthread -pthread -pthread -lQtNetwork -pthread -pthread -pthread -pthread -pthread -pthread -lQtGui -pthread -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
 
AR            = ar cqs
 
RANLIB        = 
 
QMAKE         = /ufs/merks/Trolltech/Qt-4.4.1/bin/qmake
 
TAR           = tar -cf
 
COMPRESS      = gzip -9f
 
COPY          = cp -f
 
SED           = sed
 
COPY_FILE     = $(COPY)
 
COPY_DIR      = $(COPY) -r
 
INSTALL_FILE  = install -m 644 -p
 
INSTALL_DIR   = $(COPY_DIR)
 
INSTALL_PROGRAM = install -m 755 -p
 
DEL_FILE      = rm -f
 
SYMLINK       = ln -sf
 
DEL_DIR       = rmdir
 
MOVE          = mv -f
 
CHK_DIR_EXISTS= test -d
 
MKDIR         = mkdir -p
 

	
 
plugin_auxingrowth: Makefile.plugin_auxingrowth
 
	make -f Makefile.plugin_auxingrowth
 
####### Output directory
 

	
 
OBJECTS_DIR   = ./
 

	
 
####### Files
 

	
 
Makefile.plugin_auxingrowth: plugin_auxingrowth.pro
 
	$(QMAKE) -makefile -o $@ $< 
 
SOURCES       = auxinsimon.cpp moc_auxinsimon.cpp
 
OBJECTS       = auxinsimon.o \
 
		moc_auxinsimon.o
 
DIST          = ../../../../Trolltech/Qt-4.4.1/mkspecs/common/g++.conf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/common/unix.conf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/common/linux.conf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/qconfig.pri \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt_functions.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt_config.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/exclusive_builds.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/default_pre.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/release.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/default_post.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/warn_on.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/unix/thread.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/moc.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/resources.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/uic.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/yacc.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/lex.prf \
 
		auxinsimon.pro
 
QMAKE_TARGET  = auxinsimon
 
DESTDIR       = ../../bin/models/
 
TARGET        = libauxinsimon.so
 
TARGETD       = libauxinsimon.so
 

	
 
plugin_leaf: Makefile.plugin_leaf
 
	make -f Makefile.plugin_leaf
 
first: all
 
####### Implicit rules
 

	
 
.SUFFIXES: .o .c .cpp .cc .cxx .C
 

	
 
.cpp.o:
 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 

	
 
.cc.o:
 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 

	
 
.cxx.o:
 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 

	
 
Makefile.plugin_leaf: plugin_leaf.pro
 
	$(QMAKE) -makefile -o $@ $< 
 
.C.o:
 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
 

	
 
.c.o:
 
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
 

	
 
####### Build rules
 

	
 
all: Makefile  ../../bin/models/$(TARGET)
 

	
 
../../bin/models/$(TARGET):  $(OBJECTS) $(SUBLIBS) $(OBJCOMP)  
 
	@$(CHK_DIR_EXISTS) ../../bin/models/ || $(MKDIR) ../../bin/models/ 
 
	-$(DEL_FILE) $(TARGET)
 
	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)
 
	-$(MOVE) $(TARGET) ../../bin/models/
 

	
 

	
 

	
 
plugin_meinhardt: Makefile.plugin_meinhardt
 
	make -f Makefile.plugin_meinhardt
 
Makefile: auxinsimon.pro  ../../../../Trolltech/Qt-4.4.1/mkspecs/linux-g++-64/qmake.conf ../../../../Trolltech/Qt-4.4.1/mkspecs/common/g++.conf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/common/unix.conf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/common/linux.conf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/qconfig.pri \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt_functions.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt_config.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/exclusive_builds.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/default_pre.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/release.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/default_post.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/warn_on.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/unix/thread.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/moc.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/resources.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/uic.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/yacc.prf \
 
		../../../../Trolltech/Qt-4.4.1/mkspecs/features/lex.prf \
 
		/ufs/merks/Trolltech/Qt-4.4.1/lib/libQt3Support.prl \
 
		/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtSql.prl \
 
		/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtCore.prl \
 
		/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtXml.prl \
 
		/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtGui.prl \
 
		/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtNetwork.prl
 
	$(QMAKE) -unix -o Makefile auxinsimon.pro
 
../../../../Trolltech/Qt-4.4.1/mkspecs/common/g++.conf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/common/unix.conf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/common/linux.conf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/qconfig.pri:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt_functions.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt_config.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/exclusive_builds.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/default_pre.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/release.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/default_post.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/warn_on.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/qt.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/unix/thread.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/moc.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/resources.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/uic.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/yacc.prf:
 
../../../../Trolltech/Qt-4.4.1/mkspecs/features/lex.prf:
 
/ufs/merks/Trolltech/Qt-4.4.1/lib/libQt3Support.prl:
 
/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtSql.prl:
 
/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtCore.prl:
 
/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtXml.prl:
 
/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtGui.prl:
 
/ufs/merks/Trolltech/Qt-4.4.1/lib/libQtNetwork.prl:
 
qmake:  FORCE
 
	@$(QMAKE) -unix -o Makefile auxinsimon.pro
 

	
 
Makefile.plugin_meinhardt: plugin_meinhardt.pro
 
	$(QMAKE) -makefile -o $@ $< 
 
dist: 
 
	@$(CHK_DIR_EXISTS) .tmp/auxinsimon1.0.0 || $(MKDIR) .tmp/auxinsimon1.0.0 
 
	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/auxinsimon1.0.0/ && $(COPY_FILE) --parents ../simplugin.h auxinsimon.h .tmp/auxinsimon1.0.0/ && $(COPY_FILE) --parents auxinsimon.cpp .tmp/auxinsimon1.0.0/ && (cd `dirname .tmp/auxinsimon1.0.0` && $(TAR) auxinsimon1.0.0.tar auxinsimon1.0.0 && $(COMPRESS) auxinsimon1.0.0.tar) && $(MOVE) `dirname .tmp/auxinsimon1.0.0`/auxinsimon1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/auxinsimon1.0.0
 

	
 

	
 
plugin_test: Makefile.plugin_test
 
	make -f Makefile.plugin_test
 
clean:compiler_clean 
 
	-$(DEL_FILE) $(OBJECTS)
 
	-$(DEL_FILE) *~ core *.core
 

	
 

	
 
####### Sub-libraries
 

	
 
Makefile.plugin_test: plugin_test.pro
 
	$(QMAKE) -makefile -o $@ $< 
 
distclean: clean
 
	-$(DEL_FILE) $(TARGET) 
 
	-$(DEL_FILE) Makefile
 

	
 

	
 
mocclean: compiler_moc_header_clean compiler_moc_source_clean
 

	
 
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
 

	
 
compiler_moc_header_make_all: moc_auxinsimon.cpp
 
compiler_moc_header_clean:
 
	-$(DEL_FILE) moc_auxinsimon.cpp
 
moc_auxinsimon.cpp: ../simplugin.h \
 
		../cellbase.h \
 
		../vector.h \
 
		../sqr.h \
 
		../parameter.h \
 
		../wall.h \
 
		../wallbase.h \
 
		../warning.h \
 
		auxinsimon.h
 
	/ufs/merks/Trolltech/Qt-4.4.1/bin/moc $(DEFINES) $(INCPATH) auxinsimon.h -o moc_auxinsimon.cpp
 

	
 
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
 
compiler_rcc_make_all:
 
compiler_rcc_clean:
 
compiler_image_collection_make_all: qmake_image_collection.cpp
 
compiler_image_collection_clean:
 
	-$(DEL_FILE) qmake_image_collection.cpp
 
compiler_moc_source_make_all:
 
compiler_moc_source_clean:
 
compiler_uic_make_all:
 
compiler_uic_clean:
 
compiler_yacc_decl_make_all:
 
compiler_yacc_decl_clean:
 
compiler_yacc_impl_make_all:
 
compiler_yacc_impl_clean:
 
compiler_lex_make_all:
 
compiler_lex_clean:
 
compiler_clean: compiler_moc_header_clean 
 

	
 
####### Compile
 

	
 
#finis
 
auxinsimon.o: auxinsimon.cpp ../simplugin.h \
 
		../cellbase.h \
 
		../vector.h \
 
		../sqr.h \
 
		../parameter.h \
 
		../wall.h \
 
		../wallbase.h \
 
		../warning.h \
 
		auxinsimon.h
 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o auxinsimon.o auxinsimon.cpp
 

	
 
moc_auxinsimon.o: moc_auxinsimon.cpp 
 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_auxinsimon.o moc_auxinsimon.cpp
 

	
 
####### Install
 

	
 
install:   FORCE
 

	
 
uninstall:   FORCE
 

	
 
FORCE:
 

	
src/canvas.cpp
Show inline comments
 
@@ -517,96 +517,98 @@ void FigureEditor::insertNode(QPointF p)
 
  Node *node = new Node(p.x(), p.y(), 0);
 
  mesh.AddNode(node);
 
  scene()->clearSelection();
 
  dynamic_cast<Main *>(parent())->Plot();
 
  FullRedraw();
 
#ifdef QDEBUG  
 
  qDebug() << "Node: " << p << endl;
 
#endif
 
}
 

	
 
static uint mainCount = 0;
 

	
 
Main::Main(QGraphicsScene& c, Mesh &m, QWidget* parent, const char* name, Qt::WindowFlags f) :
 
  Q3MainWindow(parent,name,f),
 
  MainBase(c,m),
 
  mesh(m)
 
	   
 
	  //canvas(c)
 
{
 
  editor = new FigureEditor(canvas,mesh, this);
 
  cerr << "Interactive = " << editor->isEnabled();
 
  working_dir = 0;
 
  QObject::connect( editor, SIGNAL(MousePressed()), this, SLOT(PauseIfRunning()));
 
  QObject::connect( editor, SIGNAL(MouseReleased()), this, SLOT(ContIfRunning()));
 
  QMenuBar* menu = menuBar();
 
  
 
  Q3PopupMenu* file = new Q3PopupMenu( menu );
 
 // file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F);
 
	file->insertItem("&Read leaf", this, SLOT(readStateXML()));
 
	file->insertItem("&Save leaf", this, SLOT(saveStateXML()));
 
	file->insertItem("Snapshot", this, SLOT(snapshot()), Qt::CTRL+Qt::SHIFT+Qt::Key_S);
 
 // file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N);
 
   file->insertSeparator();
 
	file->insertItem("Read next leaf", this, SLOT(readNextStateXML()), Qt::Key_PageDown);
 
	file->insertItem("Read previous leaf", this, SLOT(readPrevStateXML()), Qt::Key_PageUp);
 
	file->insertItem("Read last leaf", this, SLOT(readLastStateXML()), Qt::Key_End);
 
	file->insertItem("Read first leaf", this, SLOT(readFirstStateXML()), Qt::Key_Home);
 
	//file->insertItem("Read &parameters", this, SLOT(readPars()));
 
  //file->insertItem("&Write parameters", this, SLOT(savePars()));
 
	
 
	file->insertSeparator();
 
	file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P);
 
	file->insertSeparator();
 
	file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
 
	menu->insertItem("&File", file);
 
	
 
	Q3PopupMenu* edit = new Q3PopupMenu( menu );
 
  edit->insertItem("Reset Chemicals and Transporters", this, SLOT( CleanMesh()), Qt::CTRL+Qt::Key_R );
 
	edit->insertItem("Reset Chemicals", this, SLOT( CleanMeshChemicals()) );
 
	edit->insertItem("Reset Transporters", this, SLOT( CleanMeshTransporters()) );
 
  edit->insertItem("Randomize PIN1 Transporters", this, SLOT( RandomizeMesh()) );
 
  edit->insertItem("Cut away SAM", this, SLOT( CutSAM() ));
 
  menu->insertItem("&Edit", edit);
 

	
 
  run = new Q3PopupMenu( menu );
 
  //  edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), ALT+Key_P);
 
  //edit->insertItem("Add &Line", this, SLOT(addLine()), ALT+Key_L);
 
  running = false;
 
	paused_id = run->insertItem("&Simulation paused", this, SLOT(togglePaused()), Qt::Key_S);
 
  run->setItemChecked(paused_id, FALSE);
 

	
 
  //run->insertItem("&Divide Cell", this, SLOT(Divide()), Qt::CTRL+Qt::Key_D);
 
 // run->insertItem("&Restart Simulation", this, SLOT(RestartSim())); 
 
  menu->insertItem("&Run", run);
 
  
 
  view = new Q3PopupMenu( menu );
 
  //view->insertItem("&Enlarge", this, SLOT(enlarge()), SHIFT+CTRL+Key_Plus);
 
  //view->insertItem("Shr&ink", this, SLOT(shrink()), SHIFT+CTRL+Key_Minus);
 
	view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Equal);
 
  view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus);
 
	view->insertSeparator();
 
	com_id = view->insertItem("Show cell &centers", this, SLOT(toggleShowCellCenters()));
 
  view->setItemChecked(com_id, FALSE);
 
  //view->insertItem("Cell monitor", this, SLOT(cellmonitor()));
 
  mesh_id = view->insertItem("Show &nodes", this, SLOT(toggleShowNodes()), Qt::CTRL+Qt::SHIFT+Qt::Key_N);
 
  view->setItemChecked(mesh_id, TRUE);
 
  node_number_id = view->insertItem("Show node numbers", this, SLOT(toggleNodeNumbers()), Qt::CTRL+Qt::SHIFT+Qt::Key_M);
 
  view->setItemChecked(node_number_id, TRUE);
 
  cell_number_id = view->insertItem("Show cell numbers", this, SLOT(toggleCellNumbers()));
 
  view->setItemChecked(cell_number_id, TRUE);
 
  hide_cells_id = view->insertItem("Hide cells", this, SLOT(toggleHideCells()));
 
  view->setItemChecked(hide_cells_id, FALSE);
 
  border_id = view->insertItem("Show &border cells", this, SLOT(toggleShowBorderCells()));
 
  view->setItemChecked(border_id, FALSE);
 
  cell_axes_id = view->insertItem("Show cell &axes", this, SLOT(toggleCellAxes()));
 
  cell_strain_id = view->insertItem("Show cell &strain", this, SLOT(toggleCellStrain()));
 
  view->setItemChecked(cell_axes_id, FALSE);
 
  fluxes_id = view->insertItem("Show &fluxes", this, SLOT(toggleShowFluxes()));
 
  view->setItemChecked(fluxes_id, FALSE);
 
  cell_walls_id = view->insertItem("Show transporters", this, SLOT(toggleShowWalls()));
 
	view->setItemChecked(cell_walls_id, FALSE);
 
	apoplasts_id = view->insertItem("Show apoplasts", this, SLOT(toggleShowApoplasts()));
 
  view->setItemChecked(apoplasts_id, FALSE);
 
 	view->insertSeparator();
 
	  only_boundary_id = view->insertItem("Show only leaf &boundary", this, SLOT(toggleLeafBoundary()));
 
  //only_boundary_id = view->insertItem("Show only leaf &boundary", 0,0);
 
	view->insertSeparator();
 
	movie_frames_id = view->insertItem("Start saving movie &frames", this, SLOT(toggleMovieFrames()));
 
@@ -1392,106 +1394,148 @@ void Main::toggleHideCells(void) {
 
void Main::FitCanvasToWindow(void) {
 
  
 
  double scale_factor_x = (double)editor->width()/(double)canvas.width();
 
  double scale_factor_y = (double)editor->height()/(double)canvas.height();
 
  double scale_factor = scale_factor_x > scale_factor_y ? scale_factor_x : scale_factor_y;
 
  QMatrix m = editor->matrix();
 
  
 
  cerr << "editor->width() = " << editor->width() << endl;
 
  cerr << "editor->height() = " << editor->height() << endl;
 
  
 
  cerr << "scale_factor = " << scale_factor << endl;
 
  cerr << "scale_factor_x = " << scale_factor_x << endl;
 
  cerr << "scale_factor_y = " << scale_factor_y << endl;
 
  m.scale( scale_factor, scale_factor );
 
  editor->setMatrix( m );
 
  editor->show();
 
}
 

	
 
  void Main::PauseIfRunning(void) {
 
    if (running) {
 
      timer->stop();
 
    }
 
  }
 

	
 
  void Main::ContIfRunning(void) {
 
    if (running) {
 
      timer->start( 0 );
 
    }
 
  }
 

	
 
void Main::FitLeafToCanvas(void) {
 

	
 
  Vector ll,ur;
 
  mesh.BoundingBox(ll, ur);
 
  
 
  ll*=Cell::Magnification(); ur*=Cell::Magnification();
 
  
 
  // give the leaf some space
 
  Vector border = ((ur-ll)/5.);
 
  
 
  QRectF bb( ll.x - border.x, ll.y - border.y, ur.x-ll.x + 2*border.x, ur.y-ll.y + 2*border.y );
 
  
 
  
 
  // cerr << ur << ", " << ll << endl;
 
  editor->fitInView(bb, Qt::KeepAspectRatio);
 
}
 

	
 
void Main::CleanMesh(void) {
 
  
 
  mesh.SettoInitVals();
 
	vector<double> clean_chem(Cell::NChem());
 
	vector<double> clean_transporters(Cell::NChem());
 

	
 
	for (int i=0;i<Cell::NChem();i++) {
 
		clean_chem[i]=par.initval[i];
 
		clean_transporters[i]=0.;		
 
	}
 
	
 
	mesh.CleanChemicals(clean_chem);
 
	mesh.CleanTransporters(clean_transporters);
 
	
 
	mesh.setTime(0);
 
  Plot();
 
  
 
  editor->FullRedraw();
 
 
 
	Plot();
 
	
 
	editor->FullRedraw();
 
	
 
  //  repaint();
 
}
 

	
 
void Main::CleanMeshChemicals(void) {
 
	
 
	vector<double> clean_chem(Cell::NChem());
 

	
 
	for (int i=0;i<Cell::NChem();i++) {
 
		clean_chem[i]=par.initval[i];
 
	}
 
	
 
	mesh.CleanChemicals(clean_chem);
 
	mesh.setTime(0);
 
	Plot();
 
	
 
	editor->FullRedraw();
 
	
 
	//  repaint();
 
}
 

	
 
void Main::CleanMeshTransporters(void) {
 
	vector<double> clean_transporters(Cell::NChem());
 
	for (int i=0;i<Cell::NChem();i++) {
 
		clean_transporters[i]=0.;
 
	}
 
	
 
	mesh.CleanTransporters(clean_transporters);
 
	
 
	mesh.setTime(0);
 
	Plot();
 
	
 
	editor->FullRedraw();
 
	
 
	//  repaint();
 
}
 

	
 
void Main::RandomizeMesh(void) {
 
  
 
  vector<double> max_chem(Cell::NChem());
 
  vector<double> max_transporters(Cell::NChem());
 
  
 
  for (int i=0;i<Cell::NChem();i++) {
 
    max_transporters[i]=0.;
 
    max_chem[i]=par.initval[i];
 
  }
 

	
 
  // Amount of PIN1 at walls
 
  max_transporters[1] = 0.01;
 
  
 
  mesh.RandomizeChemicals(max_chem, max_transporters);
 
  
 
  Plot();
 
}
 

	
 
void Main::XMLReadSettings(xmlNode *settings) {
 
  
 
  MainBase::XMLReadSettings(settings);
 

	
 
  view->setItemChecked(com_id, showcentersp);
 
  view->setItemChecked(mesh_id, showmeshp);
 
  view->setItemChecked(border_id, showbordercellp);
 
  view->setItemChecked(node_number_id, shownodenumbersp);
 
  view->setItemChecked(cell_number_id, showcellnumbersp);
 
  view->setItemChecked(cell_axes_id, showcellsaxesp);
 
  view->setItemChecked(cell_strain_id, showcellstrainp);
 
  view->setItemChecked(movie_frames_id, movieframesp);
 
  view->setItemChecked(only_boundary_id, showboundaryonlyp);
 
  view->setItemChecked(fluxes_id, showfluxesp);
 
  view->setItemChecked(hide_cells_id, hidecellsp);
 
  options->setItemChecked(dyn_cells_id, dynamicscellsp);
 
  view->setItemChecked( cell_walls_id, showwallsp);
 
	view->setItemChecked( apoplasts_id, showapoplastsp);
 
}
 

	
 
xmlNode *Main::XMLSettingsTree(void) {
 

	
 
  showcentersp = view->isItemChecked(com_id);
 
  showmeshp = view->isItemChecked(mesh_id);
 
  showbordercellp =  view->isItemChecked(border_id);
 
  shownodenumbersp =  view->isItemChecked(node_number_id);
 
  showcellnumbersp =  view->isItemChecked(cell_number_id);
 
  showcellsaxesp = view->isItemChecked( cell_axes_id );
 
  showcellstrainp = view->isItemChecked( cell_strain_id );
 
  movieframesp = view->isItemChecked(movie_frames_id);;
src/canvas.h
Show inline comments
 
@@ -181,98 +181,101 @@ class Main : public Q3MainWindow, public
 
      // Exit rotation mode if mouse is clicked
 
      connect(editor, SIGNAL(MousePressed()), this, SLOT(ExitRotationMode()));
 
    }
 
  
 
  }
 
  void ExitRotationMode(void) { 
 
    UserMessage("Exited rotation mode.",2000);
 

	
 
    options->setItemChecked(rotation_mode_id, false); 
 
    if (editor)
 
      disconnect(editor, SIGNAL(MousePressed()), this, SLOT(ExitRotationMode()));
 
  }
 

	
 
  virtual void UserMessage(QString message, int timeout=0);
 
  void Refresh(void) { Plot(); }
 
  void PauseIfRunning(void);
 
  void ContIfRunning(void);
 
  virtual void XMLReadSettings(xmlNode *settings);
 
   
 
  private slots:
 
  void aboutQt();
 
  void newView();
 
  void EditParameters();
 
  void readStateXML();
 
  int readStateXML(const char *filename, bool geometry = true, bool pars=true, bool simtime = true);
 
  void readNextStateXML();
 
  void readPrevStateXML();
 
  void readFirstStateXML();
 
  void readLastStateXML();
 
  void saveStateXML();
 
  void snapshot();
 
  void savePars();
 
  void readPars();
 
  void clear();
 
  void init();
 
  virtual void CutSAM() { MainBase::CutSAM(); Refresh();}
 
/*   void cellmonitor() { */
 
/*     PlotDialog *plot = new PlotDialog(this); */
 
/*     cerr << "Attempting to launch a cell monitor\n"; */
 
/*   } */
 
  
 
  //void addPolygon();
 
  //void addLine();
 

	
 
  void enlarge();
 
  void shrink();
 
  void zoomIn();
 
  void zoomOut();
 
  
 
	>
 
  void CleanMesh();
 
	void CleanMeshChemicals(void);
 
	void CleanMeshTransporters(void);
 
	
 
  void RandomizeMesh();
 

	
 
 signals:
 
  void SimulationDone(void);
 
  void ParsChanged(void);
 
  
 
 protected:
 
  Mesh &mesh;
 
  
 
 private:
 
  NodeSet *node_set;
 
  FigureEditor *editor;
 
  //QCanvas& canvas;
 
  Q3PopupMenu* options;
 
  Q3PopupMenu *view;
 
  Q3PopupMenu *run;
 
	QMenu *modelmenu;
 
  Q3PopupMenu *helpmenu;
 

	
 
  QPrinter* printer;
 
  const QDir *working_dir;
 
  QString currentFile;
 
  //  toggle item states 
 
  int dbf_id; // options->Double Buffer
 
  int com_id; // view->Show centers
 
  int mesh_id; // view->Show mesh
 
  int node_number_id; // view->Show Node numbers
 
  int cell_number_id; // view->Show Cell numbers
 
  int border_id; // view->Show border cells
 
  int paused_id; // run->Simulation paused
 
  int cell_axes_id; // view->Show cell axes
 
  int cell_strain_id; // view->Show cell strain
 
  int only_boundary_id; // view ->Show only leaf boundary
 
  int cell_walls_id; // view -> Show transporters
 
	int apoplasts_id; // view -> Show apoplasts
 
  int tooltips_id; // help -> Show Cell Info
 
  int hide_cells_id; // view->Hide Cells
 
  double flux_arrow_size;
 
  int movie_frames_id;
 
  int fluxes_id;
 
  int dyn_cells_id;
 
  int rotation_mode_id;
 
  int insert_mode_id;
 
  QTimer *timer;
 
  QFile *gifanim;
 
  bool running;
 
  virtual xmlNode *XMLSettingsTree(void);
 
  static const QString caption;
src/mesh.cpp
Show inline comments
 
@@ -1843,125 +1843,138 @@ Vector Mesh::FirstConcMoment(int chem) {
 
  to the boundary polygon.
 
*/
 
void Mesh::DeleteLooseWalls(void) {
 

	
 
  list<Wall *>::iterator w=walls.begin();
 
  
 
  while (w!=walls.end()) {
 
    
 
    // if both cells of the wall are dead, remove the wall
 
    if ((*w)->C1()->DeadP() || (*w)->C2()->DeadP()) {
 
      if ((*w)->C1()->DeadP() && (*w)->C2()->DeadP()) {
 
	delete *w;
 
	w=walls.erase(w);
 
      } else {
 
	if ((*w)->C1()->DeadP())
 
	  (*w)->c1 = boundary_polygon;
 
	else
 
	  (*w)->c2 = boundary_polygon;
 
	w++;
 
      }
 
    } else {
 
      w++;
 
    }
 
    
 
  }
 
  
 
}
 

	
 
/*void Mesh::FitLeafToCanvas(double width, double height) {
 

	
 
  Vector bbll,bbur;
 
  BoundingBox(bbll,bbur);
 
  
 
  double scale_x = width/(bbur.x-bbll.x);
 
  double scale_y = height/(bbur.y-bbll.y);
 
  
 
  double factor = scale_x<scale_y ? scale_x:scale_y;
 
  
 
  Cell::SetMagnification(factor); // smallest of scale_x and scale_y
 
  
 
  double offset_x = (width/Cell::Magnification()-(bbur.x-bbll.x))/2.;  
 
  double offset_y = (height/Cell::Magnification()-(bbur.y-bbll.y))/2.;
 
  
 
  Cell::setOffset(offset_x, offset_y);
 
  
 
  }*/
 

	
 

	
 
void Mesh::CleanChemicals(const vector<double> &clean_chem, const vector<double> &clean_transporters) {
 
  
 
  if (clean_chem.size()!=(unsigned)Cell::NChem() || clean_transporters.size()!=(unsigned)Cell::NChem()) {
 
    throw "Run time error in Mesh::CleanChemicals: size of clean_chem and clean_transporters should be equal to Cell::NChem()";
 
  }
 
  for (vector<Cell *>::iterator c=cells.begin();
 
       c!=cells.end();
 
       c++) {
 
    
 
    for (int i=0;i<Cell::NChem();i++) {
 
      (*c)->SetChemical(i,clean_chem[i]);
 
    }
 
    (*c)->SetNewChemToChem();
 

	
 
void Mesh::CleanChemicals(const vector<double> &clean_chem) {
 
	
 
	if (clean_chem.size()!=(unsigned)Cell::NChem()) {
 
		throw "Run time error in Mesh::CleanChemicals: size of clean_chem should be equal to Cell::NChem()";
 
	}
 
	for (vector<Cell *>::iterator c=cells.begin();
 
		 c!=cells.end();
 
		 c++) {
 
		
 
		for (int i=0;i<Cell::NChem();i++) {
 
			(*c)->SetChemical(i,clean_chem[i]);
 
		}
 
		(*c)->SetNewChemToChem();
 
		
 
	}
 
	
 

	
 
}
 

	
 

	
 
  }
 
void Mesh::CleanTransporters(const vector<double> &clean_transporters) {
 
	
 
	if (clean_transporters.size()!=(unsigned)Cell::NChem()) {
 
		throw "Run time error in Mesh::CleanTransporters: size ofclean_transporters should be equal to Cell::NChem()";
 
	}
 

	
 
  // clean transporters
 
  for (list<Wall *>::iterator w=walls.begin();
 
       w!=walls.end();
 
       w++) {
 
    
 
    for (int i=0;i<Cell::NChem();i++) {
 
      (*w)->setTransporters1(i,clean_transporters[i]); (*w)->setNewTransporters1(i,clean_transporters[i]);
 
      (*w)->setTransporters2(i,clean_transporters[i]); (*w)->setNewTransporters2(i,clean_transporters[i]);
 
    }
 
  }
 
  
 
	
 
	// clean transporters
 
	for (list<Wall *>::iterator w=walls.begin();
 
		 w!=walls.end();
 
		 w++) {
 
		
 
		for (int i=0;i<Cell::NChem();i++) {
 
			(*w)->setTransporters1(i,clean_transporters[i]); (*w)->setNewTransporters1(i,clean_transporters[i]);
 
			(*w)->setTransporters2(i,clean_transporters[i]); (*w)->setNewTransporters2(i,clean_transporters[i]);
 
		}
 
	}
 
	
 
}
 

	
 

	
 
void Mesh::RandomizeChemicals(const vector<double> &max_chem, const vector<double> &max_transporters) {
 
  
 
  if (max_chem.size()!=(unsigned)Cell::NChem() || max_transporters.size()!=(unsigned)Cell::NChem()) {
 
    throw "Run time error in Mesh::CleanChemicals: size of max_chem and max_transporters should be equal to Cell::NChem()";
 
  }
 
  
 
  for (vector<Cell *>::iterator c=cells.begin();
 
       c!=cells.end();
 
       c++) {
 
    
 
    for (int i=0;i<Cell::NChem();i++) {
 
      (*c)->SetChemical(i,max_chem[i]*RANDOM());
 
    }
 
    (*c)->SetNewChemToChem();
 

	
 
  }
 

	
 
  // randomize transporters
 
  for (list<Wall *>::iterator w=walls.begin();
 
       w!=walls.end();
 
       w++) {
 
    
 
    for (int i=0;i<Cell::NChem();i++) {
 
      (*w)->setTransporters1(i,max_transporters[i] * RANDOM()); (*w)->setNewTransporters1(i, (*w)->Transporters1(i) );
 
      (*w)->setTransporters2(i,max_transporters[i] * RANDOM()); (*w)->setNewTransporters2(i, (*w)->Transporters1(i) );
 
    }
 
  }
 
  
 
}
 

	
 
//!\brief Calculates a vector with derivatives of all variables, which
 
// we can pass to an ODESolver. 
 
void Mesh::Derivatives(double *derivs) {
 
  
 
  int nwalls = walls.size();
 
  int ncells = cells.size();
 
  int nchems = Cell::NChem();
 
  
 
  // two eqs per chemical for each walls, and one eq per chemical for each cell
 
  // This is for generality. For a specific model you may optimize
 
  // this by removing superfluous (empty) equations.
 
  int neqs = 2 * nwalls * nchems + ncells * nchems;
 
  
 
  //static double *derivs = 0; 
 
  // derivs is allocated by RungeKutta class.
 

	
 
  for (int i=0;i<neqs;i++) { derivs[i]=0.;}
 
  
 
@@ -2113,97 +2126,98 @@ void Mesh::DrawNodes(QGraphicsScene *c) 
 
    
 
    item->setZValue(5);
 
    item->show();
 
    item ->setPos(((Cell::offset[0]+i->x)*Cell::factor),
 
		  ((Cell::offset[1]+i->y)*Cell::factor) );
 
  }
 

	
 
}
 

	
 
/*! Returns the sum of protein "ch" of a cycling protein in cells and walls */
 
double Mesh::CalcProtCellsWalls(int ch) const {
 

	
 

	
 
  double sum_prot=0.;
 

	
 
  // At membranes
 
  for (list<Wall *>::const_iterator w=walls.begin();
 
       w!=walls.end();
 
       w++) {
 
    sum_prot += (*w)->Transporters1(ch);
 
    sum_prot += (*w)->Transporters2(ch);
 
  }
 

	
 
  // At cells
 
  for (vector<Cell *>::const_iterator c=cells.begin();
 
       c!=cells.end();
 
       c++) {
 
    
 
    sum_prot += (*c)->Chemical(ch);
 
  }
 
  
 
  return sum_prot;
 

	
 
}
 

	
 
void Mesh::SettoInitVals(void) {
 
  
 
  vector<double> clean_chem(Cell::NChem());
 
  vector<double> clean_transporters(Cell::NChem());
 
  
 
  for (int i=0;i<Cell::NChem();i++) {
 
    clean_transporters[i]=0.;
 
    clean_chem[i]=par.initval[i];
 
  }
 

	
 
  // Amount of PIN1
 
  //clean_chem[1] = 0.;
 
  
 
  CleanChemicals(clean_chem, clean_transporters);
 
	CleanChemicals(clean_chem);
 
	CleanTransporters(clean_transporters);
 

	
 
}
 

	
 
string Mesh::getTimeHours(void) const {
 
	int hours = (int)(time / 3600);
 
	int mins = (int)((time - hours * 3600)/60);
 
	int secs = (int)((time - hours * 3600 - mins * 60));
 
	ostringstream tstr;
 
	tstr << hours << " h " << mins << " m " << secs << " s";
 
	return tstr.str();
 
}
 

	
 
QVector<qreal> Mesh::VertexAngles(void) {
 
	QVector<qreal> angles;
 
	for (vector<Node *>::const_iterator n=nodes.begin();
 
		 n!=nodes.end();
 
		 n++) {
 
		if ((*n)->Value()>2 && !(*n)->BoundaryP() ) {
 
			angles+=(*n)->NeighbourAngles();
 
		}
 
	}
 
	return angles;
 
}
 

	
 
QVector< QPair<qreal,int> > Mesh::VertexAnglesValues(void) {
 

	
 
	QVector< QPair<qreal,int> > anglesvalues;
 
	for (vector<Node *>::const_iterator n=nodes.begin();
 
		 n!=nodes.end();
 
		 n++) {
 
		if ((*n)->Value()>2 && !(*n)->BoundaryP() ) {
 
			
 
			QVector<qreal> angles = (*n)->NeighbourAngles();
 
			int value_vertex = angles.size();
 
			for (QVector<qreal>::ConstIterator i=angles.begin();
 
				 i!=angles.end();
 
				 i++) {
 
				
 
				anglesvalues += QPair< qreal, int > (*i, value_vertex);
 
			}
 
		}
 
	}
 
	return anglesvalues;
 
}
 

	
 
void Mesh::Clean(void) {
 
        #ifdef QDEBUG
 
        qDebug() << "Freeing nodes" << endl;
src/mesh.h
Show inline comments
 
@@ -368,97 +368,98 @@ public:
 
	inline void DrawBoundary(QGraphicsScene *c) {
 
		boundary_polygon->Draw(c);
 
	}
 
	void DrawNodes(QGraphicsScene *c) const;
 
	
 
#endif
 
	double max_chem;
 
	
 
	void XMLSave(const char *docname, xmlNode *settings=0) const;
 
	void XMLRead(const char *docname, xmlNode **settings=0, bool geometry = true, bool pars = true, bool simtime = true);
 
	void XMLReadPars(const xmlNode * root_node);
 
	void XMLReadGeometry(const xmlNode *root_node);
 
	void XMLReadSimtime(const xmlNode *root_node);
 
	void XMLReadNodes(xmlNode *cur);
 
	void XMLReadCells(xmlNode *cur);
 
	void XMLParseTree(const xmlNode * root_node);
 
	void XMLReadWalls(xmlNode *cur, vector<Wall *> *tmp_cells);
 
	void XMLReadWallsToCells(xmlNode *root, vector<Wall *> *tmp_walls);
 
	void XMLReadNodeSets(xmlNode *root);
 
	void XMLReadNodeSetsToNodes(xmlNode *root);
 
	void PerturbChem(int chemnum, double range);
 
	void CleanUpCellNodeLists(void);
 
	void CleanUpWalls(void);
 
	void CutAwayBelowLine( Vector startpoint, Vector endpoint );
 
	void CutAwaySAM(void);
 
	void RepairBoundaryPolygon(void);
 
	void Rotate(double angle, Vector center);
 
	void PrintWallList( void );
 
	void TestIllegalWalls(void);
 
	Vector FirstConcMoment(int chem);
 
	inline Vector Centroid(void) {
 
		return boundary_polygon->Centroid();
 
	}
 
	
 
	inline Vector Offset(void) {
 
		return boundary_polygon->Offset();
 
	}
 
	
 
	inline double Factor(void) {
 
		return boundary_polygon->Factor();
 
	}
 
	
 
	void DeleteLooseWalls(void);
 
	void FitLeafToCanvas(double width, double height);
 
	void AddNodeSet(NodeSet *node_set) {
 
		node_sets.push_back(node_set);
 
	}
 
	
 
	void CleanChemicals(const vector<double> &clean_chem, const vector<double> &clean_transporters);
 
	void CleanChemicals(const vector<double> &clean_chem);
 
	void CleanTransporters(const vector<double> &clean_transporters);
 
	void RandomizeChemicals(const vector<double> &max_chem, const vector<double> &max_transporters);
 
	inline double getTime(void) const { return time; }
 
	string getTimeHours(void) const; 
 
	inline void setTime(double t) { time = t; }
 
	double CalcProtCellsWalls(int ch) const;  
 
	void SettoInitVals(void);
 
	QVector<qreal> VertexAngles(void);
 
	QVector< QPair<qreal,int> > VertexAnglesValues(void);
 
	void SetSimPlugin(SimPluginInterface *new_plugin) {
 
		/* if (plugin) 
 
			delete plugin;*/
 
		plugin=new_plugin;
 
	}
 
	QString ModelID(void) { return plugin?plugin->ModelID():QString("undefined"); }
 
	void StandardInit(void);	
 

	
 
	Node* findNextBoundaryNode(Node*);
 

	
 
private:
 
	
 
	// Data members
 
	vector<Cell *> cells;
 
	vector<Node *> nodes;
 
	list<Wall *> walls; // we need to erase elements from this container frequently, hence a list.
 
public:
 
	vector<NodeSet *> node_sets;
 
private:
 
	vector<Node *> shuffled_nodes;
 
	vector<Cell *> shuffled_cells;
 
	unique_queue<Edge> node_insertion_queue;
 
	BoundaryPolygon *boundary_polygon;
 
	double time;
 
	SimPluginInterface *plugin;
 
	
 
	// Private member functions
 
	void AddNodeToCell(Cell *c, Node *n, Node *nb1 , Node *nb2);
 
	void AddNodeToCellAtIndex(Cell *c, Node *n, Node *nb1 , Node *nb2, list<Node *>::iterator ins_pos);
 
	void InsertNode(Edge &e);
 
	inline Node *AddNode(Node *n) {
 
		nodes.push_back(n);
 
		shuffled_nodes.push_back(n);
 
		n->m=this;
 
		return n;
 
	}
 
	
 
	inline Cell *AddCell(Cell *c) {
 
		cells.push_back(c);
 
		shuffled_cells.push_back(c);
0 comments (0 inline, 0 general)