Files
@ 4cb24b737683
Branch filter:
Location: EI/VirtualLeaf/src/canvas.h
4cb24b737683
7.6 KiB
text/x-chdr
merge? I tried to push my recent updates, hoping I haven't messed up things. All intermediate versions are kept anyway, right?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | /*
*
* $Id$
*
* This file is part of the Virtual Leaf.
*
* VirtualLeaf 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.
*
* VirtualLeaf 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 <http://www.gnu.org/licenses/>.
*
* Copyright 2010 Roeland Merks.
*
*/
#ifndef _CANVAS_H_
#define _CANVAS_H_
#include <q3popupmenu.h>
#include <q3mainwindow.h>
#include <q3intdict.h>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QList>
#include <string>
#include <sstream>
//Added by qt3to4:
#include <QMouseEvent>
#include <vector>
#include "simitembase.h"
#include "mainbase.h"
#include "cellitem.h"
#include "infobar.h"
#include "nodeitem.h"
#include "cell.h"
#ifdef HAVE_QWT
#include "data_plot.h"
#endif
#include <libxml/xpath.h>
#include <libxml/xmlreader.h>
#if defined(Q_OS_MAC)
#define PREFIX "cmd"
#else
#define PREFIX "crtl"
#endif
class QFile;
class QDir;
class ModelCatalogue;
class InfoBar;
class FigureEditor : public QGraphicsView {
Q_OBJECT
friend class Main;
public:
FigureEditor(QGraphicsScene&, Mesh&, QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
void clear();
void Save(const char *fname, const char *format, int sizex=640, int sizey=480);
void FullRedraw(void);
protected:
void mousePressEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void wheelEvent(QWheelEvent *event);
void scaleView(qreal scaleFactor);
vector <CellItem *> getIntersectedCells(void);
void insertNode(QPointF p);
NodeItem *selectedNodeItem(QList<QGraphicsItem *> l) const;
signals:
void status(const QString&);
void MousePressed(void);
void MouseReleased(void);
protected:
Mesh &mesh;
private:
//NodeItem* moving;
SimItemBase *moving;
QPointF moving_start;
QGraphicsLineItem *intersection_line;
bool rotation_mode;
bool insert_mode;
double rot_angle;
};
class Main : public Q3MainWindow, public MainBase {
Q_OBJECT
friend class ModelCatalogue; // needs to populate menu item models
public:
Main(QGraphicsScene&, Mesh&, QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
~Main();
virtual bool ShowCentersP(void) {return view->isItemChecked(com_id);}
virtual bool ShowMeshP(void) {return view->isItemChecked(mesh_id);}
virtual bool ShowBorderCellsP(void) {return view->isItemChecked(border_id);}
virtual bool PausedP(void) {return run->isItemChecked(paused_id);}
virtual bool ShowNodeNumbersP(void) {return view->isItemChecked(node_number_id);}
virtual bool ShowCellNumbersP(void) {return view->isItemChecked(cell_number_id);}
virtual bool ShowCellAxesP(void) {return view->isItemChecked(cell_axes_id);}
virtual bool ShowCellStrainP(void) {return view->isItemChecked(cell_strain_id);}
virtual bool MovieFramesP(void) {return view->isItemChecked(movie_frames_id);}
virtual bool ShowBoundaryOnlyP(void) {return view->isItemChecked(only_boundary_id);}
virtual bool ShowWallsP(void) {return view->isItemChecked(cell_walls_id);}
// virtual bool ShowApoplastsP(void) { return view->isItemChecked(apoplasts_id);}
virtual bool ShowFluxesP(void) { return view->isItemChecked(fluxes_id); }
virtual bool DynamicCellsP(void) { return options->isItemChecked(dyn_cells_id); }
virtual bool RotationModeP(void) { return options->isItemChecked(rotation_mode_id); }
virtual bool InsertModeP(void) { return options->isItemChecked(insert_mode_id); }
virtual bool ShowToolTipsP(void) { return helpmenu->isItemChecked(tooltips_id); }
virtual bool HideCellsP(void) { return view->isItemChecked(hide_cells_id); }
void scale(double factor);
virtual double getFluxArrowsize(void)
{
return flux_arrow_size;
}
void FitCanvasToWindow();
void FitLeafToCanvas(void);
public slots:
void about();
void gpl();
void TimeStepWrap();
void togglePaused();
void setFluxArrowSize(int size);
void RestartSim(void);
void toggleShowCellCenters(void);
void toggleShowNodes(void);
void toggleShowBorderCells(void);
void toggleShowFluxes(void);
void toggleNodeNumbers(void);
void toggleCellNumbers(void);
void toggleCellAxes(void);
void toggleCellStrain(void);
void toggleShowWalls(void);
void toggleShowApoplasts(void);
void toggleDynCells(void);
void toggleMovieFrames(void);
void toggleLeafBoundary(void);
void toggleHideCells(void);
void print();
void startSimulation(void);
void stopSimulation(void);
void RefreshInfoBar(void);
void EnterRotationMode(void)
{
UserMessage("Rotation mode. Click mouse to exit.");
if (editor) {
editor->rot_angle = 0. ;
// Exit rotation mode if mouse is clicked
connect(editor, SIGNAL(MousePressed()), this, SLOT(ExitRotationMode()));
editor->setMouseTracking(true);
}
}
void ExitRotationMode(void)
{
UserMessage("Exited rotation mode.",2000);
options->setItemChecked(rotation_mode_id, false);
if (editor)
disconnect(editor, SIGNAL(MousePressed()), this, SLOT(ExitRotationMode()));
editor->setMouseTracking(false);
}
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 exportCellData();
void saveStateXML();
void snapshot();
void savePars();
void readPars();
void clear();
void init();
virtual void CutSAM() { MainBase::CutSAM(); Refresh();}
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;
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;
static const QString caption_with_file;
InfoBar *infobar;
};
#endif
/* finis*/
|