COPASI API  4.16.103
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CLayout Class Reference

#include <CLayout.h>

Inheritance diagram for CLayout:
Inheritance graph
[legend]
Collaboration diagram for CLayout:
Collaboration graph
[legend]

Public Member Functions

void addCompartmentGlyph (CLCompartmentGlyph *glyph)
 
void addGeneralGlyph (CLGeneralGlyph *glyph)
 
void addLocalRenderInformation (CLLocalRenderInformation *pRenderInfo)
 
void addMetaboliteGlyph (CLMetabGlyph *glyph)
 
void addReactionGlyph (CLReactionGlyph *glyph)
 
void addTextGlyph (CLTextGlyph *glyph)
 
void calculateAndAssignBounds ()
 
CLBoundingBox calculateBoundingBox () const
 
 CLayout (const std::string &name="Layout", const CCopasiContainer *pParent=NULL)
 
 CLayout (const CLayout &src, const CCopasiContainer *pParent=NULL)
 
 CLayout (const Layout &sbml, std::map< std::string, std::string > &layoutmap, const CCopasiContainer *pParent=NULL)
 
void exportToDotFile (std::ostream &os) const
 
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
 
const CLDimensionsgetDimensions () const
 
virtual const std::string & getKey () const
 
const CCopasiVector
< CLCompartmentGlyph > & 
getListOfCompartmentGlyphs () const
 
CCopasiVector
< CLCompartmentGlyph > & 
getListOfCompartmentGlyphs ()
 
const CCopasiVector
< CLGeneralGlyph > & 
getListOfGeneralGlyphs () const
 
CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs ()
 
const CCopasiVector
< CLLocalRenderInformation > & 
getListOfLocalRenderInformationObjects () const
 
CCopasiVector
< CLLocalRenderInformation > & 
getListOfLocalRenderInformationObjects ()
 
const CCopasiVector
< CLMetabGlyph > & 
getListOfMetaboliteGlyphs () const
 
CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs ()
 
const CCopasiVector
< CLReactionGlyph > & 
getListOfReactionGlyphs () const
 
CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs ()
 
const CCopasiVector
< CLTextGlyph > & 
getListOfTextGlyphs () const
 
CCopasiVector< CLTextGlyph > & getListOfTextGlyphs ()
 
const CLLocalRenderInformationgetRenderInformation (size_t index) const
 
CLLocalRenderInformationgetRenderInformation (size_t index)
 
virtual void moveBy (const CLPoint &p)
 
void print (std::ostream *ostream) const
 
virtual void scale (const double &scaleFactor)
 
void setDimensions (const CLDimensions &d)
 
 ~CLayout ()
 
- Public Member Functions inherited from CLBase
 CLBase ()
 
 CLBase (const CLBase &b)
 
 CLBase (const SBase &)
 
const std::string & getTag () const
 
bool hasTag () const
 
void setTag (const std::string &tag)
 
virtual ~CLBase ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Protected Member Functions

void writeDotEdge (std::ostream &os, const std::string &id1, const std::string &id2, int t=0) const
 
void writeDotNode (std::ostream &os, const std::string &id, const std::string &label, int t=0) const
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 

Protected Attributes

CLDimensions mDimensions
 
std::string mKey
 
CCopasiVector< CLCompartmentGlyphmvCompartments
 
CCopasiVector< CLGeneralGlyphmvGraphicalObjects
 
CCopasiVector< CLTextGlyphmvLabels
 
CCopasiVector
< CLLocalRenderInformation
mvLocalRenderInformationObjects
 
CCopasiVector< CLMetabGlyphmvMetabs
 
CCopasiVector< CLReactionGlyphmvReactions
 
- Protected Attributes inherited from CLBase
std::string mTag
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 

Friends

std::ostream & operator<< (std::ostream &os, const CLayout &g)
 

Additional Inherited Members

- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

This class describes a reaction network layout. Its structure is exactly corresponding to the sbml layout extension

Definition at line 34 of file CLayout.h.

Constructor & Destructor Documentation

CLayout::CLayout ( const std::string &  name = "Layout",
const CCopasiContainer pParent = NULL 
)

Definition at line 38 of file CLayout.cpp.

40  : CLBase(),
41  CCopasiContainer(name, pParent, "Layout"),
42  mKey(CCopasiRootContainer::getKeyFactory()->add("Layout", this)),
43  mDimensions(),
44  mvCompartments("ListOfCompartmentGlyphs", this),
45  mvMetabs("ListOfMetaboliteGlyphs", this),
46  mvReactions("ListOfReactionGlyphs", this),
47  mvLabels("ListOfTextGlyphs", this),
48  mvGraphicalObjects("ListOfGraphicalObjects", this)
49  , mvLocalRenderInformationObjects("ListOfLocalRenderInformationObjects", this)
50 {}
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
CLBase()
Definition: CLBase.h:36
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
CLDimensions mDimensions
Definition: CLayout.h:40
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
std::string mKey
Definition: CLayout.h:38
static CKeyFactory * getKeyFactory()
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
CLayout::CLayout ( const CLayout src,
const CCopasiContainer pParent = NULL 
)

Definition at line 52 of file CLayout.cpp.

References CCopasiVector< T >::add(), CCopasiVector< T >::begin(), CCopasiVector< T >::end(), CLTextGlyph::getGraphicalObjectKey(), CLGraphicalObject::getKey(), CCopasiObject::getKey(), CLReactionGlyph::getListOfMetabReferenceGlyphs(), CLGeneralGlyph::getListOfReferenceGlyphs(), CLGeneralGlyph::getListOfSubglyphs(), CLMetabReferenceGlyph::getMetabGlyphKey(), CLReferenceGlyph::getTargetGlyphKey(), mvCompartments, mvGraphicalObjects, mvLabels, mvMetabs, mvReactions, CLTextGlyph::setGraphicalObjectKey(), CLMetabReferenceGlyph::setMetabGlyphKey(), CLReferenceGlyph::setTargetGlyphKey(), and CCopasiVector< T >::size().

54  : CLBase(src),
55  CCopasiContainer(src, pParent),
56  mKey(CCopasiRootContainer::getKeyFactory()->add("Layout", this)),
58  mvCompartments("ListOfCompartmentGlyphs", this),
59  mvMetabs("ListOfMetaboliteGlyphs", this),
60  mvReactions("ListOfReactionGlyphs", this),
61  mvLabels("ListOfTextGlyphs", this),
62  mvGraphicalObjects("ListOfGraphicalObjects", this)
64 {
65  //TODO references from one glyph to another have to be reconstructed after
66  // copying. This applies to Labels and species reference glyphs
67 
68  std::map<std::string, std::string> forward;
69  std::map<std::string, std::string> reverse;
70 
72 
73  for (; compIt != src.mvCompartments.end(); ++compIt)
74  {
75  CLCompartmentGlyph *comp = new CLCompartmentGlyph(*(*compIt));
76  mvCompartments.add(comp, true);
77  forward[(*compIt)->getKey()] = comp->getKey();
78  reverse[comp->getKey()] = (*compIt)->getKey();
79  }
80 
82 
83  for (; metabIt != src.mvMetabs.end(); ++metabIt)
84  {
85  CLMetabGlyph *metab = new CLMetabGlyph(*(*metabIt));
86  mvMetabs.add(metab, true);
87  forward[(*metabIt)->getKey()] = metab->getKey();
88  reverse[metab->getKey()] = (*metabIt)->getKey();
89  }
90 
92 
93  for (; reactIt != src.mvReactions.end(); ++reactIt)
94  {
95  CLReactionGlyph *r = new CLReactionGlyph(*(*reactIt));
96  mvReactions.add(r, true);
97  forward[(*reactIt)->getKey()] = r->getKey();
98  reverse[r->getKey()] = (*reactIt)->getKey();
99 
100  for (size_t i = 0; i < r->getListOfMetabReferenceGlyphs().size(); ++i)
101  {
102  forward[(*reactIt)->getListOfMetabReferenceGlyphs()[i]->getKey()]
104  reverse[r->getListOfMetabReferenceGlyphs()[i]->getKey()]
105  = (*reactIt)->getListOfMetabReferenceGlyphs()[i]->getKey();
106  }
107  }
108 
110 
111  for (; textIt != src.mvLabels.end(); ++textIt)
112  {
113  CLTextGlyph *text = new CLTextGlyph(*(*textIt));
114  mvLabels.add(text, true);
115  forward[(*textIt)->getKey()] = text->getKey();
116  reverse[text->getKey()] = (*textIt)->getKey();
117  }
118 
120 
121  for (; generalIt != src.mvGraphicalObjects.end(); ++generalIt)
122  {
123  CLGeneralGlyph *general = new CLGeneralGlyph(*(*generalIt));
124  mvGraphicalObjects.add(general, true);
125  forward[(*generalIt)->getKey()] = general->getKey();
126  reverse[general->getKey()] = (*generalIt)->getKey();
127 
128  for (size_t i = 0; i < general->getListOfReferenceGlyphs().size(); ++i)
129  {
130  forward[(*generalIt)->getListOfReferenceGlyphs()[i]->getKey()]
131  = general->getListOfReferenceGlyphs()[i]->getKey();
132  reverse[general->getListOfReferenceGlyphs()[i]->getKey()]
133  = (*generalIt)->getListOfReferenceGlyphs()[i]->getKey();
134  }
135 
136  for (size_t i = 0; i < general->getListOfSubglyphs().size(); ++i)
137  {
138  forward[(*generalIt)->getListOfSubglyphs()[i]->getKey()]
139  = general->getListOfSubglyphs()[i]->getKey();
140  reverse[general->getListOfSubglyphs()[i]->getKey()]
141  = (*generalIt)->getListOfSubglyphs()[i]->getKey();
142  }
143  }
144 
145  {
146 
147  // by now we have collected all keys, now we need to replace them
148  std::map<std::string, std::string>::const_iterator constIt;
150 
151  for (; textIt != mvLabels.end(); ++textIt)
152  {
153  CLTextGlyph *text = *textIt;
154  const std::string& key = text->getGraphicalObjectKey();
155  constIt = forward.find(key);
156 
157  if (constIt == forward.end())
158  continue;
159 
160  text->setGraphicalObjectKey(constIt->second);
161  }
162 
164 
165  for (; reactIt != mvReactions.end(); ++reactIt)
166  {
167  CLReactionGlyph *r = *reactIt;
169 
170  for (; refIt != r->getListOfMetabReferenceGlyphs().end(); ++refIt)
171  {
172  CLMetabReferenceGlyph* current = *refIt;
173  const std::string& key = current->getMetabGlyphKey();
174  constIt = forward.find(key);
175 
176  if (constIt == forward.end())
177  continue;
178 
179  current->setMetabGlyphKey(constIt->second);
180  }
181  }
182 
184 
185  for (; generalIt != mvGraphicalObjects.end(); ++generalIt)
186  {
187  CLGeneralGlyph *g = *generalIt;
189 
190  for (; refIt != g->getListOfReferenceGlyphs().end(); ++refIt)
191  {
192  CLReferenceGlyph* current = *refIt;
193  const std::string& key = current->getTargetGlyphKey();
194  constIt = forward.find(key);
195 
196  if (constIt == forward.end())
197  continue;
198 
199  current->setTargetGlyphKey(constIt->second);
200  }
201 
202  //CCopasiVector<CLGraphicalObject>::iterator refIt = g->getListOfSubglyphs().begin();
203  //for(;refIt != g->getListOfReferenceGlyphs().end(); ++refIt)
204  //{
205  // CLGraphicalObject* current = *refIt;
206  // const std::string& key = current->getTargetGlyphKey();
207  // constIt = forward.find(key);
208  // if (constIt == forward.end())
209  // continue;
210  // current->setTargetGlyphKey(constIt->second);
211  //}
212  }
213  }
214 }
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
CLBase()
Definition: CLBase.h:36
virtual size_t size() const
iterator begin()
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
const CCopasiVector< CLGraphicalObject > & getListOfSubglyphs() const
void setTargetGlyphKey(const std::string &k)
const std::string & getMetabGlyphKey() const
virtual const std::string & getKey() const
virtual const std::string & getKey() const
iterator end()
CLDimensions mDimensions
Definition: CLayout.h:40
virtual bool add(const CType &src)
const CCopasiVector< CLReferenceGlyph > & getListOfReferenceGlyphs() const
void setGraphicalObjectKey(const std::string &k)
Definition: CLGlyphs.cpp:338
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
std::string mKey
Definition: CLayout.h:38
void setMetabGlyphKey(const std::string &k)
static CKeyFactory * getKeyFactory()
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
const std::string & getTargetGlyphKey() const
const std::string & getGraphicalObjectKey() const
Definition: CLGlyphs.h:163
CLayout::CLayout ( const Layout &  sbml,
std::map< std::string, std::string > &  layoutmap,
const CCopasiContainer pParent = NULL 
)

constructor from libsbml object. Does not read the whole libsbml tree. Additional work is done in SBMLDocumentLoader

Definition at line 216 of file CLayout.cpp.

References mKey.

219  : CLBase(sbml),
220  CCopasiContainer(sbml.getId(), pParent, "Layout"),
221  mKey(CCopasiRootContainer::getKeyFactory()->add("Layout", this)),
222  mDimensions(*sbml.getDimensions()),
223  mvCompartments("ListOfCompartmentGlyphs", this),
224  mvMetabs("ListOfMetaboliteGlyphs", this),
225  mvReactions("ListOfReactionGlyphs", this),
226  mvLabels("ListOfTextGlyphs", this),
227  mvGraphicalObjects("ListOfGraphicalObjects", this)
228  , mvLocalRenderInformationObjects("ListOfLocalRenderInformationObjects", this)
229 {
230  //add the copasi key to the map
231  layoutmap[sbml.getId()] = mKey;
232 }
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
CLBase()
Definition: CLBase.h:36
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
CLDimensions mDimensions
Definition: CLayout.h:40
std::string add(const std::string &prefix, CCopasiObject *pObject)
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
std::string mKey
Definition: CLayout.h:38
static CKeyFactory * getKeyFactory()
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
CLayout::~CLayout ( )

Definition at line 234 of file CLayout.cpp.

References CCopasiRootContainer::getKeyFactory(), mKey, and CKeyFactory::remove().

235 {
237 }
bool remove(const std::string &key)
std::string mKey
Definition: CLayout.h:38
static CKeyFactory * getKeyFactory()

Member Function Documentation

void CLayout::addCompartmentGlyph ( CLCompartmentGlyph glyph)

add Glyph to layout. The layout takes ownership of the glyph.

Definition at line 239 of file CLayout.cpp.

References CCopasiVector< T >::add(), and mvCompartments.

Referenced by SBMLDocumentLoader::createLayout(), CCopasiSpringLayout::createLayout(), test000097::createModel(), and CCopasiXMLParser::CompartmentGlyphElement::start().

240 {
241  if (glyph)
242  mvCompartments.add(glyph, true); //true means vector takes ownership
243 }
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
virtual bool add(const CType &src)
void CLayout::addGeneralGlyph ( CLGeneralGlyph glyph)

add Glyph to layout. The layout takes ownership of the glyph.

Definition at line 263 of file CLayout.cpp.

References CCopasiVector< T >::add(), and mvGraphicalObjects.

Referenced by SBMLDocumentLoader::createLayout(), CCopasiSpringLayout::createLayout(), and CCopasiXMLParser::AdditionalGOElement::start().

264 {
265  if (glyph)
266  mvGraphicalObjects.add(glyph, true); //true means vector takes ownership
267 }
virtual bool add(const CType &src)
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
void CLayout::addLocalRenderInformation ( CLLocalRenderInformation pRenderInfo)

add local render information to layout. The layout takes ownership of the object.

Definition at line 646 of file CLayout.cpp.

References CCopasiVector< T >::add(), and mvLocalRenderInformationObjects.

Referenced by SBMLDocumentLoader::createLayout(), and CCopasiXMLParser::LocalRenderInformationElement::start().

647 {
648  if (pRenderInfo)
649  {
650  this->mvLocalRenderInformationObjects.add(pRenderInfo, true); //true means vector takes ownership
651  }
652 }
virtual bool add(const CType &src)
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
void CLayout::addMetaboliteGlyph ( CLMetabGlyph glyph)

add Glyph to layout. The layout takes ownership of the glyph.

Definition at line 245 of file CLayout.cpp.

References CCopasiVector< T >::add(), and mvMetabs.

Referenced by SBMLDocumentLoader::createLayout(), CCopasiSpringLayout::createLayout(), and CCopasiXMLParser::MetaboliteGlyphElement::start().

246 {
247  if (glyph)
248  mvMetabs.add(glyph, true); //true means vector takes ownership
249 }
virtual bool add(const CType &src)
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
void CLayout::addReactionGlyph ( CLReactionGlyph glyph)

add Glyph to layout. The layout takes ownership of the glyph.

Definition at line 251 of file CLayout.cpp.

References CCopasiVector< T >::add(), and mvReactions.

Referenced by SBMLDocumentLoader::createLayout(), CCopasiSpringLayout::createLayout(), and CCopasiXMLParser::ReactionGlyphElement::start().

252 {
253  if (glyph)
254  mvReactions.add(glyph, true); //true means vector takes ownership
255 }
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
virtual bool add(const CType &src)
void CLayout::addTextGlyph ( CLTextGlyph glyph)

add Glyph to layout. The layout takes ownership of the glyph.

Definition at line 257 of file CLayout.cpp.

References CCopasiVector< T >::add(), and mvLabels.

Referenced by SBMLDocumentLoader::createLayout(), CCopasiSpringLayout::createLayout(), and CCopasiXMLParser::TextGlyphElement::start().

258 {
259  if (glyph)
260  mvLabels.add(glyph, true); //true means vector takes ownership
261 }
virtual bool add(const CType &src)
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
void CLayout::calculateAndAssignBounds ( )

Calculates the Bounding Box, moves the layout to the origin and assigns it to the layout.

Definition at line 955 of file CLayout.cpp.

References calculateBoundingBox(), CLBoundingBox::getDimensions(), CLBoundingBox::getPosition(), CLPoint::getX(), CLPoint::getY(), CLPoint::getZ(), moveBy(), and setDimensions().

Referenced by CCopasiSpringLayout::finalizeState().

956 {
958  // move into the origin
959  CLPoint differenceToOrigin(
960  -bb.getPosition().getX(),
961  -bb.getPosition().getY()
962  , -bb.getPosition().getZ()
963  );
964  moveBy(differenceToOrigin);
966 }
const C_FLOAT64 & getZ() const
Definition: CLBase.h:85
void setDimensions(const CLDimensions &d)
Definition: CLayout.h:77
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
Definition: CLBase.h:54
const CLPoint & getPosition() const
Definition: CLBase.h:265
CLBoundingBox calculateBoundingBox() const
Definition: CLayout.cpp:684
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
virtual void moveBy(const CLPoint &p)
Definition: CLayout.cpp:909
CLBoundingBox CLayout::calculateBoundingBox ( ) const

This methods calculates the bounding box of the layout. It traverses all layout objects and looks for the minimal and maximal x and y values that occur in the layout. These values are returned in the form of a bounding box where the minimal values are stored in the position and the maxima are given as the minimal values plus the corresponding dimension.

Definition at line 684 of file CLayout.cpp.

References CLCurve::calculateBoundingBox(), CLGraphicalObject::getBoundingBox(), CLGlyphWithCurve::getCurve(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), getListOfCompartmentGlyphs(), getListOfGeneralGlyphs(), getListOfMetaboliteGlyphs(), CLReactionGlyph::getListOfMetabReferenceGlyphs(), getListOfReactionGlyphs(), CLGeneralGlyph::getListOfReferenceGlyphs(), getListOfTextGlyphs(), CLCurve::getNumCurveSegments(), CLBoundingBox::getPosition(), CLDimensions::getWidth(), CLPoint::getX(), CLPoint::getY(), max, and CCopasiVector< T >::size().

Referenced by CQGLLayoutPainter::calculateAndAssignBounds(), calculateAndAssignBounds(), and CCopasiSpringLayout::createLayout().

685 {
686  double minX = std::numeric_limits<double>::max();
687  double minY = minX;
688  double maxX = -minX;
689  double maxY = -minX;
690 
691  const CLGraphicalObject* pObject = NULL;
692  const CLCurve* pCurve = NULL;
693  const CLBoundingBox* pBB;
694  const CLPoint* pP = NULL;
695  const CLDimensions* pDim;
696  size_t i, iMax = this->getListOfCompartmentGlyphs().size();
697  double x, y, x2, y2;
698 
699  for (i = 0; i < iMax; ++i)
700  {
701  pObject = this->getListOfCompartmentGlyphs()[i];
702  pBB = &pObject->getBoundingBox();
703  pP = &pBB->getPosition();
704  x = pP->getX();
705  y = pP->getY();
706  pDim = &pBB->getDimensions();
707  x2 = x + pDim->getWidth();
708  y2 = y + pDim->getHeight();
709  minX = (minX < x) ? minX : x;
710  minY = (minY < y) ? minY : y;
711  maxX = (maxX > x2) ? maxX : x2;
712  maxY = (maxY > y2) ? maxY : y2;
713  }
714 
715  iMax = this->getListOfMetaboliteGlyphs().size();
716 
717  for (i = 0; i < iMax; ++i)
718  {
719  pObject = this->getListOfMetaboliteGlyphs()[i];
720  pBB = &pObject->getBoundingBox();
721  pP = &pBB->getPosition();
722  x = pP->getX();
723  y = pP->getY();
724  pDim = &pBB->getDimensions();
725  x2 = x + pDim->getWidth();
726  y2 = y + pDim->getHeight();
727  minX = (minX < x) ? minX : x;
728  minY = (minY < y) ? minY : y;
729  maxX = (maxX > x2) ? maxX : x2;
730  maxY = (maxY > y2) ? maxY : y2;
731  }
732 
733  iMax = this->getListOfTextGlyphs().size();
734 
735  for (i = 0; i < iMax; ++i)
736  {
737  pObject = this->getListOfTextGlyphs()[i];
738  pBB = &pObject->getBoundingBox();
739  pP = &pBB->getPosition();
740  x = pP->getX();
741  y = pP->getY();
742  pDim = &pBB->getDimensions();
743  x2 = x + pDim->getWidth();
744  y2 = y + pDim->getHeight();
745  minX = (minX < x) ? minX : x;
746  minY = (minY < y) ? minY : y;
747  maxX = (maxX > x2) ? maxX : x2;
748  maxY = (maxY > y2) ? maxY : y2;
749  }
750 
751  size_t j, jMax;
752  const CLGeneralGlyph* pGG = NULL;
753  const CLReferenceGlyph* pRefG = NULL;
754  iMax = this->getListOfGeneralGlyphs().size();
755 
756  for (i = 0; i < iMax; ++i)
757  {
758  pGG = this->getListOfGeneralGlyphs()[i];
759 
760  if (pGG->getCurve().getNumCurveSegments() > 0)
761  {
762  pCurve = &pGG->getCurve();
763  CLBoundingBox bb = pCurve->calculateBoundingBox();
764  pP = &bb.getPosition();
765  x = pP->getX();
766  y = pP->getY();
767  pDim = &bb.getDimensions();
768  x2 = x + pDim->getWidth();
769  y2 = y + pDim->getHeight();
770  minX = (minX < x) ? minX : x;
771  minY = (minY < y) ? minY : y;
772  maxX = (maxX > x2) ? maxX : x2;
773  maxY = (maxY > y2) ? maxY : y2;
774  }
775  else
776  {
777  pBB = &pGG->getBoundingBox();
778  pP = &pBB->getPosition();
779  x = pP->getX();
780  y = pP->getY();
781  pDim = &pBB->getDimensions();
782  x2 = x + pDim->getWidth();
783  y2 = y + pDim->getHeight();
784  minX = (minX < x) ? minX : x;
785  minY = (minY < y) ? minY : y;
786  maxX = (maxX > x2) ? maxX : x2;
787  maxY = (maxY > y2) ? maxY : y2;
788  }
789 
790  jMax = pGG->getListOfReferenceGlyphs().size();
791 
792  for (j = 0; j < jMax; ++j)
793  {
794  pRefG = pGG->getListOfReferenceGlyphs()[j];
795 
796  if (pRefG->getCurve().getNumCurveSegments() > 0)
797  {
798  pCurve = &pRefG->getCurve();
799  CLBoundingBox bb = pCurve->calculateBoundingBox();
800  pP = &bb.getPosition();
801  x = pP->getX();
802  y = pP->getY();
803  pDim = &bb.getDimensions();
804  x2 = x + pDim->getWidth();
805  y2 = y + pDim->getHeight();
806  minX = (minX < x) ? minX : x;
807  minY = (minY < y) ? minY : y;
808  maxX = (maxX > x2) ? maxX : x2;
809  maxY = (maxY > y2) ? maxY : y2;
810  }
811  else
812  {
813  pBB = &pRefG->getBoundingBox();
814  pP = &pBB->getPosition();
815  x = pP->getX();
816  y = pP->getY();
817  pDim = &pBB->getDimensions();
818  x2 = x + pDim->getWidth();
819  y2 = y + pDim->getHeight();
820  minX = (minX < x) ? minX : x;
821  minY = (minY < y) ? minY : y;
822  maxX = (maxX > x2) ? maxX : x2;
823  maxY = (maxY > y2) ? maxY : y2;
824  }
825  }
826  }
827 
828  const CLReactionGlyph* pRG = NULL;
829 
830  const CLMetabReferenceGlyph* pSRG = NULL;
831 
832  iMax = this->getListOfReactionGlyphs().size();
833 
834  for (i = 0; i < iMax; ++i)
835  {
836  pRG = this->getListOfReactionGlyphs()[i];
837 
838  if (pRG->getCurve().getNumCurveSegments() > 0)
839  {
840  pCurve = &pRG->getCurve();
841  CLBoundingBox bb = pCurve->calculateBoundingBox();
842  pP = &bb.getPosition();
843  x = pP->getX();
844  y = pP->getY();
845  pDim = &bb.getDimensions();
846  x2 = x + pDim->getWidth();
847  y2 = y + pDim->getHeight();
848  minX = (minX < x) ? minX : x;
849  minY = (minY < y) ? minY : y;
850  maxX = (maxX > x2) ? maxX : x2;
851  maxY = (maxY > y2) ? maxY : y2;
852  }
853  else
854  {
855  pBB = &pRG->getBoundingBox();
856  pP = &pBB->getPosition();
857  x = pP->getX();
858  y = pP->getY();
859  pDim = &pBB->getDimensions();
860  x2 = x + pDim->getWidth();
861  y2 = y + pDim->getHeight();
862  minX = (minX < x) ? minX : x;
863  minY = (minY < y) ? minY : y;
864  maxX = (maxX > x2) ? maxX : x2;
865  maxY = (maxY > y2) ? maxY : y2;
866  }
867 
868  jMax = pRG->getListOfMetabReferenceGlyphs().size();
869 
870  for (j = 0; j < jMax; ++j)
871  {
872  pSRG = pRG->getListOfMetabReferenceGlyphs()[j];
873 
874  if (pSRG->getCurve().getNumCurveSegments() > 0)
875  {
876  pCurve = &pSRG->getCurve();
877  CLBoundingBox bb = pCurve->calculateBoundingBox();
878  pP = &bb.getPosition();
879  x = pP->getX();
880  y = pP->getY();
881  pDim = &bb.getDimensions();
882  x2 = x + pDim->getWidth();
883  y2 = y + pDim->getHeight();
884  minX = (minX < x) ? minX : x;
885  minY = (minY < y) ? minY : y;
886  maxX = (maxX > x2) ? maxX : x2;
887  maxY = (maxY > y2) ? maxY : y2;
888  }
889  else
890  {
891  pBB = &pSRG->getBoundingBox();
892  pP = &pBB->getPosition();
893  x = pP->getX();
894  y = pP->getY();
895  pDim = &pBB->getDimensions();
896  x2 = x + pDim->getWidth();
897  y2 = y + pDim->getHeight();
898  minX = (minX < x) ? minX : x;
899  minY = (minY < y) ? minY : y;
900  maxX = (maxX > x2) ? maxX : x2;
901  maxY = (maxY > y2) ? maxY : y2;
902  }
903  }
904  }
905 
906  return CLBoundingBox(CLPoint(minX, minY), CLDimensions(maxX - minX, maxY - minY));
907 }
CLBoundingBox calculateBoundingBox() const
Definition: CLCurve.cpp:218
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
Definition: CLayout.h:120
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CLBoundingBox & getBoundingBox() const
virtual size_t size() const
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
Definition: CLBase.h:54
const CLPoint & getPosition() const
Definition: CLBase.h:265
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
const CCopasiVector< CLReferenceGlyph > & getListOfReferenceGlyphs() const
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
const CLCurve & getCurve() const
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
#define max(a, b)
Definition: f2c.h:176
void CLayout::exportToDotFile ( std::ostream &  os) const

Definition at line 331 of file CLayout.cpp.

References getKey(), CCopasiObject::getKey(), CLMetabReferenceGlyph::getMetabGlyphKey(), CLMetabReferenceGlyph::getRole(), mvMetabs, mvReactions, CLMetabReferenceGlyph::PRODUCT, CCopasiVector< T >::size(), CLMetabReferenceGlyph::SUBSTRATE, writeDotEdge(), and writeDotNode().

332 {
333  os << "digraph G {\n";
334 
335  //species glyphs
336  size_t i, imax = mvMetabs.size();
337 
338  for (i = 0; i < imax; ++i)
339  {
340  writeDotNode(os, mvMetabs[i]->getKey(), mvMetabs[i]->getModelObjectDisplayName());
341  }
342 
343  //reaction glyphs
344  imax = mvReactions.size();
345 
346  for (i = 0; i < imax; ++i)
347  {
348  writeDotNode(os, mvReactions[i]->getKey() + "_S", "", 1);
349  writeDotNode(os, mvReactions[i]->getKey() + "_P", "", 1);
350  writeDotEdge(os, mvReactions[i]->getKey() + "_S", mvReactions[i]->getKey() + "_P", 1);
351 
352  size_t j, jmax = mvReactions[i]->getListOfMetabReferenceGlyphs().size();
353 
354  for (j = 0; j < jmax; ++j)
355  {
356  CLMetabReferenceGlyph* mrg = mvReactions[i]->getListOfMetabReferenceGlyphs()[j];
357 
359  writeDotEdge(os, mrg->getMetabGlyphKey(), mvReactions[i]->getKey() + "_S");
360  else if (mrg->getRole() == CLMetabReferenceGlyph::PRODUCT)
361  writeDotEdge(os, mvReactions[i]->getKey() + "_P", mrg->getMetabGlyphKey());
362  }
363  }
364 
365  os << "}" << std::endl;
366 }
void writeDotEdge(std::ostream &os, const std::string &id1, const std::string &id2, int t=0) const
Definition: CLayout.cpp:380
virtual size_t size() const
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
const std::string & getMetabGlyphKey() const
virtual const std::string & getKey() const
void writeDotNode(std::ostream &os, const std::string &id, const std::string &label, int t=0) const
Definition: CLayout.cpp:368
virtual const std::string & getKey() const
Definition: CLayout.h:71
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
void CLayout::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

This method writes the information of the copasi layout object into the corresponding sbml object

Definition at line 392 of file CLayout.cpp.

References SBMLDocumentLoader::convertLayoutObjectKeys(), CSBMLExporter::createUniqueId(), CLTextGlyph::exportReferenceToSBML(), CLMetabGlyph::exportToSBML(), CLCompartmentGlyph::exportToSBML(), CLTextGlyph::exportToSBML(), CLGeneralGlyph::exportToSBML(), CLReactionGlyph::exportToSBML(), getKey(), CLGraphicalObject::getKey(), CLGeneralGlyph::getListOfReferenceGlyphs(), CLDimensions::getSBMLDimensions(), mDimensions, mvCompartments, mvGraphicalObjects, mvLabels, mvLocalRenderInformationObjects, mvMetabs, mvReactions, and CCopasiVector< T >::size().

Referenced by CListOfLayouts::exportToSBML().

399 {
400  if (!layout) return;
401 
402  //Name and ID
403  std::string id = CSBMLExporter::createUniqueId(sbmlIDs, "layout", true);
404  layout->setId(id);
405  sbmlIDs.insert(std::pair<const std::string, const SBase*>(id, layout));
406  //we do not check if the layout is already present in the libsbml data
407  //structures. This is no big deal since at the moment no software
408  //relies on persistent IDs for layout elements.
409 
410  //Dimensions
411  Dimensions tmpDim = mDimensions.getSBMLDimensions();
412  layout->setDimensions(&tmpDim);
413 
414  //some of the following code is not used at the moment: the COPASI model map
415  //does not contain glyphs. Since this may change in the future I leave the code
416  //below.
417 
418  // create a map from COPASI layout object to SBML objects. We do not put
419  //the layout objects into the global map (copasimodelmap) but we need to have
420  //access to all objects in the current layout since speciesReferenceGlyph and
421  //textGlyph need to reference other graphical objects.
422  std::map<const CLBase*, const SBase*> layoutmap;
423 
424  //Compartment glyphs
425  size_t i, imax = mvCompartments.size();
426 
427  for (i = 0; i < imax; ++i)
428  {
430 
431  //check if the compartment glyph exists in the libsbml data
432  std::map<const CCopasiObject*, SBase*>::const_iterator it;
433  it = copasimodelmap.find(tmp);
434 
435  CompartmentGlyph * pCG;
436 
437  if (it == copasimodelmap.end()) //not found
438  {
439  pCG = layout->createCompartmentGlyph();
440  }
441  else
442  {
443  pCG = dynamic_cast<CompartmentGlyph*>(it->second);
444  }
445 
446  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pCG));
447  tmp->exportToSBML(pCG, copasimodelmap, sbmlIDs);
448  }
449 
450  //Species glyphs
451  imax = mvMetabs.size();
452 
453  for (i = 0; i < imax; ++i)
454  {
455  CLMetabGlyph * tmp = mvMetabs[i];
456 
457  //check if the glyph exists in the libsbml data
458  std::map<const CCopasiObject*, SBase*>::const_iterator it;
459  it = copasimodelmap.find(tmp);
460 
461  SpeciesGlyph * pG;
462 
463  if (it == copasimodelmap.end()) //not found
464  {
465  pG = layout->createSpeciesGlyph();
466  }
467  else
468  {
469  pG = dynamic_cast<SpeciesGlyph*>(it->second);
470  }
471 
472  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
473  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs);
474  }
475 
476  //Reaction glyphs
477  imax = mvReactions.size();
478 
479  for (i = 0; i < imax; ++i)
480  {
481  CLReactionGlyph * tmp = mvReactions[i];
482 
483  //check if the glyph exists in the libsbml data
484  std::map<const CCopasiObject*, SBase*>::const_iterator it;
485  it = copasimodelmap.find(tmp);
486 
487  ReactionGlyph * pG;
488 
489  if (it == copasimodelmap.end()) //not found
490  {
491  pG = layout->createReactionGlyph();
492  }
493  else
494  {
495  pG = dynamic_cast<ReactionGlyph*>(it->second);
496  }
497 
498  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
499  //we need to pass the layoutmap here for 2 reasons:
500  //1. the metabreferenceglyphs need to be added
501  //2. the metabreferenceglyphs need to resolve the reference to the metabglyph
502  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
503  }
504 
505  //Text glyphs
506  imax = mvLabels.size();
507 
508  for (i = 0; i < imax; ++i)
509  {
510  CLTextGlyph * tmp = mvLabels[i];
511 
512  //check if the glyph exists in the libsbml data
513  std::map<const CCopasiObject*, SBase*>::const_iterator it;
514  it = copasimodelmap.find(tmp);
515 
516  TextGlyph * pG;
517 
518  if (it == copasimodelmap.end()) //not found
519  {
520  pG = layout->createTextGlyph();
521  }
522  else
523  {
524  pG = dynamic_cast<TextGlyph*>(it->second);
525  }
526 
527  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
528  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs);
529  }
530 
531  //generic glyphs
532  imax = mvGraphicalObjects.size();
533 
534  for (i = 0; i < imax; ++i)
535  {
537 
538  //check if the glyph exists in the libsbml data
539  std::map<const CCopasiObject*, SBase*>::const_iterator it;
540  it = copasimodelmap.find(tmp);
541 
542  GraphicalObject * pG;
543 
544  if (it == copasimodelmap.end()) //not found
545  {
546 #if LIBSBML_VERSION >= 50800
547 
548  if (tmp->getListOfReferenceGlyphs().size() > 0)
549  pG = layout->createGeneralGlyph();
550  else
551 #endif // LIBSBML_VERSION >= 50800
552  pG = layout->createAdditionalGraphicalObject();
553  }
554  else
555  {
556  pG = dynamic_cast<GraphicalObject*>(it->second);
557  }
558 
559  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
560  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
561  }
562 
563  //now that we have all graphical objects in the layoutmap we can resolve the references
564  //in the text glyphs
565  imax = mvLabels.size();
566 
567  for (i = 0; i < imax; ++i)
568  {
569  const CLTextGlyph * tmp = mvLabels[i];
570 
571  //find the corresponding SBML object
572  std::map<const CLBase*, const SBase*>::const_iterator it = layoutmap.find(tmp);
573 
574  if (it != layoutmap.end() && it->second && dynamic_cast<const TextGlyph*>(it->second))
575  {
576  tmp->exportReferenceToSBML(const_cast<TextGlyph*>(dynamic_cast<const TextGlyph*>(it->second)), layoutmap);
577  }
578  }
579 
580  // export the local render information
581  imax = this->mvLocalRenderInformationObjects.size();
582  LocalRenderInformation* pLRI = NULL;
583  std::map<std::string, std::string> keyToIdMap;
584 
585  /*
586  std::map<std::string,std::string> colorKeyToIdMap;
587  std::map<std::string,std::string> gradientKeyToIdMap;
588  std::map<std::string,std::string> lineEndingKeyToIdMap;
589  std::map<std::string,std::map<std::string,std::string> > colorKeyToIdMapMap;
590  std::map<std::string,std::map<std::string,std::string> > gradientKeyToIdMapMap;
591  std::map<std::string,std::map<std::string,std::string> > lineEndingKeyToIdMapMap;
592  */
593  for (i = 0; i < imax; ++i)
594  {
595  //colorKeyToIdMap.clear();
596  //gradientKeyToIdMap.clear();
597  //lineEndingKeyToIdMap.clear();
598  //pLRI=this->mvLocalRenderInformationObjects[i]->toSBML(colorKeyToIdMap,gradientKeyToIdMap,lineEndingKeyToIdMap);
599  pLRI = this->mvLocalRenderInformationObjects[i]->toSBML(layout->getLevel(), layout->getVersion());
600  keyToIdMap.insert(std::pair<std::string, std::string>(this->mvLocalRenderInformationObjects[i]->getKey(), pLRI->getId()));
601  //colorKeyToIdMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getId(),colorKeyToIdMap));
602  //gradientKeyToIdMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getId(),gradientKeyToIdMap));
603  //lineEndingKeyToIdMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getId(),lineEndingKeyToIdMap));
604  // fix the references to layout objects in id lists
605  std::map<const CLBase*, const SBase*>::const_iterator layoutMapIt = layoutmap.begin(), layoutMapEndit = layoutmap.end();
606  std::map<std::string, std::string> layoutObjectKeyToIdMap;
607  const CLGraphicalObject* pGObject = NULL;
608 
609  while (layoutMapIt != layoutMapEndit)
610  {
611  pGObject = dynamic_cast<const CLGraphicalObject*>(layoutMapIt->first);
612 
613  if (pGObject != NULL)
614  {
615  layoutObjectKeyToIdMap.insert(std::pair<std::string, std::string>(pGObject->getKey(), layoutMapIt->second->getId()));
616  }
617 
618  ++layoutMapIt;
619  }
620 
621  size_t j, jMax = pLRI->getNumStyles();
622 
623  for (j = 0; j < jMax; ++j)
624  {
625  SBMLDocumentLoader::convertLayoutObjectKeys(*(pLRI->getStyle((unsigned int) j)), layoutObjectKeyToIdMap);
626  }
627 
628  RenderLayoutPlugin* rlolPlugin = (RenderLayoutPlugin*) layout->getPlugin("render");
629 
630  if (rlolPlugin == NULL)
631  {
632  const std::string uri = (layout->getLevel() < 3 ? RenderExtension::getXmlnsL2() : RenderExtension::getXmlnsL3V1V1());
633  layout->enablePackage(uri, "render", true);
634 
635  if (layout->getLevel() > 2)
636  layout->getSBMLDocument()->setPackageRequired("render", false);
637 
638  rlolPlugin = (RenderLayoutPlugin*) layout->getPlugin("render");
639  }
640 
641  if (rlolPlugin != NULL)
642  rlolPlugin->getListOfLocalRenderInformation()->appendAndOwn(pLRI);
643  }
644 }
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
virtual void exportToSBML(ReactionGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, std::map< const CLBase *, const SBase * > &layoutmap) const
virtual size_t size() const
Dimensions getSBMLDimensions() const
Definition: CLBase.cpp:43
static void convertLayoutObjectKeys(LocalStyle &style, const std::map< std::string, std::string > &keyToIdMap)
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
virtual void exportToSBML(CompartmentGlyph *cg, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLGlyphs.cpp:145
static const std::string createUniqueId(const std::map< std::string, const SBase * > &idMap, const std::string &prefix, bool addIndexForFirst, const std::string &separator="_")
virtual const std::string & getKey() const
CLDimensions mDimensions
Definition: CLayout.h:40
virtual void exportToSBML(SpeciesGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLGlyphs.cpp:73
const CCopasiVector< CLReferenceGlyph > & getListOfReferenceGlyphs() const
virtual const std::string & getKey() const
Definition: CLayout.h:71
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
void exportReferenceToSBML(TextGlyph *g, const std::map< const CLBase *, const SBase * > &layoutmap) const
Definition: CLGlyphs.cpp:297
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
virtual void exportToSBML(TextGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLGlyphs.cpp:267
virtual void exportToSBML(GraphicalObject *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, std::map< const CLBase *, const SBase * > &layoutmap) const
const CLDimensions& CLayout::getDimensions ( ) const
inline
virtual const std::string& CLayout::getKey ( ) const
inlinevirtual

Retrieves the key of the layout

Reimplemented from CCopasiObject.

Definition at line 71 of file CLayout.h.

References mKey.

Referenced by CQLayoutsWidget::createLayoutWindow(), exportToDotFile(), exportToSBML(), CCopasiXML::saveLayoutList(), CQLayoutsWidget::slotShowLayout(), and CQNewMainWindow::updateLayoutList().

72  {return mKey;};
std::string mKey
Definition: CLayout.h:38
const CCopasiVector<CLCompartmentGlyph>& CLayout::getListOfCompartmentGlyphs ( ) const
inline
CCopasiVector<CLCompartmentGlyph>& CLayout::getListOfCompartmentGlyphs ( )
inline

Definition at line 84 of file CLayout.h.

References mvCompartments.

85  {return mvCompartments;};
CCopasiVector< CLCompartmentGlyph > mvCompartments
Definition: CLayout.h:42
const CCopasiVector<CLGeneralGlyph>& CLayout::getListOfGeneralGlyphs ( ) const
inline
CCopasiVector<CLGeneralGlyph>& CLayout::getListOfGeneralGlyphs ( )
inline

Definition at line 136 of file CLayout.h.

References mvGraphicalObjects.

137  {return mvGraphicalObjects;};
CCopasiVector< CLGeneralGlyph > mvGraphicalObjects
Definition: CLayout.h:46
const CCopasiVector<CLLocalRenderInformation>& CLayout::getListOfLocalRenderInformationObjects ( ) const
inline
CCopasiVector<CLLocalRenderInformation>& CLayout::getListOfLocalRenderInformationObjects ( )
inline

Returns a reference to the list of local render information objects.

Definition at line 155 of file CLayout.h.

References mvLocalRenderInformationObjects.

156  {return this->mvLocalRenderInformationObjects;};
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
const CCopasiVector<CLMetabGlyph>& CLayout::getListOfMetaboliteGlyphs ( ) const
inline
CCopasiVector<CLMetabGlyph>& CLayout::getListOfMetaboliteGlyphs ( )
inline

Definition at line 97 of file CLayout.h.

References mvMetabs.

98  {return mvMetabs;};
CCopasiVector< CLMetabGlyph > mvMetabs
Definition: CLayout.h:43
const CCopasiVector<CLReactionGlyph>& CLayout::getListOfReactionGlyphs ( ) const
inline
CCopasiVector<CLReactionGlyph>& CLayout::getListOfReactionGlyphs ( )
inline

Definition at line 110 of file CLayout.h.

References mvReactions.

111  {return mvReactions;};
CCopasiVector< CLReactionGlyph > mvReactions
Definition: CLayout.h:44
const CCopasiVector<CLTextGlyph>& CLayout::getListOfTextGlyphs ( ) const
inline
CCopasiVector<CLTextGlyph>& CLayout::getListOfTextGlyphs ( )
inline

Definition at line 123 of file CLayout.h.

References mvLabels.

124  {return mvLabels;};
CCopasiVector< CLTextGlyph > mvLabels
Definition: CLayout.h:45
const CLLocalRenderInformation * CLayout::getRenderInformation ( size_t  index) const

Returns a const pointer to the local render information with the given index or NULL if the index is invalid.

Definition at line 658 of file CLayout.cpp.

References mvLocalRenderInformationObjects, and CCopasiVector< T >::size().

Referenced by CQNewMainWindow::slotRenderInfoChanged(), and CQNewMainWindow::updateRenderInformationList().

659 {
660  if (index >= this->mvLocalRenderInformationObjects.size()) return NULL;
661 
662  return this->mvLocalRenderInformationObjects[index];
663 }
virtual size_t size() const
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
CLLocalRenderInformation * CLayout::getRenderInformation ( size_t  index)

Returns a pointer to the local render information with the given index or NULL if the index is invalid.

Definition at line 669 of file CLayout.cpp.

References mvLocalRenderInformationObjects, and CCopasiVector< T >::size().

670 {
671  if (index >= this->mvLocalRenderInformationObjects.size()) return NULL;
672 
673  return this->mvLocalRenderInformationObjects[index];
674 }
virtual size_t size() const
CCopasiVector< CLLocalRenderInformation > mvLocalRenderInformationObjects
Definition: CLayout.h:47
void CLayout::moveBy ( const CLPoint p)
virtual

Reimplemented from CLBase.

Definition at line 909 of file CLayout.cpp.

References getListOfCompartmentGlyphs(), getListOfGeneralGlyphs(), getListOfMetaboliteGlyphs(), getListOfReactionGlyphs(), getListOfTextGlyphs(), CLPoint::isEmpty(), CLGraphicalObject::moveBy(), and CCopasiVector< T >::size().

Referenced by CQGLLayoutPainter::calculateAndAssignBounds(), and calculateAndAssignBounds().

910 {
911  if (p.isEmpty()) return;
912 
913  CLGraphicalObject* pObject = NULL;
914  size_t i, iMax = this->getListOfCompartmentGlyphs().size();
915 
916  for (i = 0; i < iMax; ++i)
917  {
918  pObject = this->getListOfCompartmentGlyphs()[i];
919  pObject->moveBy(p);
920  }
921 
922  iMax = this->getListOfMetaboliteGlyphs().size();
923 
924  for (i = 0; i < iMax; ++i)
925  {
926  pObject = this->getListOfMetaboliteGlyphs()[i];
927  pObject->moveBy(p);
928  }
929 
930  iMax = this->getListOfReactionGlyphs().size();
931 
932  for (i = 0; i < iMax; ++i)
933  {
934  pObject = this->getListOfReactionGlyphs()[i];
935  pObject->moveBy(p);
936  }
937 
938  iMax = this->getListOfTextGlyphs().size();
939 
940  for (i = 0; i < iMax; ++i)
941  {
942  pObject = this->getListOfTextGlyphs()[i];
943  pObject->moveBy(p);
944  }
945 
946  iMax = this->getListOfGeneralGlyphs().size();
947 
948  for (i = 0; i < iMax; ++i)
949  {
950  pObject = this->getListOfGeneralGlyphs()[i];
951  pObject->moveBy(p);
952  }
953 }
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
Definition: CLayout.h:120
virtual size_t size() const
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
bool isEmpty() const
Definition: CLBase.h:163
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
virtual void moveBy(const CLPoint &p)
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
void CLayout::print ( std::ostream *  ostream) const
virtual

This is the output method for any object. The default implementation provided with CCopasiObject uses the ostream operator<< of the object to print the object.To override this default behavior one needs to reimplement the virtual print function.

Parameters
std::ostream* ostream

Reimplemented from CCopasiObject.

Definition at line 328 of file CLayout.cpp.

329 {*os << *this;}
virtual void CLayout::scale ( const double &  scaleFactor)
inlinevirtual

Definition at line 190 of file CLayout.h.

References mDimensions, and CLDimensions::scale().

190 {this->mDimensions.scale(scaleFactor);}
CLDimensions mDimensions
Definition: CLayout.h:40
void scale(const double &scaleFactor)
Definition: CLBase.h:223
void CLayout::setDimensions ( const CLDimensions d)
inline
void CLayout::writeDotEdge ( std::ostream &  os,
const std::string &  id1,
const std::string &  id2,
int  t = 0 
) const
protected

Definition at line 380 of file CLayout.cpp.

Referenced by exportToDotFile().

383 {
384  std::string tmp;
385 
386  if (t == 1)
387  tmp = " [len=0.2] ";
388 
389  os << id1 << " -> " << id2 << tmp << "\n"; //[label=\"" << label << "\"] \n";
390 }
void CLayout::writeDotNode ( std::ostream &  os,
const std::string &  id,
const std::string &  label,
int  t = 0 
) const
protected

Definition at line 368 of file CLayout.cpp.

Referenced by exportToDotFile().

371 {
372  std::string tmp;
373 
374  if (t == 1)
375  tmp = " shape=point ";
376 
377  os << id << " [" << tmp << " label=\"" << label << "\"] \n";
378 }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CLayout g 
)
friend

insert operator

Definition at line 269 of file CLayout.cpp.

270 {
271  size_t i, imax;
272 
273  os << "Layout \"" << l.getObjectName() << "\" " << l.mDimensions << "\n\n";
274 
275  imax = l.mvCompartments.size();
276 
277  if (imax)
278  {
279  os << "List of compartment glyphs: \n\n";
280 
281  for (i = 0; i < imax; ++i)
282  os << *l.mvCompartments[i];
283  }
284 
285  imax = l.mvMetabs.size();
286 
287  if (imax)
288  {
289  os << "\nList of species glyphs: \n\n";
290 
291  for (i = 0; i < imax; ++i)
292  os << *l.mvMetabs[i];
293  }
294 
295  imax = l.mvReactions.size();
296 
297  if (imax)
298  {
299  os << "\nList of reaction glyphs: \n\n";
300 
301  for (i = 0; i < imax; ++i)
302  os << *l.mvReactions[i];
303  }
304 
305  imax = l.mvLabels.size();
306 
307  if (imax)
308  {
309  os << "\nList of labels: \n\n";
310 
311  for (i = 0; i < imax; ++i)
312  os << *l.mvLabels[i];
313  }
314 
315  imax = l.mvGraphicalObjects.size();
316 
317  if (imax)
318  {
319  os << "\nList of graphical objects: \n\n";
320 
321  for (i = 0; i < imax; ++i)
322  os << *l.mvGraphicalObjects[i];
323  }
324 
325  return os;
326 }

Member Data Documentation

CLDimensions CLayout::mDimensions
protected

Definition at line 40 of file CLayout.h.

Referenced by exportToSBML(), getDimensions(), operator<<(), scale(), and setDimensions().

std::string CLayout::mKey
protected

Definition at line 38 of file CLayout.h.

Referenced by CLayout(), getKey(), and ~CLayout().

CCopasiVector<CLCompartmentGlyph> CLayout::mvCompartments
protected
CCopasiVector<CLGeneralGlyph> CLayout::mvGraphicalObjects
protected

Definition at line 46 of file CLayout.h.

Referenced by addGeneralGlyph(), CLayout(), exportToSBML(), getListOfGeneralGlyphs(), and operator<<().

CCopasiVector<CLTextGlyph> CLayout::mvLabels
protected

Definition at line 45 of file CLayout.h.

Referenced by addTextGlyph(), CLayout(), exportToSBML(), getListOfTextGlyphs(), and operator<<().

CCopasiVector<CLLocalRenderInformation> CLayout::mvLocalRenderInformationObjects
protected
CCopasiVector<CLMetabGlyph> CLayout::mvMetabs
protected
CCopasiVector<CLReactionGlyph> CLayout::mvReactions
protected

The documentation for this class was generated from the following files: