COPASI API  4.16.103
CLGraphicalObject.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef CLGO_H_
16 #define CLGO_H_
17 
18 #include <string>
20 
21 #include "CLBase.h"
22 
23 class GraphicalObject;
24 
25 /**
26  * This is the base class for the layout objects in copasi.
27  * It is a CCopasiObject. It also has a key (which is used if one
28  * layout object refers to another one)
29  * It provides the mechanism for refering to a copasi model
30  * object by key. This needs to be specialized in the derived
31  * classes
32  */
34 {
35 protected:
36 
37  /**
38  * The key of the layout object itself
39  */
40  std::string mKey;
41 
42  /**
43  * The key of an object of the COPASI model. This is not used
44  * in this base class. It is provided as a service for the
45  * derived classes
46  */
47  std::string mModelObjectKey;
48 
49  // attribute to store the object role
50  std::string mObjectRole;
51 
53 
54 public:
55 
56  CLGraphicalObject(const std::string & name = "GraphicalObject",
57  const CCopasiContainer * pParent = NULL);
58 
60  const CCopasiContainer * pParent = NULL);
61 
62  /**
63  * constructor from libsbml object
64  */
65  CLGraphicalObject(const GraphicalObject & sbml,
66  std::map<std::string, std::string> & layoutmap,
67  const CCopasiContainer * pParent = NULL);
68 
70 
71  /**
72  * The assignment operator does not copy the key.
73  */
75 
76  /**
77  * Retrieves the key of the layout object
78  */
79  virtual const std::string & getKey() const
80  {return mKey;};
81 
82  virtual CLGraphicalObject* clone() const {return new CLGraphicalObject(*this, NULL);};
83 
84  virtual void moveBy(const CLPoint &p);
85 
86  const CLBoundingBox & getBoundingBox() const {return mBBox;};
88  void setBoundingBox(const CLBoundingBox & bb) {mBBox = bb;};
89 
90  const CLPoint & getPosition() const {return mBBox.getPosition();};
91  void setPosition(const CLPoint & p) {mBBox.setPosition(p);};
92 
93  const C_FLOAT64 & getX() const {return mBBox.getPosition().getX();};
94  void setX(const C_FLOAT64 & x) {mBBox.getPosition().setX(x);};
95 
96  const C_FLOAT64 & getY() const {return mBBox.getPosition().getY();};
97  void setY(const C_FLOAT64 & y) {mBBox.getPosition().setY(y);};
98 
99  const CLDimensions & getDimensions() const {return mBBox.getDimensions();};
101 
102  const C_FLOAT64 & getWidth() const {return mBBox.getDimensions().getWidth();};
103  void setWidth(const C_FLOAT64 & w) {mBBox.getDimensions().setWidth(w);};
104 
105  const C_FLOAT64 & getHeight() const {return mBBox.getDimensions().getHeight();};
107 
108  const std::string & getModelObjectKey() const {return mModelObjectKey;};
109 
110  void setModelObjectKey(const std::string & k) {mModelObjectKey = k;};
111 
112  CCopasiObject * getModelObject() const;
113 
114  /**
115  * if the graphical object refers to a model object this method will return the
116  * name of that object.
117  */
118  std::string getModelObjectName() const;
119 
120  /**
121  * if the graphical object refers to a model object this method will return the
122  * display name of that object.
123  */
124  std::string getModelObjectDisplayName(bool regular = true, bool richtext = false) const;
125 
126  /**
127  * This method writes the information of the copasi layout object into the
128  * corresponding sbml object
129  */
130  virtual void exportToSBML(GraphicalObject * sbmlobject,
131  const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
132  std::map<std::string, const SBase*>& sbmlIDs) const;
133 
134  /**
135  * Method to set the role of a graphical object.
136  */
137  void setObjectRole(const std::string& role);
138 
139  /**
140  * Method to read the object role of an object.
141  */
142  const std::string& getObjectRole() const;
143 
144  /**
145  * insert operator
146  */
147  friend std::ostream & operator<<(std::ostream &os, const CLGraphicalObject & g);
148  void print(std::ostream * ostream) const;
149 
150  /**
151  * This method is used for the export of several layout elements.
152  * Layout elements can reference model elements, but when a referenced model element
153  * is deleted, the layout is not infomred about this yet, so we end up with dangling
154  * references.
155  * If the key belongs to an object in the same datamodel, true is returned, else false is returned.
156  */
157  bool hasValidModelReference() const;
158 };
159 
160 #endif
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
std::string mModelObjectKey
std::string getModelObjectDisplayName(bool regular=true, bool richtext=false) const
const CLBoundingBox & getBoundingBox() const
void setX(const C_FLOAT64 &x)
Definition: CLBase.h:91
void setPosition(const CLPoint &p)
Definition: CLBase.h:272
const C_FLOAT64 & getX() const
void setY(const C_FLOAT64 &y)
const std::string & getObjectRole() const
void setDimensions(const CLDimensions &d)
void setY(const C_FLOAT64 &y)
Definition: CLBase.h:92
const CLPoint & getPosition() const
CLBoundingBox & getBoundingBox()
virtual const std::string & getKey() const
void setModelObjectKey(const std::string &k)
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
void setHeight(const C_FLOAT64 &h)
Definition: CLBase.h:220
std::string mObjectRole
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
void setDimensions(const CLDimensions &d)
Definition: CLBase.h:273
Definition: CLBase.h:54
CLBoundingBox mBBox
const CLPoint & getPosition() const
Definition: CLBase.h:265
virtual void exportToSBML(GraphicalObject *sbmlobject, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLBase.h:33
std::string getModelObjectName() const
Header file of class CCopasiContainer.
void setPosition(const CLPoint &p)
CLGraphicalObject(const std::string &name="GraphicalObject", const CCopasiContainer *pParent=NULL)
const C_FLOAT64 & getWidth() const
void setHeight(const C_FLOAT64 &h)
const std::string & getModelObjectKey() const
CLGraphicalObject & operator=(const CLGraphicalObject &rhs)
void setBoundingBox(const CLBoundingBox &bb)
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
const C_FLOAT64 & getY() const
CCopasiObject * getModelObject() const
void setObjectRole(const std::string &role)
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
#define C_FLOAT64
Definition: copasi.h:92
virtual void moveBy(const CLPoint &p)
void print(std::ostream *ostream) const
friend std::ostream & operator<<(std::ostream &os, const CLGraphicalObject &g)
bool hasValidModelReference() const
const CLDimensions & getDimensions() const
void setWidth(const C_FLOAT64 &w)
const C_FLOAT64 & getHeight() const
void setX(const C_FLOAT64 &x)
void setWidth(const C_FLOAT64 &w)
Definition: CLBase.h:219
virtual CLGraphicalObject * clone() const