diff --git a/src/cell.h b/src/cell.h --- a/src/cell.h +++ b/src/cell.h @@ -45,161 +45,153 @@ class Cell : public CellBase { - - Q_OBJECT - friend class Mesh; - friend class FigureEditor; + + Q_OBJECT + friend class Mesh; + friend class FigureEditor; + + public: + Cell(double x, double y, double z = 0.); + Cell(void); + Cell(const Cell &src); + Cell operator=(const Cell &src); + bool Cmp(Cell*) const; + bool Eq(Cell*) const; + + inline bool IndexEquals(int i) { return i == index; } + + static void SetMagnification(const double &magn) { + factor=magn; + } + static Vector Offset(void) { + Vector offs; + offs.x=offset[0]; + offs.y=offset[1]; + return offs; + } -public: - Cell(double x, double y, double z = 0.); - Cell(void); - Cell(const Cell &src); - Cell operator=(const Cell &src); - bool Cmp(Cell*) const; - bool Eq(Cell*) const; + static void Translate(const double &tx,const double &ty) { + offset[0]+=tx; + offset[1]+=ty; + } + + inline static double Factor(void) { + return factor; + } + static void setOffset(double ox, double oy) { + offset[0]=ox; + offset[1]=oy; + } + static double Magnification(void) { + return factor; + } + + static double Scale(const double scale) { + factor*=scale; + return factor; + } + + void DivideOverAxis(Vector axis); // divide cell over axis + + // divide over the line (if line and cell intersect) + bool DivideOverGivenLine(const Vector v1, const Vector v2, bool wall_fixed = false, NodeSet *node_set = 0); + + void Divide(void) { // Divide cell over short axis + + Vector long_axis; + Length(&long_axis); + DivideOverAxis(long_axis.Perp2D()); + } - inline bool IndexEquals(int i) { return i == index; } - - static void SetMagnification(const double &magn) { - factor=magn; - } - static Vector Offset(void) { - Vector offs; - offs.x=offset[0]; - offs.y=offset[1]; - return offs; - } - - static void Translate(const double &tx,const double &ty) { - offset[0]+=tx; - offset[1]+=ty; - } - - inline static double Factor(void) { - return factor; - } - static void setOffset(double ox, double oy) { - offset[0]=ox; - offset[1]=oy; - } - static double Magnification(void) { - return factor; - } - - static double Scale(const double scale) { - factor*=scale; - return factor; - } - - void DivideOverAxis(Vector axis); // divide cell over axis - bool DivideOverGivenLine(const Vector v1, const Vector v2, bool wall_fixed = false, NodeSet *node_set = 0); // divide over the line (if line and cell intersect) - - void Divide(void) { // Divide cell over short axis - - Vector long_axis; - Length(&long_axis); - DivideOverAxis(long_axis.Perp2D()); - - } - - //void CheckForGFDrivenDivision(void); - inline int NNodes(void) const { return nodes.size(); } - - void Move(Vector T); - void Move(double dx, double dy, double dz=0) { - Move( Vector (dx, dy, dz) ); - } - - double Displace(double dx, double dy, double dh); - void Displace(void); - double Energy(void) const; - bool SelfIntersect(void); - bool MoveSelfIntersectsP(Node *nid, Vector new_pos); - bool IntersectsWithLineP(const Vector v1, const Vector v2); + //void CheckForGFDrivenDivision(void); + inline int NNodes(void) const { return nodes.size(); } + + void Move(Vector T); + void Move(double dx, double dy, double dz=0) { + Move( Vector (dx, dy, dz) ); + } + + double Displace(double dx, double dy, double dh); + void Displace(void); + double Energy(void) const; + bool SelfIntersect(void); + bool MoveSelfIntersectsP(Node *nid, Vector new_pos); + bool IntersectsWithLineP(const Vector v1, const Vector v2); + + void XMLAdd(xmlNodePtr cells_node) const; + + void ConstructWalls(void); + void Flux(double *flux, double *D); + + void OnClick(QMouseEvent *e); + inline Mesh& getMesh(void) const { return *m; } + double MeanArea(void); + + void Apoptose(void); // Cell kills itself + list::iterator RemoveWall( Wall *w ); + void AddWall( Wall *w ); + + void Draw(QGraphicsScene *c, QString tooltip = QString::Null()); - void XMLAdd(xmlNodePtr cells_node) const; - - void ConstructWalls(void); - void Flux(double *flux, double *D); - - /*! \brief Method called if a cell is clicked. - - Define this in the end-user code (e.g. meinhardt.cpp). - - */ - void OnClick(QMouseEvent *e); - inline Mesh& getMesh(void) const { return *m; } - double MeanArea(void); - - void Apoptose(void); // Cell kills itself - list::iterator RemoveWall( Wall *w ); - void AddWall( Wall *w ); + // Draw a text in the cell's center + void DrawText(QGraphicsScene *c, const QString &text) const; + void DrawIndex(QGraphicsScene *c) const; + void DrawCenter(QGraphicsScene *c) const; + void DrawNodes(QGraphicsScene *c) const; + + void DrawAxis(QGraphicsScene *c) const; + void DrawStrain(QGraphicsScene *c) const; + void DrawFluxes(QGraphicsScene *c, double arrowsize = 1.); + void DrawWalls(QGraphicsScene *c) const; + void DrawValence(QGraphicsScene *c) const; + void EmitValues(double t); - void Draw(QGraphicsScene *c, QString tooltip = QString::Null()); - - // Draw a text in the cell's center - void DrawText(QGraphicsScene *c, const QString &text) const; - void DrawIndex(QGraphicsScene *c) const; - void DrawCenter(QGraphicsScene *c) const; - void DrawNodes(QGraphicsScene *c) const; - - void DrawAxis(QGraphicsScene *c) const; - void DrawStrain(QGraphicsScene *c) const; - void DrawFluxes(QGraphicsScene *c, double arrowsize = 1.); - void DrawWalls(QGraphicsScene *c) const; - void DrawValence(QGraphicsScene *c) const; - void EmitValues(double t); - -signals: - void ChemMonValue(double t, double *x); - - -protected: - void XMLAddCore(xmlNodePtr xmlcell) const; - int XMLRead(xmlNode *cur); - void DivideWalls(ItList new_node_locations, const Vector from, const Vector to, bool wall_fixed = false, NodeSet *node_set = 0); + signals: + void ChemMonValue(double t, double *x); + + protected: + void XMLAddCore(xmlNodePtr xmlcell) const; + int XMLRead(xmlNode *cur); + void DivideWalls(ItList new_node_locations, const Vector from, const Vector to, bool wall_fixed = false, NodeSet *node_set = 0); -private: + private: - static QPen *cell_outline_pen; - static double offset[3]; - static double factor; - Mesh *m; - void ConstructConnections(void); - void SetWallLengths(void); - + static QPen *cell_outline_pen; + static double offset[3]; + static double factor; + Mesh *m; + void ConstructConnections(void); + void SetWallLengths(void); }; // Boundarypolygon is a special cell; will not increase ncells // and will not be part of Mesh::cells class BoundaryPolygon : public Cell { - -public: - BoundaryPolygon(void) : Cell() { - NCells()--; - index=-1; - } - - BoundaryPolygon(double x,double y,double z=0) : Cell (x,y,z) { - NCells()--; - index=-1; - } - - BoundaryPolygon &operator=(Cell &src) { - Cell::operator=(src); - index=-1; - return *this; - } - virtual void Draw(QGraphicsScene *c, QString tooltip = QString::Null()); - - virtual void XMLAdd(xmlNodePtr parent_node) const; - - virtual bool BoundaryPolP(void) const { return true; } + + public: + BoundaryPolygon(void) : Cell() { + NCells()--; + index=-1; + } + BoundaryPolygon(double x,double y,double z=0) : Cell (x,y,z) { + NCells()--; + index=-1; + } + BoundaryPolygon &operator=(Cell &src) { + Cell::operator=(src); + index=-1; + return *this; + } + virtual void Draw(QGraphicsScene *c, QString tooltip = QString::Null()); + + virtual void XMLAdd(xmlNodePtr parent_node) const; + + virtual bool BoundaryPolP(void) const { return true; } }; - +#endif -#endif +/* finis */