COPASI API  4.16.103
CLayout.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 CLAYOUT_H_
16 #define CLAYOUT_H_
17 
18 #include <string>
19 
21 
22 #include "CLBase.h"
23 #include "CLGlyphs.h"
24 #include "CLReactionGlyph.h"
25 
27 
28 class Layout;
29 
30 /**
31  * This class describes a reaction network layout. Its structure
32  * is exactly corresponding to the sbml layout extension
33  */
34 class CLayout : public CLBase, public CCopasiContainer
35 {
36 protected:
37 
38  std::string mKey;
39 
41 
48 
49 public:
50 
51  CLayout(const std::string & name = "Layout",
52  const CCopasiContainer * pParent = NULL);
53 
54  CLayout(const CLayout & src,
55  const CCopasiContainer * pParent = NULL);
56 
57  /**
58  * constructor from libsbml object.
59  * Does not read the whole libsbml tree. Additional
60  * work is done in SBMLDocumentLoader
61  */
62  CLayout(const Layout & sbml,
63  std::map<std::string, std::string> & layoutmap,
64  const CCopasiContainer * pParent = NULL);
65 
66  ~CLayout();
67 
68  /**
69  * Retrieves the key of the layout
70  */
71  virtual const std::string & getKey() const
72  {return mKey;};
73 
74  virtual void moveBy(const CLPoint &p);
75 
76  const CLDimensions & getDimensions() const {return mDimensions;};
77  void setDimensions(const CLDimensions & d) {mDimensions = d;};
78 
79  //*******************
80 
82  {return mvCompartments;};
83 
85  {return mvCompartments;};
86 
87  /**
88  * add Glyph to layout. The layout takes ownership of the glyph.
89  */
91 
92  //*******************
93 
95  {return mvMetabs;};
96 
98  {return mvMetabs;};
99 
100  /**
101  * add Glyph to layout. The layout takes ownership of the glyph.
102  */
103  void addMetaboliteGlyph(CLMetabGlyph * glyph);
104 
105  //*******************
106 
108  {return mvReactions;};
109 
111  {return mvReactions;};
112 
113  /**
114  * add Glyph to layout. The layout takes ownership of the glyph.
115  */
116  void addReactionGlyph(CLReactionGlyph * glyph);
117 
118  //*******************
119 
121  {return mvLabels;};
122 
124  {return mvLabels;};
125 
126  /**
127  * add Glyph to layout. The layout takes ownership of the glyph.
128  */
129  void addTextGlyph(CLTextGlyph * glyph);
130 
131  //*******************
132 
134  {return mvGraphicalObjects;};
135 
137  {return mvGraphicalObjects;};
138 
139  /**
140  * add Glyph to layout. The layout takes ownership of the glyph.
141  */
142  void addGeneralGlyph(CLGeneralGlyph * glyph);
143 
144  //*******************
145 
146  /**
147  * Returns a const reference to the list of local render information objects.
148  */
150  {return this->mvLocalRenderInformationObjects;};
151 
152  /**
153  * Returns a reference to the list of local render information objects.
154  */
156  {return this->mvLocalRenderInformationObjects;};
157 
158  /**
159  * Returns a const pointer to the local render information with the given index or NULL
160  * if the index is invalid.
161  */
162  const CLLocalRenderInformation* getRenderInformation(size_t index) const;
163 
164  /**
165  * Returns a pointer to the local render information with the given index or NULL
166  * if the index is invalid.
167  */
169 
170  /**
171  * add local render information to layout. The layout takes ownership of the object.
172  */
174 
175  /**
176  * This methods calculates the bounding box of the layout.
177  * It traverses all layout objects and looks for the minimal and maximal x
178  * and y values that occur in the layout.
179  * These values are returned in the form of a bounding box where the minimal
180  * values are stored in the position and the maxima are given as the minimal
181  * values plus the corresponding dimension.
182  */
184 
185  /**
186  * Calculates the Bounding Box, moves the layout to the origin and assigns it to the layout.
187  */
189 
190  virtual void scale(const double & scaleFactor) {this->mDimensions.scale(scaleFactor);}
191  /**
192  * insert operator
193  */
194  friend std::ostream & operator<<(std::ostream &os, const CLayout & g);
195  void print(std::ostream * ostream) const;
196 
197  void exportToDotFile(std::ostream & os) const;
198 
199  /**
200  * This method writes the information of the copasi layout object into the
201  * corresponding sbml object
202  */
203  void exportToSBML(Layout * layout, const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
204  std::map<std::string, const SBase*>& sbmlIDs
205  , const std::map<std::string, std::string>& globalKeyToIdMap
206  ) const;
207 
208 protected:
209  void writeDotNode(std::ostream & os, const std::string & id,
210  const std::string & label,
211  int t = 0) const;
212 
213  void writeDotEdge(std::ostream & os, const std::string & id1,
214  const std::string & id2,
215  int t = 0) const;
216 };
217 
218 #endif
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
void addReactionGlyph(CLReactionGlyph *glyph)
Definition: CLayout.cpp:251
CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs()
Definition: CLayout.h:136
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
Definition: CLayout.h:120
void writeDotEdge(std::ostream &os, const std::string &id1, const std::string &id2, int t=0) const
Definition: CLayout.cpp:380
CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs()
Definition: CLayout.h:110
void addGeneralGlyph(CLGeneralGlyph *glyph)
Definition: CLayout.cpp:263
void addLocalRenderInformation(CLLocalRenderInformation *pRenderInfo)
Definition: CLayout.cpp:646
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
CLayout(const std::string &name="Layout", const CCopasiContainer *pParent=NULL)
Definition: CLayout.cpp:38
void setDimensions(const CLDimensions &d)
Definition: CLayout.h:77
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs()
Definition: CLayout.h:97
const CLLocalRenderInformation * getRenderInformation(size_t index) const
Definition: CLayout.cpp:658
void addMetaboliteGlyph(CLMetabGlyph *glyph)
Definition: CLayout.cpp:245
CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects()
Definition: CLayout.h:155
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
CCopasiVector< CLTextGlyph > & getListOfTextGlyphs()
Definition: CLayout.h:123
void addTextGlyph(CLTextGlyph *glyph)
Definition: CLayout.cpp:257
void print(std::ostream *ostream) const
Definition: CLayout.cpp:328
friend std::ostream & operator<<(std::ostream &os, const CLayout &g)
Definition: CLayout.cpp:269
~CLayout()
Definition: CLayout.cpp:234
Definition: CLBase.h:54
CLDimensions mDimensions
Definition: CLayout.h:40
void writeDotNode(std::ostream &os, const std::string &id, const std::string &label, int t=0) const
Definition: CLayout.cpp:368
void calculateAndAssignBounds()
Definition: CLayout.cpp:955
CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs()
Definition: CLayout.h:84
Definition: CLBase.h:33
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
CLBoundingBox calculateBoundingBox() const
Definition: CLayout.cpp:684
virtual const std::string & getKey() const
Definition: CLayout.h:71
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
void addCompartmentGlyph(CLCompartmentGlyph *glyph)
Definition: CLayout.cpp:239
std::string mKey
Definition: CLayout.h:38
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
virtual void moveBy(const CLPoint &p)
Definition: CLayout.cpp:909
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
void exportToDotFile(std::ostream &os) const
Definition: CLayout.cpp:331
void scale(const double &scaleFactor)
Definition: CLBase.h:223
void exportToSBML(Layout *layout, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, const std::map< std::string, std::string > &globalKeyToIdMap) const
Definition: CLayout.cpp:392
virtual void scale(const double &scaleFactor)
Definition: CLayout.h:190
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
const CLDimensions & getDimensions() const
Definition: CLayout.h:76