COPASI API  4.16.103
CLGlobalRenderInformation.cpp
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 #include <sstream>
7 #include <assert.h>
8 
9 #define USE_LAYOUT 1
10 #define USE_RENDER 1
11 
12 #include <sbml/packages/render/sbml/GlobalRenderInformation.h>
13 
15 
18 
19 /**
20  * Constructor.
21  */
23  CLRenderInformationBase("GlobalRenderInformation", pParent)
24 {
25  this->mKey = CCopasiRootContainer::getKeyFactory()->add("GlobalRenderInformation", this);
26 }
27 
28 /**
29  * Copy constructor
30  */
32  CLRenderInformationBase(source, pParent),
33  mListOfStyles(source.mListOfStyles, this)
34 {
35  this->mKey = CCopasiRootContainer::getKeyFactory()->add("GlobalRenderInformation", this);
36 }
37 
38 /**
39  * Constructor to generate object from the corresponding SBML object.
40  */
41 CLGlobalRenderInformation::CLGlobalRenderInformation(const GlobalRenderInformation& source,
42  /*
43  std::map<std::string,std::string>& colorIdToKeyMap,
44  std::map<std::string,std::string>& gradientIdToKeyMap,
45  std::map<std::string,std::string>& lineEndingIdToKeyMap,
46  */
47  CCopasiContainer* pParent):
48  //CLRenderInformationBase(source,"GlobalRenderInformation",colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap,pParent)
49  CLRenderInformationBase(source, "GlobalRenderInformation", pParent)
50 {
51  this->mKey = CCopasiRootContainer::getKeyFactory()->add("GlobalRenderInformation", this);
52  unsigned int i, iMax = source.getNumStyles();
53 
54  for (i = 0; i < iMax; ++i)
55  {
56  this->mListOfStyles.add(new CLGlobalStyle(*static_cast<const GlobalStyle*>(source.getStyle(i))), true);
57  }
58 }
59 
60 /**
61  * Returns the number of styles.
62  */
64 {
65  return this->mListOfStyles.size();
66 }
67 
68 /**
69  * Returns a pointer to the LitOfStyles object.
70  */
72 {
73  return &(this->mListOfStyles);
74 }
75 
76 /**
77  * Returns a pointer to the ListOfStyles object.
78  */
80 {
81  return &(this->mListOfStyles);
82 }
83 
84 /**
85  * Returns a pointer to the style with the given index.
86  * If the index is invalid, NULL is returned.
87  */
89 {
90  return (i < this->mListOfStyles.size()) ? this->mListOfStyles[i] : NULL;
91 }
92 
93 /**
94  * Returns a pointer to the style with the given index.
95  * If the index is invalid, NULL is returned.
96  */
98 {
99  return (i < this->mListOfStyles.size()) ? this->mListOfStyles[i] : NULL;
100 }
101 
103 {
104  CLGlobalStyle* pStyle = new CLGlobalStyle();
105  this->mListOfStyles.add(pStyle, true);
106  return pStyle;
107 }
108 
110 {
111  this->mListOfStyles.add(new CLGlobalStyle(*pStyle), true);
112 }
113 
114 /**
115  * Converts this object to the corresponding SBML object.
116  *
117  */
118 bool CLGlobalRenderInformation::toSBML(GlobalRenderInformation* pGRI, unsigned int level, unsigned int version) const
119 {
120  bool result = true;
121  this->addSBMLAttributes(pGRI);
122  size_t i, iMax = this->mListOfStyles.size();
123 
124  for (i = 0; i < iMax; ++i)
125  {
126  GlobalStyle* pStyle = static_cast<const CLGlobalStyle*>(this->getStyle(i))->toSBML(level, version);
127  int success = pGRI->addStyle(pStyle);
128  assert(success == LIBSBML_OPERATION_SUCCESS);
129  result = (result && (success == LIBSBML_OPERATION_SUCCESS));
130  delete pStyle;
131  }
132 
133  return result;
134 }
CLGlobalRenderInformation(CCopasiContainer *pParent=NULL)
void addSBMLAttributes(RenderInformationBase *pBase) const
virtual size_t size() const
void addStyle(const CLGlobalStyle *pStyle)
CCopasiVector< CLGlobalStyle > * getListOfStyles()
bool toSBML(GlobalRenderInformation *pGRI, unsigned int level, unsigned int version) const
virtual bool add(const CType &src)
std::string add(const std::string &prefix, CCopasiObject *pObject)
CCopasiVector< CLGlobalStyle > mListOfStyles
static CKeyFactory * getKeyFactory()