COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CCopasiXML Class Reference

#include <CCopasiXML.h>

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

Public Member Functions

 CCopasiXML ()
 
bool freeFunctionList ()
 
bool freeGUI ()
 
bool freeLayoutList ()
 
bool freeModel ()
 
bool freePlotList ()
 
bool freeReportList ()
 
bool freeTaskList ()
 
CCopasiVectorN< CFunction > * getFunctionList () const
 
SCopasiXMLGUIgetGUI () const
 
CListOfLayoutsgetLayoutList () const
 
CModelgetModel () const
 
COutputDefinitionVectorgetPlotList () const
 
CReportDefinitionVectorgetReportList () const
 
CCopasiVectorN< CCopasiTask > * getTaskList () const
 
bool haveFunctionList () const
 
bool haveGUI () const
 
bool haveLayoutList () const
 
bool haveModel () const
 
bool havePlotList () const
 
bool haveReportList () const
 
bool haveTaskList () const
 
virtual bool load (std::istream &is, const std::string &pwd)
 
virtual bool save (std::ostream &os, const std::string &relativeTo)
 
bool setDatamodel (CCopasiDataModel *pDataModel)
 
bool setFunctionList (CCopasiVectorN< CFunction > *pFunctionList)
 
bool setGUI (SCopasiXMLGUI *pGUI)
 
bool setLayoutList (const CListOfLayouts &reportList)
 
bool setModel (CModel *pModel)
 
bool setPlotList (COutputDefinitionVector *pPlotList)
 
bool setReportList (CReportDefinitionVector *pReportList)
 
bool setTaskList (CCopasiVectorN< CCopasiTask > *pTaskList)
 
 ~CCopasiXML ()
 
- Public Member Functions inherited from CCopasiXMLInterface
 CCopasiXMLInterface ()
 
bool load (const std::string &fileName, const std::string &relativeTo)
 
bool save (const std::string &fileName, const std::string &relativeTo)
 
virtual ~CCopasiXMLInterface ()
 

Private Member Functions

bool buildFunctionList ()
 
void fixBuild55 ()
 
void fixBuild81 ()
 
void save1DAttributes (const CLGraphicalPrimitive1D &primitive, CXMLAttributeList &attributes)
 
void save2DAttributes (const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
 
bool saveAnnotation (const CAnnotation *pAnnotation)
 
template<typename HEADELEMENT >
void saveArrowHeadAttributes (const HEADELEMENT &element, CXMLAttributeList &attributes)
 
void saveBoundingBox (const CLBoundingBox &bb)
 
void saveColorDefinition (const CLColorDefinition &color)
 
void saveCurve (const CLCurve &c)
 
void saveCurveElements (const std::vector< CLRenderPoint * > &curveElements)
 
void saveDimensions (const CLDimensions &d)
 
void saveEllipseElement (const CLEllipse &ellipse)
 
bool saveFunctionList ()
 
void saveGlobalRenderInformation (const CLGlobalRenderInformation &renderInfo)
 
void saveGlobalStyle (const CLGlobalStyle &style)
 
void saveGradientAttributes (const CLGradientBase &gradient, CXMLAttributeList &attributes)
 
void saveGradientElements (const CLGradientBase &gradient)
 
void saveGradientStop (const CLGradientStop &stop)
 
void saveGroupElement (const CLGroup &group)
 
bool saveGUI ()
 
void saveImageElement (const CLImage &image)
 
bool saveLayoutList ()
 
void saveLinearGradient (const CLLinearGradient &gradient)
 
void saveLineEnding (const CLLineEnding &lineEnding)
 
void saveListOfGlobalRenderInformation (const CCopasiVector< CLGlobalRenderInformation > &list)
 
void saveListOfLocalRenderInformation (const CCopasiVector< CLLocalRenderInformation > &list)
 
void saveLocalRenderInformation (const CLLocalRenderInformation &renderInfo)
 
void saveLocalStyle (const CLLocalStyle &style)
 
bool saveModel ()
 
bool saveModelParameter (const CModelParameter *pModelParameter)
 
bool savePlotList ()
 
void savePolygonElement (const CLPolygon &polygon)
 
void savePosition (const CLPoint &p, const std::string &tag="Position")
 
void saveRadialGradient (const CLRadialGradient &gradient)
 
void saveRectangleElement (const CLRectangle &rectangle)
 
void saveRenderCurveElement (const CLRenderCurve &curve)
 
void saveRenderInformationAttributes (const CLRenderInformationBase &renderInfo, CXMLAttributeList &attributes)
 
void saveRenderInformationDefinitionElements (const CLRenderInformationBase &renderInfo)
 
void saveRenderPoint (const CLRenderPoint &point)
 
void saveRenderTextElement (const CLText &text)
 
bool saveReportList ()
 
bool saveReportSection (const std::string &name, const std::vector< CRegisteredObjectName > &section)
 
bool saveSBMLReference ()
 
void saveStyleAttributes (const CLStyle &style, CXMLAttributeList &attributes)
 
void saveStyleElements (const CLStyle &style)
 
bool saveTaskList ()
 
template<typename TEXTELEMENT >
void saveTextAttributes (const TEXTELEMENT &text, CXMLAttributeList &attributes)
 
void saveTransformation2D (const CLTransformation2D &transformation)
 
void saveTransformationAttributes (const CLTransformation2D &transformation, CXMLAttributeList &attributes)
 

Private Attributes

bool mMCXML21Issued
 
CCopasiDataModelmpDataModel
 
CCopasiVectorN< CFunction > * mpFunctionList
 
SCopasiXMLGUImpGUI
 
CListOfLayoutsmpLayoutList
 
CModelmpModel
 
COutputDefinitionVectormpPlotList
 
CReportDefinitionVectormpReportList
 
CCopasiVectorN< CCopasiTask > * mpTaskList
 
std::map< std::string,
std::string > 
mSBMLReference
 

Additional Inherited Members

- Public Types inherited from CCopasiXMLInterface
enum  EncodingType { none = 0, standard, attribute, character }
 
- Static Public Member Functions inherited from CCopasiXMLInterface
static std::string encode (const std::string &str, const EncodingType &type=standard)
 
static std::string utf8 (const std::string &str)
 
- Protected Member Functions inherited from CCopasiXMLInterface
bool endSaveElement (const std::string &name)
 
bool saveData (const std::string &data)
 
bool saveElement (const std::string &name, CXMLAttributeList &attributeList)
 
bool saveParameter (const CCopasiParameter &parameter)
 
bool saveParameterGroup (const std::vector< CCopasiParameter * > &group)
 
bool saveXhtml (const std::string &xhtml)
 
bool startSaveElement (const std::string &name)
 
bool startSaveElement (const std::string &name, CXMLAttributeList &attributeList)
 
- Protected Attributes inherited from CCopasiXMLInterface
std::string mIndent
 
std::istream * mpIstream
 
std::ostream * mpOstream
 
std::string mPWD
 

Detailed Description

Definition at line 75 of file CCopasiXML.h.

Constructor & Destructor Documentation

CCopasiXML::CCopasiXML ( )

Constructor

CCopasiXML class. This class implements a CCopasiXMLInterface to the COPASI XML specified in http://www.copasi.org/schema/copasi.xsd

Created for COPASI by Stefan Hoops 2003 Copyright Stefan Hoops

Definition at line 87 of file CCopasiXML.cpp.

87  :
89  mpModel(NULL),
90  mpFunctionList(NULL),
91  mpTaskList(NULL),
92  mpReportList(NULL),
93  mpPlotList(NULL),
94  mpGUI(NULL),
95  mpLayoutList(NULL),
96  mpDataModel(NULL),
97  mMCXML21Issued(false)
98 {}
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
CModel * mpModel
Definition: CCopasiXML.h:553
bool mMCXML21Issued
Definition: CCopasiXML.h:604
CCopasiXML::~CCopasiXML ( )

Destructor

Definition at line 100 of file CCopasiXML.cpp.

100 {}

Member Function Documentation

bool CCopasiXML::buildFunctionList ( )
private

Build a list of functions.

Returns
bool success

Definition at line 1872 of file CCopasiXML.cpp.

References CCopasiRootContainer::getFunctionList(), CCopasiDataModel::getModel(), CFunctionDB::getUsedFunctions(), mpDataModel, and setFunctionList().

Referenced by save().

1873 {
1874  bool success = true;
1875 
1876  CCopasiVectorN< CFunction > * pFunctionList
1878 
1880 
1881  if (!setFunctionList(pFunctionList)) success = false;
1882 
1883  return success;
1884 }
bool setFunctionList(CCopasiVectorN< CFunction > *pFunctionList)
Definition: CCopasiXML.cpp:270
std::vector< CFunction * > getUsedFunctions(const CModel *pModel) const
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
static CFunctionDB * getFunctionList()
void CCopasiXML::fixBuild55 ( )
private

Fix files written with Version 4.10.55, which wrote the square root of user defined weights for the parameter fitting task

Definition at line 1886 of file CCopasiXML.cpp.

References C_INVALID_INDEX, CFitTask::fixBuild55(), CCopasiVectorN< CType >::getIndex(), mpTaskList, and pTask.

Referenced by load().

1887 {
1888  if (mpTaskList == NULL) return;
1889 
1890  size_t Index = mpTaskList->getIndex("Parameter Estimation");
1891 
1892  if (Index == C_INVALID_INDEX) return;
1893 
1894  CFitTask * pTask = dynamic_cast< CFitTask * >((*mpTaskList)[Index]);
1895 
1896  if (pTask == NULL) return;
1897 
1898  pTask->fixBuild55();
1899 
1900  return;
1901 }
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
void fixBuild55()
Definition: CFitTask.cpp:129
CTSSATask * pTask
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
void CCopasiXML::fixBuild81 ( )
private

Fix files written with Version 4.12.81 and earlier, which wrote the exp(mean) and exp(std. deviation) for normal random distributions in the scan task.

Definition at line 1903 of file CCopasiXML.cpp.

References C_INVALID_INDEX, CScanTask::fixBuild81(), CCopasiVectorN< CType >::getIndex(), mpTaskList, and pTask.

Referenced by load().

1904 {
1905  if (mpTaskList == NULL) return;
1906 
1907  size_t Index = mpTaskList->getIndex("Scan");
1908 
1909  if (Index == C_INVALID_INDEX) return;
1910 
1911  CScanTask * pTask = dynamic_cast< CScanTask * >((*mpTaskList)[Index]);
1912 
1913  if (pTask == NULL) return;
1914 
1915  pTask->fixBuild81();
1916 
1917  return;
1918 }
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
CTSSATask * pTask
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
void fixBuild81()
Definition: CScanTask.cpp:322
bool CCopasiXML::freeFunctionList ( )

Free the function list.

Returns
bool success

Definition at line 282 of file CCopasiXML.cpp.

References mpFunctionList, and pdelete.

Referenced by save().

283 {
285  return true;
286 }
#define pdelete(p)
Definition: copasi.h:215
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
bool CCopasiXML::freeGUI ( )

Free the GUI.

Returns
bool success

Definition at line 369 of file CCopasiXML.cpp.

References mpGUI, and pdelete.

Referenced by CCopasiDataModel::loadModel().

370 {
371  pdelete(mpGUI);
372  return true;
373 }
#define pdelete(p)
Definition: copasi.h:215
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
bool CCopasiXML::freeLayoutList ( )

Free the layout list.

Returns
bool success

Definition at line 389 of file CCopasiXML.cpp.

References mpLayoutList, and pdelete.

Referenced by CCopasiDataModel::loadModel().

390 {
392  return true;
393 }
#define pdelete(p)
Definition: copasi.h:215
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
bool CCopasiXML::freeModel ( )

Free the model.

Returns
bool success

Definition at line 264 of file CCopasiXML.cpp.

References mpModel, and pdelete.

Referenced by CCopasiDataModel::loadModel().

265 {
266  pdelete(mpModel);
267  return true;
268 }
#define pdelete(p)
Definition: copasi.h:215
CModel * mpModel
Definition: CCopasiXML.h:553
bool CCopasiXML::freePlotList ( )

Free the plot list.

Returns
bool success

Definition at line 331 of file CCopasiXML.cpp.

References mpPlotList, and pdelete.

Referenced by CCopasiDataModel::loadModel().

332 {
334  return true;
335 }
#define pdelete(p)
Definition: copasi.h:215
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
bool CCopasiXML::freeReportList ( )

Free the report list.

Returns
bool success

Definition at line 351 of file CCopasiXML.cpp.

References mpReportList, and pdelete.

Referenced by CCopasiDataModel::loadModel().

352 {
354  return true;
355 }
#define pdelete(p)
Definition: copasi.h:215
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
bool CCopasiXML::freeTaskList ( )

Free the task list.

Returns
bool success

Definition at line 311 of file CCopasiXML.cpp.

References mpTaskList, and pdelete.

Referenced by CCopasiDataModel::loadModel().

312 {
314  return true;
315 }
#define pdelete(p)
Definition: copasi.h:215
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
CCopasiVectorN< CFunction > * CCopasiXML::getFunctionList ( ) const

Retrieve the function list.

Returns
CCopasiVectorN< CFunction > * pFunctionList

Definition at line 276 of file CCopasiXML.cpp.

References mpFunctionList.

277 {return mpFunctionList;}
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
SCopasiXMLGUI * CCopasiXML::getGUI ( ) const

Retrieve the SCopasiXMLGUI.

Returns
SCopasiXMLGUI * pGUI

Definition at line 365 of file CCopasiXML.cpp.

References mpGUI.

365 {return mpGUI;}
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
CListOfLayouts * CCopasiXML::getLayoutList ( ) const

Retrieve the layout list.

Returns
CListOfLayouts * layoutList

Definition at line 383 of file CCopasiXML.cpp.

References mpLayoutList.

Referenced by CCopasiDataModel::loadModel().

384 {return mpLayoutList;}
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
CModel * CCopasiXML::getModel ( ) const

Retreive the model.

Returns
CModel * pModel

Definition at line 260 of file CCopasiXML.cpp.

References mpModel.

Referenced by CCopasiDataModel::loadModel().

260 {return mpModel;}
CModel * mpModel
Definition: CCopasiXML.h:553
COutputDefinitionVector * CCopasiXML::getPlotList ( ) const

Retrieve the plot list.

Returns
COutputDefinitionVector * plotList

Definition at line 325 of file CCopasiXML.cpp.

References mpPlotList.

Referenced by CCopasiDataModel::loadModel().

326 {return mpPlotList;}
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
CReportDefinitionVector * CCopasiXML::getReportList ( ) const

Retrieve the report list.

Returns
CReportDefinitionVector * reportList

Definition at line 345 of file CCopasiXML.cpp.

References mpReportList.

Referenced by CCopasiDataModel::loadModel().

346 {return mpReportList;}
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
CCopasiVectorN< CCopasiTask > * CCopasiXML::getTaskList ( ) const

Retrieve the task list.

Returns
CCopasiVectorN< CCopasiTask > * taskList

Definition at line 305 of file CCopasiXML.cpp.

References mpTaskList.

Referenced by CCopasiDataModel::loadModel().

306 {return mpTaskList;}
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
bool CCopasiXML::haveFunctionList ( ) const

Retrieve whether the XML contains a function list.

Returns
bool haveFunctionList

Definition at line 279 of file CCopasiXML.cpp.

References mpFunctionList.

Referenced by save(), and saveFunctionList().

280 {return mpFunctionList != NULL;}
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
bool CCopasiXML::haveGUI ( ) const

Retrieve whether the XML contains a GUI.

Returns
bool have GUI

Definition at line 367 of file CCopasiXML.cpp.

References mpGUI.

Referenced by saveGUI().

367 {return mpGUI != NULL;}
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
bool CCopasiXML::haveLayoutList ( ) const

Retrieve whether the XML contains a layout list.

Returns
bool haveLayoutList

Definition at line 386 of file CCopasiXML.cpp.

References mpLayoutList.

Referenced by saveLayoutList().

387 {return mpLayoutList != NULL;}
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
bool CCopasiXML::haveModel ( ) const

Retreive whether the XML contains a model.

Returns
bool have Model

Definition at line 262 of file CCopasiXML.cpp.

References mpModel.

Referenced by save(), and saveModel().

262 {return mpModel != NULL;}
CModel * mpModel
Definition: CCopasiXML.h:553
bool CCopasiXML::havePlotList ( ) const

Retrieve whether the XML contains a plot list.

Returns
bool havePlotList

Definition at line 328 of file CCopasiXML.cpp.

References mpPlotList.

Referenced by savePlotList().

329 {return mpPlotList != NULL;}
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
bool CCopasiXML::haveReportList ( ) const

Retrieve whether the XML contains a report list.

Returns
bool haveReportList

Definition at line 348 of file CCopasiXML.cpp.

References mpReportList.

Referenced by saveReportList().

349 {return mpReportList != NULL;}
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
bool CCopasiXML::haveTaskList ( ) const

Retrieve whether the XML contains a task list.

Returns
bool haveTaskList

Definition at line 308 of file CCopasiXML.cpp.

References mpTaskList.

Referenced by saveTaskList().

309 {return mpTaskList != NULL;}
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
bool CCopasiXML::load ( std::istream &  is,
const std::string &  pwd 
)
virtual

Load information from a given istream.

Parameters
std::istream& is
conststd::string & pwd
Returns
bool success

Implements CCopasiXMLInterface.

Definition at line 169 of file CCopasiXML.cpp.

References BUFFER_SIZE, fatalError, fixBuild55(), fixBuild81(), CExpatTemplate< CType >::getCurrentColumnNumber(), CExpatTemplate< CType >::getCurrentLineNumber(), CExpatTemplate< CType >::getErrorString(), CCopasiXMLParser::getLayoutList(), CCopasiXMLParser::getModel(), CCopasiXMLParser::getPlotList(), CCopasiXMLParser::getReportList(), CCopasiXMLParser::getTaskList(), CVersion::getVersion(), CVersion::getVersionDevel(), MCXML, mpDataModel, mpFunctionList, mpGUI, CCopasiXMLInterface::mpIstream, mpLayoutList, mpModel, mpPlotList, mpReportList, mpTaskList, CCopasiXMLInterface::mPWD, CExpatTemplate< CType >::parse(), pdelete, CCopasiMessage::RAW, CCopasiXMLParser::setDatamodel(), CCopasiXMLParser::setFunctionList(), CCopasiXMLParser::setGUI(), CCopasiXMLParser::setLayoutList(), CVersion::VERSION, and CCopasiMessage::WARNING.

Referenced by CFunctionDB::load(), and CCopasiDataModel::loadModel().

171 {
172  mPWD = relativeTo;
173 
174  is.imbue(std::locale::classic());
175  is.precision(16);
176 
177  mpIstream = &is;
178  bool success = true;
179  bool done = false;
180 
181  CVersion FileVersion;
182  CCopasiXMLParser Parser(FileVersion);
183 
184  Parser.setFunctionList(mpFunctionList);
185  Parser.setGUI(mpGUI);
186  Parser.setLayoutList(mpLayoutList);
187  Parser.setDatamodel(this->mpDataModel);
188 
189 #define BUFFER_SIZE 0xfffe
190  char * pBuffer = new char[BUFFER_SIZE + 1];
191 
192  try
193  {
194  while (!done)
195  {
196  mpIstream->get(pBuffer, BUFFER_SIZE, 0);
197 
198  if (mpIstream->eof()) done = true;
199 
200  if (mpIstream->fail() && !done) fatalError();
201 
202  if (!Parser.parse(pBuffer, -1, done))
203  {
205  Parser.getCurrentLineNumber(),
206  Parser.getCurrentColumnNumber(),
207  Parser.getErrorString());
208  done = true;
209  success = false;
210  }
211  }
212  }
213 
214  catch (...)
215  {
216  success = false;
217  }
218 
219  delete [] pBuffer;
220 #undef BUFFER_SIZE
221 
222  mpModel = Parser.getModel();
223  mpReportList = Parser.getReportList();
224  mpTaskList = Parser.getTaskList();
225  mpPlotList = Parser.getPlotList();
226  mpLayoutList = Parser.getLayoutList();
227 
228  if (!success)
229  {
230  pdelete(mpModel);
235  }
236 
237  // The range in which the fix needs to be applied
238  if (36 <= FileVersion.getVersionDevel() && FileVersion.getVersionDevel() <= 58)
239  {
240  fixBuild55();
241  }
242 
243  if (FileVersion.getVersionDevel() <= 81)
244  {
245  fixBuild81();
246  }
247 
248  if (!CVersion::VERSION.isCompatible(FileVersion))
249  CCopasiMessage(CCopasiMessage::WARNING, MCXML + 9, FileVersion.getVersion().c_str());
250 
251  return success;
252 }
#define pdelete(p)
Definition: copasi.h:215
#define BUFFER_SIZE
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
void fixBuild81()
#define fatalError()
#define MCXML
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
void fixBuild55()
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
struct MESSAGES Message
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
C_INT32 getVersionDevel() const
Definition: CVersion.cpp:129
CModel * mpModel
Definition: CCopasiXML.h:553
const std::string & getVersion() const
Definition: CVersion.cpp:139
static const CVersion VERSION
Definition: CVersion.h:164
bool CCopasiXML::save ( std::ostream &  os,
const std::string &  relativeTo 
)
virtual

Save information to a given ostream.

Parameters
std::ostream& os
conststd::string & relativeTo
Returns
bool success

Implements CCopasiXMLInterface.

Definition at line 102 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), buildFunctionList(), CCopasiXMLInterface::endSaveElement(), freeFunctionList(), CVersion::getVersion(), haveFunctionList(), haveModel(), CCopasiXMLInterface::mpOstream, CCopasiXMLInterface::mPWD, saveFunctionList(), saveGUI(), saveLayoutList(), saveModel(), savePlotList(), saveReportList(), saveSBMLReference(), saveTaskList(), CCopasiXMLInterface::startSaveElement(), UTCTimeStamp(), and CVersion::VERSION.

Referenced by save_cps_model_to_stream().

104 {
105  mPWD = relativeTo;
106 
107  os.imbue(std::locale::classic());
108  os.precision(16);
109 
110  mpOstream = &os;
111  bool success = true;
112 
113  *mpOstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
114  << std::endl;
115 
116  *mpOstream << "<!-- generated with COPASI "
118  << " (http://www.copasi.org) at "
119  << UTCTimeStamp()
120  << " UTC -->"
121  << std::endl;
122 
123  *mpOstream << "<?oxygen RNGSchema=\"http://www.copasi.org/static/schema/CopasiML.rng\" type=\"xml\"?>" << std::endl;
124 
125  CXMLAttributeList Attributes;
126  Attributes.add("xmlns", "http://www.copasi.org/static/schema");
127  Attributes.add("versionMajor", CVersion::VERSION.getVersionMajor());
128  Attributes.add("versionMinor", CVersion::VERSION.getVersionMinor());
129  Attributes.add("versionDevel", CVersion::VERSION.getVersionDevel());
130  Attributes.add("copasiSourcesModified", CVersion::VERSION.isSourceModified());
131 
132  /*
133  Attributes.add("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
134  Attributes.add("xsi:noNamespaceSchemaLocation",
135  "http://www.copasi.org/static/schema/CopasiML.rng");
136  */
137 
138  startSaveElement("COPASI", Attributes);
139 
140  if (haveModel() && !haveFunctionList())
141  {
142  if (!buildFunctionList()) success = false;
143 
144  if (!saveFunctionList()) success = false;
145 
146  if (!freeFunctionList()) success = false;
147  }
148  else if (!saveFunctionList()) success = false;
149 
150  if (!saveModel()) success = false;
151 
152  if (!saveTaskList()) success = false;
153 
154  if (!saveReportList()) success = false;
155 
156  if (!savePlotList()) success = false;
157 
158  if (!saveGUI()) success = false;
159 
160  if (!saveLayoutList()) success = false;
161 
162  if (!saveSBMLReference()) success = false;
163 
164  endSaveElement("COPASI");
165 
166  return success;
167 }
bool startSaveElement(const std::string &name)
bool saveReportList()
bool savePlotList()
bool haveModel() const
Definition: CCopasiXML.cpp:262
bool haveFunctionList() const
Definition: CCopasiXML.cpp:279
bool freeFunctionList()
Definition: CCopasiXML.cpp:282
bool saveModel()
Definition: CCopasiXML.cpp:395
bool saveSBMLReference()
bool saveLayoutList()
bool endSaveElement(const std::string &name)
bool saveGUI()
std::string UTCTimeStamp()
Definition: utility.cpp:64
bool saveFunctionList()
const std::string & getVersion() const
Definition: CVersion.cpp:139
bool buildFunctionList()
bool saveTaskList()
bool add(const std::string &name, const CType &value)
static const CVersion VERSION
Definition: CVersion.h:164
void CCopasiXML::save1DAttributes ( const CLGraphicalPrimitive1D primitive,
CXMLAttributeList attributes 
)
private

Saves the attributes for a 1D element

Definition at line 2342 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLGraphicalPrimitive1D::getDashArray(), CLGraphicalPrimitive1D::getStroke(), CLGraphicalPrimitive1D::getStrokeWidth(), CLGraphicalPrimitive1D::isSetDashArray(), CLGraphicalPrimitive1D::isSetStroke(), CLGraphicalPrimitive1D::isSetStrokeWidth(), and saveTransformationAttributes().

Referenced by save2DAttributes(), saveRenderCurveElement(), and saveRenderTextElement().

2343 {
2344  // first we go and add the transformation attributes because each 1D element is automatically a transformation element.
2345  saveTransformationAttributes(primitive, attributes);
2346 
2347  // stroke
2348  if (primitive.isSetStroke())
2349  {
2350  attributes.add("stroke", primitive.getStroke());
2351  }
2352 
2353  // stroke size
2354  if (primitive.isSetStrokeWidth())
2355  {
2356  std::ostringstream os;
2357  os << primitive.getStrokeWidth();
2358  attributes.add("stroke-width", os.str());
2359  }
2360 
2361  // stroke dash array
2362  if (primitive.isSetDashArray())
2363  {
2364  std::ostringstream os;
2365  size_t i, iMax = primitive.getDashArray().size();
2366  os << primitive.getDashArray()[0];
2367 
2368  for (i = 1; i < iMax; ++i)
2369  {
2370  os << ", " << primitive.getDashArray()[i];
2371  }
2372 
2373  attributes.add("stroke-dasharray", os.str());
2374  }
2375 }
const std::string & getStroke() const
void saveTransformationAttributes(const CLTransformation2D &transformation, CXMLAttributeList &attributes)
bool add(const std::string &name, const CType &value)
const std::vector< unsigned int > & getDashArray() const
void CCopasiXML::save2DAttributes ( const CLGraphicalPrimitive2D primitive,
CXMLAttributeList attributes 
)
private

Saves the attributes for a 2D element

Definition at line 2380 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLGraphicalPrimitive2D::EVENODD, CLGraphicalPrimitive2D::getFillColor(), CLGraphicalPrimitive2D::getFillRule(), CLGraphicalPrimitive2D::isSetFill(), CLGraphicalPrimitive2D::isSetFillRule(), CLGraphicalPrimitive2D::NONZERO, and save1DAttributes().

Referenced by saveEllipseElement(), saveGroupElement(), savePolygonElement(), and saveRectangleElement().

2381 {
2382  // first we go and add the 1D attributes because each 2D element is automatically a 1D element.
2383  save1DAttributes(primitive, attributes);
2384 
2385  // fill
2386  if (primitive.isSetFill())
2387  {
2388  attributes.add("fill", primitive.getFillColor());
2389  }
2390 
2391  // fill rule
2392  if (primitive.isSetFillRule())
2393  {
2394  switch (primitive.getFillRule())
2395  {
2397  attributes.add("fill-rule", "evenodd");
2398  break;
2399 
2401  default:
2402  attributes.add("fill-rule", "nonzero");
2403  break;
2404  }
2405  }
2406 }
void save1DAttributes(const CLGraphicalPrimitive1D &primitive, CXMLAttributeList &attributes)
const std::string & getFillColor() const
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveAnnotation ( const CAnnotation pAnnotation)
private

Definition at line 922 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CAnnotation::getMiriamAnnotation(), CAnnotation::getNotes(), CAnnotation::getUnsupportedAnnotations(), CCopasiXMLInterface::mpOstream, CCopasiXMLInterface::saveXhtml(), CXMLAttributeList::setValue(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveFunctionList(), and saveModel().

923 {
924  if (pAnnotation->getMiriamAnnotation() != "")
925  {
926  startSaveElement("MiriamAnnotation");
927  *mpOstream << pAnnotation->getMiriamAnnotation() << std::endl;
928  endSaveElement("MiriamAnnotation");
929  }
930 
931  if (pAnnotation->getNotes() != "")
932  {
933  startSaveElement("Comment");
934  saveXhtml(pAnnotation->getNotes());
935  endSaveElement("Comment");
936  }
937 
938  if (pAnnotation->getUnsupportedAnnotations().size() > 0)
939  {
940  startSaveElement("ListOfUnsupportedAnnotations");
941 
942  CAnnotation::UnsupportedAnnotation::const_iterator it = pAnnotation->getUnsupportedAnnotations().begin();
943  CAnnotation::UnsupportedAnnotation::const_iterator end = pAnnotation->getUnsupportedAnnotations().end();
944 
945  CXMLAttributeList Attributes;
946  Attributes.add("name", "");
947 
948  for (; it != end; ++it)
949  {
950  Attributes.setValue(0, it->first);
951 
952  startSaveElement("UnsupportedAnnotation", Attributes);
953  *mpOstream << it->second << std::endl;
954  endSaveElement("UnsupportedAnnotation");
955  }
956 
957  endSaveElement("ListOfUnsupportedAnnotations");
958  }
959 
960  return true;
961 }
bool startSaveElement(const std::string &name)
bool saveXhtml(const std::string &xhtml)
const std::string & getMiriamAnnotation() const
bool setValue(const size_t &index, const CType &value)
const std::string & getNotes() const
bool endSaveElement(const std::string &name)
UnsupportedAnnotation & getUnsupportedAnnotations()
bool add(const std::string &name, const CType &value)
template<typename HEADELEMENT >
void CCopasiXML::saveArrowHeadAttributes ( const HEADELEMENT &  element,
CXMLAttributeList attributes 
)
private

Saves the startHead and endHead attribute as found in group and curves. We write it as a template so that it can be used on curves and group elements.

Definition at line 2505 of file CCopasiXML.cpp.

References CXMLAttributeList::add().

2506 {
2507  // start head
2508  if (element.isSetStartHead())
2509  {
2510  attributes.add("startHead", element.getStartHead());
2511  }
2512 
2513  // start head
2514  if (element.isSetEndHead())
2515  {
2516  attributes.add("endHead", element.getEndHead());
2517  }
2518 }
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveBoundingBox ( const CLBoundingBox bb)
private

Definition at line 1382 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), CLBoundingBox::getDimensions(), CLBoundingBox::getPosition(), saveDimensions(), savePosition(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveLayoutList(), and saveLineEnding().

1383 {
1384  startSaveElement("BoundingBox");
1385  savePosition(bb.getPosition());
1387  endSaveElement("BoundingBox");
1388 }
void saveDimensions(const CLDimensions &d)
bool startSaveElement(const std::string &name)
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const CLPoint & getPosition() const
Definition: CLBase.h:265
void savePosition(const CLPoint &p, const std::string &tag="Position")
bool endSaveElement(const std::string &name)
void CCopasiXML::saveColorDefinition ( const CLColorDefinition color)
private

Save a single color definition element.

Definition at line 2103 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLColorDefinition::createValueString(), CLColorDefinition::getId(), and CCopasiXMLInterface::saveElement().

Referenced by saveRenderInformationDefinitionElements().

2104 {
2105  CXMLAttributeList attributes;
2106  attributes.add("id", color.getId());
2107  attributes.add("value", color.createValueString());
2108  saveElement("ColorDefinition", attributes);
2109 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
std::string createValueString() const
const std::string & getId() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveCurve ( const CLCurve c)
private

Definition at line 1390 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CLLineSegment::getBase1(), CLLineSegment::getBase2(), CLCurve::getCurveSegments(), CLLineSegment::getEnd(), CLCurve::getNumCurveSegments(), CLLineSegment::getStart(), CLLineSegment::isBezier(), savePosition(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveLayoutList().

1391 {
1392  CXMLAttributeList Attributes;
1393  startSaveElement("Curve");
1394 
1395  if (c.getNumCurveSegments() > 0)
1396  {
1397  startSaveElement("ListOfCurveSegments");
1398  size_t i, imax = c.getNumCurveSegments();
1399 
1400  for (i = 0; i < imax; ++i)
1401  {
1402  const CLLineSegment & cs = c.getCurveSegments()[i];
1403 
1404  Attributes.erase();
1405 
1406  if (cs.isBezier())
1407  Attributes.add("xsi:type", "CubicBezier");
1408  else
1409  Attributes.add("xsi:type", "LineSegment");
1410 
1411  startSaveElement("CurveSegment", Attributes);
1412 
1413  savePosition(cs.getStart(), "Start");
1414  savePosition(cs.getEnd(), "End");
1415 
1416  if (cs.isBezier())
1417  {
1418  savePosition(cs.getBase1(), "BasePoint1");
1419  savePosition(cs.getBase2(), "BasePoint2");
1420  }
1421 
1422  endSaveElement("CurveSegment");
1423  }
1424 
1425  endSaveElement("ListOfCurveSegments");
1426  }
1427 
1428  endSaveElement("Curve");
1429 }
bool startSaveElement(const std::string &name)
const std::vector< CLLineSegment > & getCurveSegments() const
Definition: CLCurve.h:154
const CLPoint & getBase1() const
Definition: CLCurve.h:82
const CLPoint & getBase2() const
Definition: CLCurve.h:83
const CLPoint & getEnd() const
Definition: CLCurve.h:75
bool isBezier() const
Definition: CLCurve.h:90
void savePosition(const CLPoint &p, const std::string &tag="Position")
bool endSaveElement(const std::string &name)
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
bool add(const std::string &name, const CType &value)
const CLPoint & getStart() const
Definition: CLCurve.h:74
void CCopasiXML::saveCurveElements ( const std::vector< CLRenderPoint * > &  curveElements)
private

saves a vector of curve elements. This can be called from the polygon as well as the curve.

Definition at line 2718 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), saveRenderPoint(), and CCopasiXMLInterface::startSaveElement().

Referenced by savePolygonElement(), and saveRenderCurveElement().

2719 {
2720  startSaveElement("ListOfElements");
2721  size_t i, iMax = curveElements.size();
2722 
2723  for (i = 0; i < iMax; ++i)
2724  {
2725  saveRenderPoint(*curveElements[i]);
2726  }
2727 
2728  endSaveElement("ListOfElements");
2729 }
bool startSaveElement(const std::string &name)
void saveRenderPoint(const CLRenderPoint &point)
bool endSaveElement(const std::string &name)
void CCopasiXML::saveDimensions ( const CLDimensions d)
private

Definition at line 1373 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CXMLAttributeList::erase(), CLDimensions::getHeight(), CLDimensions::getWidth(), and CCopasiXMLInterface::saveElement().

Referenced by saveBoundingBox().

1374 {
1375  CXMLAttributeList Attributes;
1376  Attributes.erase();
1377  Attributes.add("width", d.getWidth());
1378  Attributes.add("height", d.getHeight());
1379  saveElement("Dimensions", Attributes);
1380 }
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveEllipseElement ( const CLEllipse ellipse)
private

saves a single ellipse element.

Definition at line 2636 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLEllipse::getCX(), CLEllipse::getCY(), CLEllipse::getCZ(), CLEllipse::getRX(), CLEllipse::getRY(), save2DAttributes(), CCopasiXMLInterface::saveElement(), and CLRelAbsVector::toString().

Referenced by saveTransformation2D().

2637 {
2638  CXMLAttributeList attributes;
2639  // first we add the attributes for a 2D object
2640  save2DAttributes(ellipse, attributes);
2641  // now we add the ellipse specific attributes
2642  attributes.add("cx", ellipse.getCX().toString());
2643  attributes.add("cy", ellipse.getCY().toString());
2644 
2645  if (ellipse.getCZ() != CLRelAbsVector(0.0, 0.0))
2646  {
2647  attributes.add("cz", ellipse.getCZ().toString());
2648  }
2649 
2650  if (ellipse.getRX() != CLRelAbsVector(0.0, 0.0))
2651  {
2652  attributes.add("rx", ellipse.getRX().toString());
2653  }
2654 
2655  if (ellipse.getRY() != CLRelAbsVector(0.0, 0.0))
2656  {
2657  attributes.add("ry", ellipse.getRY().toString());
2658  }
2659 
2660  saveElement("Ellipse", attributes);
2661 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const CLRelAbsVector & getRX() const
Definition: CLEllipse.cpp:151
const CLRelAbsVector & getCY() const
Definition: CLEllipse.cpp:135
void save2DAttributes(const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
const CLRelAbsVector & getCZ() const
Definition: CLEllipse.cpp:143
const CLRelAbsVector & getRY() const
Definition: CLEllipse.cpp:159
std::string toString() const
const CLRelAbsVector & getCX() const
Definition: CLEllipse.cpp:127
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveFunctionList ( )
private

Save the list of functions.

Returns
bool success

Definition at line 1018 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CEvaluationTree::getInfix(), CFunction::getKey(), CFunctionParameter::getKey(), CCopasiObject::getObjectName(), CFunction::getSBMLId(), CEvaluationTree::getType(), CFunctionParameter::getUsage(), CFunction::getVariables(), haveFunctionList(), CFunction::isReversible(), mpFunctionList, mSBMLReference, CFunctionParameter::RoleNameXML, saveAnnotation(), CCopasiXMLInterface::saveData(), CCopasiXMLInterface::saveElement(), CXMLAttributeList::setValue(), CFunctionParameters::size(), CCopasiVector< T >::size(), CCopasiXMLInterface::startSaveElement(), TriFalse, TriTrue, TriUnspecified, and CEvaluationTree::XMLType.

Referenced by save().

1019 {
1020  bool success = true;
1021 
1022  if (!haveFunctionList()) return success;
1023 
1024  size_t i, imax = mpFunctionList->size();
1025 
1026  if (!imax) return success;
1027 
1028  CXMLAttributeList Attributes;
1029  CFunction * pFunction = NULL;
1030 
1031  startSaveElement("ListOfFunctions");
1032 
1033  for (i = 0; i < imax; i++)
1034  {
1035  pFunction = (*mpFunctionList)[i];
1036 
1037  Attributes.erase();
1038  Attributes.add("key", pFunction->getKey());
1039  Attributes.add("name", pFunction->getObjectName());
1040  Attributes.add("type", CEvaluationTree::XMLType[pFunction->getType()]);
1041 
1042  if (pFunction)
1043  {
1044  switch (pFunction->isReversible())
1045  {
1046  case TriUnspecified:
1047  Attributes.add("reversible", "unspecified");
1048  break;
1049 
1050  case TriFalse:
1051  Attributes.add("reversible", "false");
1052  break;
1053 
1054  case TriTrue:
1055  Attributes.add("reversible", "true");
1056  break;
1057  }
1058 
1059  if (pFunction->getSBMLId() != "")
1060  mSBMLReference[pFunction->getSBMLId()] = pFunction->getKey();
1061  }
1062 
1063  startSaveElement("Function", Attributes);
1064 
1065  saveAnnotation(pFunction);
1066 
1067  startSaveElement("Expression");
1068  saveData(pFunction->getInfix());
1069  endSaveElement("Expression");
1070 
1071  if (pFunction)
1072  {
1073  startSaveElement("ListOfParameterDescriptions");
1074 
1075  size_t j, jmax = pFunction->getVariables().size();
1076  CFunctionParameter * pParameter;
1077 
1078  Attributes.erase();
1079  Attributes.add("key", "");
1080  Attributes.add("name", "");
1081  Attributes.add("order", "");
1082  Attributes.add("role", "");
1083 
1084  for (j = 0; j < jmax; j++)
1085  {
1086  pParameter = pFunction->getVariables()[j];
1087  Attributes.setValue(0, pParameter->getKey());
1088  Attributes.setValue(1, pParameter->getObjectName());
1089  Attributes.setValue(2, j);
1090  Attributes.setValue(3, CFunctionParameter::RoleNameXML[pParameter->getUsage()]);
1091 
1092  saveElement("ParameterDescription", Attributes);
1093  }
1094 
1095  endSaveElement("ListOfParameterDescriptions");
1096  }
1097 
1098  endSaveElement("Function");
1099  }
1100 
1101  endSaveElement("ListOfFunctions");
1102 
1103  return success;
1104 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
virtual size_t size() const
bool saveData(const std::string &data)
virtual const std::string & getKey() const
const CEvaluationTree::Type & getType() const
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
bool haveFunctionList() const
Definition: CCopasiXML.cpp:279
const std::string & getKey() const
Definition: CFunction.cpp:58
static const std::string RoleNameXML[]
bool setValue(const size_t &index, const CType &value)
bool saveAnnotation(const CAnnotation *pAnnotation)
Definition: CCopasiXML.cpp:922
const TriLogic & isReversible() const
Definition: CFunction.cpp:145
std::map< std::string, std::string > mSBMLReference
Definition: CCopasiXML.h:594
const std::string & getSBMLId() const
Definition: CFunction.cpp:68
bool endSaveElement(const std::string &name)
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
static const char * XMLType[]
const std::string & getInfix() const
CFunctionParameters & getVariables()
Definition: CFunction.cpp:148
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveGlobalRenderInformation ( const CLGlobalRenderInformation renderInfo)
private

Saves a single global render information object.

Definition at line 1955 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), CLGlobalRenderInformation::getNumStyles(), CLGlobalRenderInformation::getStyle(), saveGlobalStyle(), saveRenderInformationAttributes(), saveRenderInformationDefinitionElements(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveListOfGlobalRenderInformation().

1956 {
1957  // first we create the attributes that are common to all render information objects
1958  CXMLAttributeList attributes;
1959  saveRenderInformationAttributes(renderInfo, attributes);
1960  startSaveElement("RenderInformation", attributes);
1961  // now we save the definition that are the same for all render information objects
1963  // last we save the global styles
1964  size_t i, iMax = renderInfo.getNumStyles();
1965 
1966  if (iMax > 0)
1967  {
1968  startSaveElement("ListOfStyles");
1969 
1970  for (i = 0; i < iMax; ++i)
1971  {
1972  saveGlobalStyle(*(dynamic_cast<const CLGlobalStyle*>(renderInfo.getStyle(i))));
1973  }
1974 
1975  endSaveElement("ListOfStyles");
1976  }
1977 
1978  endSaveElement("RenderInformation");
1979 }
bool startSaveElement(const std::string &name)
void saveGlobalStyle(const CLGlobalStyle &style)
void saveRenderInformationAttributes(const CLRenderInformationBase &renderInfo, CXMLAttributeList &attributes)
bool endSaveElement(const std::string &name)
void saveRenderInformationDefinitionElements(const CLRenderInformationBase &renderInfo)
void CCopasiXML::saveGlobalStyle ( const CLGlobalStyle style)
private

Saves a single local style element.

Definition at line 2253 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), saveStyleAttributes(), saveStyleElements(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveGlobalRenderInformation().

2254 {
2255  // first we create the attributes
2256  CXMLAttributeList attributes;
2257  saveStyleAttributes(style, attributes);
2258  startSaveElement("Style", attributes);
2259  saveStyleElements(style);
2260  endSaveElement("Style");
2261 }
bool startSaveElement(const std::string &name)
void saveStyleAttributes(const CLStyle &style, CXMLAttributeList &attributes)
void saveStyleElements(const CLStyle &style)
bool endSaveElement(const std::string &name)
void CCopasiXML::saveGradientAttributes ( const CLGradientBase gradient,
CXMLAttributeList attributes 
)
private

Adds the attributes common to radial and linear gradient.

Definition at line 2167 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLGradientBase::getId(), CLGradientBase::getSpreadMethod(), CLGradientBase::PAD, CLGradientBase::REFLECT, and CLGradientBase::REPEAT.

Referenced by saveLinearGradient(), and saveRadialGradient().

2168 {
2169  attributes.add("id", gradient.getId());
2170 
2171  switch (gradient.getSpreadMethod())
2172  {
2174  attributes.add("spreadMethod", "repeat");
2175  break;
2176 
2178  attributes.add("spreadMethod", "reflect");
2179  break;
2180 
2181  case CLGradientBase::PAD:
2182  default:
2183  attributes.add("spreadMethod", "pad");
2184  break;
2185  }
2186 }
const std::string & getId() const
SPREADMETHOD getSpreadMethod() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveGradientElements ( const CLGradientBase gradient)
private

Saves the elements that are common to linear and radial gradients.

Definition at line 2191 of file CCopasiXML.cpp.

References CLGradientBase::getGradientStop(), CLGradientBase::getNumGradientStops(), and saveGradientStop().

Referenced by saveLinearGradient(), and saveRadialGradient().

2192 {
2193  size_t i, iMax = gradient.getNumGradientStops();
2194 
2195  if (iMax > 0)
2196  {
2197  for (i = 0; i < iMax; ++i)
2198  {
2199  saveGradientStop(*(gradient.getGradientStop(i)));
2200  }
2201  }
2202 }
CLGradientStop * getGradientStop(size_t i)
size_t getNumGradientStops() const
void saveGradientStop(const CLGradientStop &stop)
void CCopasiXML::saveGradientStop ( const CLGradientStop stop)
private

Saves a single gradient stop element.

Definition at line 2207 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLGradientStop::getOffset(), CLGradientStop::getStopColor(), CCopasiXMLInterface::saveElement(), and CLRelAbsVector::toString().

Referenced by saveGradientElements().

2208 {
2209  CXMLAttributeList attributes;
2210  attributes.add("offset", stop.getOffset().toString());
2211  attributes.add("stop-color", stop.getStopColor());
2212  saveElement("Stop", attributes);
2213 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const std::string & getStopColor() const
const CLRelAbsVector & getOffset() const
std::string toString() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveGroupElement ( const CLGroup group)
private

Saves a group element.

Definition at line 2293 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), save2DAttributes(), saveTransformation2D(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveLineEnding(), saveStyleElements(), and saveTransformation2D().

2294 {
2295  CXMLAttributeList attributes;
2296  save2DAttributes(group, attributes);
2297  saveTextAttributes<CLGroup>(group, attributes);
2298  saveArrowHeadAttributes<CLGroup>(group, attributes);
2299  startSaveElement("Group", attributes);
2300  size_t i, iMax = group.getNumElements();
2301 
2302  if (iMax > 0)
2303  {
2304  for (i = 0; i < iMax; ++i)
2305  {
2306  saveTransformation2D(*dynamic_cast<const CLTransformation2D*>(group.getElement(i)));
2307  }
2308  }
2309 
2310  endSaveElement("Group");
2311 }
bool startSaveElement(const std::string &name)
void saveTransformation2D(const CLTransformation2D &transformation)
void save2DAttributes(const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
bool endSaveElement(const std::string &name)
bool CCopasiXML::saveGUI ( )
private

Save GUI information

Returns
bool success

Definition at line 1779 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CSlider::convertScaleToScaleName(), CCopasiXMLInterface::endSaveElement(), CSlider::getAssociatedEntityKey(), CSlider::getKey(), CSlider::getMaxValue(), CSlider::getMinValue(), CSlider::getScaling(), SCopasiXMLGUI::getSliderList(), CSlider::getSliderObjectCN(), CSlider::getSliderType(), CSlider::getSliderValue(), CSlider::getTickFactor(), CSlider::getTickNumber(), haveGUI(), mpGUI, CCopasiXMLInterface::saveElement(), CXMLAttributeList::setValue(), CCopasiVector< T >::size(), CCopasiXMLInterface::startSaveElement(), and CSlider::TypeName.

Referenced by save().

1780 {
1781  bool success = true;
1782 
1783  if (!haveGUI()) return success;
1784 
1785  startSaveElement("GUI");
1786 
1787  if (mpGUI->getSliderList() && mpGUI->getSliderList()->size())
1788  {
1789  startSaveElement("ListOfSliders");
1790 
1791  CSlider * pSlider;
1792  CXMLAttributeList Attributes;
1793 
1794  Attributes.add("key", "");
1795  Attributes.add("associatedEntityKey", "");
1796  Attributes.add("objectCN", "");
1797  Attributes.add("objectType", "");
1798  Attributes.add("objectValue", "");
1799  Attributes.add("minValue", "");
1800  Attributes.add("maxValue", "");
1801  Attributes.add("tickNumber", "");
1802  Attributes.add("tickFactor", "");
1803  Attributes.add("scaling", "");
1804 
1805  size_t i, imax = mpGUI->getSliderList()->size();
1806 
1807  for (i = 0; i < imax; i++)
1808  {
1809  pSlider = (*mpGUI->getSliderList())[i];
1810  Attributes.setValue(0, pSlider->getKey());
1811  Attributes.setValue(1, pSlider->getAssociatedEntityKey());
1812  Attributes.setValue(2, pSlider->getSliderObjectCN());
1813  Attributes.setValue(3, CSlider::TypeName[pSlider->getSliderType()]);
1814  Attributes.setValue(4, pSlider->getSliderValue());
1815  Attributes.setValue(5, pSlider->getMinValue());
1816  Attributes.setValue(6, pSlider->getMaxValue());
1817  Attributes.setValue(7, pSlider->getTickNumber());
1818  Attributes.setValue(8, pSlider->getTickFactor());
1819  Attributes.setValue(9, pSlider->convertScaleToScaleName(pSlider->getScaling()));
1820  saveElement("Slider", Attributes);
1821  }
1822 
1823  endSaveElement("ListOfSliders");
1824  }
1825 
1826  endSaveElement("GUI");
1827 
1828  return success;
1829 }
CCopasiVector< CSlider > * getSliderList()
const char * convertScaleToScaleName(Scale scale)
Definition: CSlider.cpp:396
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
bool startSaveElement(const std::string &name)
virtual size_t size() const
bool haveGUI() const
Definition: CCopasiXML.cpp:367
const std::string & getSliderObjectCN() const
Definition: CSlider.cpp:179
const std::string & getAssociatedEntityKey() const
Definition: CSlider.cpp:101
const std::string & getKey() const
Definition: CSlider.cpp:91
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
CSlider::Type getSliderType() const
Definition: CSlider.cpp:188
static const char * TypeName[]
Definition: CSlider.h:45
bool setValue(const size_t &index, const CType &value)
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
bool endSaveElement(const std::string &name)
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
unsigned C_INT32 getTickFactor() const
Definition: CSlider.cpp:366
Scale getScaling() const
Definition: CSlider.cpp:369
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveImageElement ( const CLImage image)
private

saves a single image element.

Definition at line 2580 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLImage::getHeight(), CLImage::getImageReference(), CLImage::getWidth(), CLImage::getX(), CLImage::getY(), CLImage::getZ(), CCopasiXMLInterface::saveElement(), saveTransformationAttributes(), and CLRelAbsVector::toString().

Referenced by saveTransformation2D().

2581 {
2582  CXMLAttributeList attributes;
2583  // first we add the attributes for a transformation
2584  saveTransformationAttributes(image, attributes);
2585  // now we add the image specific attributes
2586  attributes.add("x", image.getX().toString());
2587  attributes.add("y", image.getY().toString());
2588 
2589  if (image.getZ() != CLRelAbsVector(0.0, 0.0))
2590  {
2591  attributes.add("z", image.getZ().toString());
2592  }
2593 
2594  attributes.add("width", image.getWidth().toString());
2595  attributes.add("height", image.getHeight().toString());
2596  attributes.add("href", image.getImageReference());
2597  saveElement("Image", attributes);
2598 }
CLRelAbsVector & getX()
Definition: CLImage.cpp:198
const CLRelAbsVector & getHeight() const
Definition: CLImage.cpp:116
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
CLRelAbsVector & getY()
Definition: CLImage.cpp:206
const std::string & getImageReference() const
Definition: CLImage.cpp:132
void saveTransformationAttributes(const CLTransformation2D &transformation, CXMLAttributeList &attributes)
const CLRelAbsVector & getWidth() const
Definition: CLImage.cpp:108
CLRelAbsVector & getZ()
Definition: CLImage.cpp:214
std::string toString() const
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveLayoutList ( )
private

Save the list of layout.

Returns
bool success

Definition at line 1431 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CLGraphicalObject::getBoundingBox(), CLGlyphWithCurve::getCurve(), CLayout::getDimensions(), CLTextGlyph::getGraphicalObjectKey(), CLDimensions::getHeight(), CLayout::getKey(), CLGraphicalObject::getKey(), CLayout::getListOfCompartmentGlyphs(), CLayout::getListOfGeneralGlyphs(), CListOfLayouts::getListOfGlobalRenderInformationObjects(), CLayout::getListOfLocalRenderInformationObjects(), CLayout::getListOfMetaboliteGlyphs(), CLReactionGlyph::getListOfMetabReferenceGlyphs(), CLayout::getListOfReactionGlyphs(), CLayout::getListOfTextGlyphs(), CLMetabReferenceGlyph::getMetabGlyphKey(), CLGraphicalObject::getModelObjectKey(), CLCurve::getNumCurveSegments(), CCopasiObject::getObjectName(), CLGraphicalObject::getObjectRole(), CLMetabReferenceGlyph::getRole(), CLTextGlyph::getText(), CLDimensions::getWidth(), CLGraphicalObject::hasValidModelReference(), haveLayoutList(), CLTextGlyph::isTextSet(), MCXML, mMCXML21Issued, mpLayoutList, saveBoundingBox(), saveCurve(), CCopasiXMLInterface::saveElement(), saveListOfGlobalRenderInformation(), saveListOfLocalRenderInformation(), CLGraphicalObject::setModelObjectKey(), CLTextGlyph::setText(), CCopasiVector< T >::size(), CCopasiXMLInterface::startSaveElement(), CCopasiMessage::WARNING, and CLMetabReferenceGlyph::XMLRole.

Referenced by save().

1432 {
1433  bool success = true;
1434 
1435  if (!haveLayoutList()) return success;
1436 
1437  size_t i, imax = mpLayoutList->size();
1438 
1439  if (!imax) return success;
1440 
1441  CXMLAttributeList Attributes;
1442  CLayout * pLayout = NULL;
1443  Attributes.add("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1444  startSaveElement("ListOfLayouts", Attributes);
1445 
1446  for (i = 0; i < imax; i++)
1447  {
1448  pLayout = (*mpLayoutList)[i];
1449 
1450  Attributes.erase();
1451  Attributes.add("key", pLayout->getKey());
1452  Attributes.add("name", pLayout->getObjectName());
1453  startSaveElement("Layout", Attributes);
1454 
1455  Attributes.erase();
1456  Attributes.add("width", pLayout->getDimensions().getWidth());
1457  Attributes.add("height", pLayout->getDimensions().getHeight());
1458  saveElement("Dimensions", Attributes);
1459 
1460  size_t j, jmax;
1461 
1462  //compartment glyphs
1463  if (pLayout->getListOfCompartmentGlyphs().size() > 0)
1464  {
1465  startSaveElement("ListOfCompartmentGlyphs");
1466 
1467  jmax = pLayout->getListOfCompartmentGlyphs().size();
1468 
1469  for (j = 0; j < jmax; ++j)
1470  {
1471  CLCompartmentGlyph* cg = pLayout->getListOfCompartmentGlyphs()[j];
1472  Attributes.erase();
1473  Attributes.add("key", cg->getKey());
1474  Attributes.add("name", cg->getObjectName());
1475 
1476  if (!cg->getModelObjectKey().empty() && cg->hasValidModelReference())
1477  {
1478  Attributes.add("compartment", cg->getModelObjectKey());
1479  }
1480  else
1481  {
1482  // we set the model reference to the empty string so that
1483  // the warnings message only appears on the first save operation
1484  cg->setModelObjectKey("");
1485 
1486  if (!this->mMCXML21Issued)
1487  {
1489  this->mMCXML21Issued = true;
1490  }
1491 
1492  // Bug 1973: we still write out the attribute, so that older
1493  // versions of COPASI do not refuse to read the model
1494  Attributes.add("metabolite", "");
1495  }
1496 
1497  if (cg->getObjectRole().find_first_not_of(" \t\r\n") != std::string::npos)
1498  {
1499  Attributes.add("objectRole", cg->getObjectRole());
1500  }
1501 
1502  startSaveElement("CompartmentGlyph", Attributes);
1503 
1505 
1506  endSaveElement("CompartmentGlyph");
1507  }
1508 
1509  endSaveElement("ListOfCompartmentGlyphs");
1510  }
1511 
1512  //species glyphs
1513  if (pLayout->getListOfMetaboliteGlyphs().size() > 0)
1514  {
1515  startSaveElement("ListOfMetabGlyphs");
1516 
1517  jmax = pLayout->getListOfMetaboliteGlyphs().size();
1518 
1519  for (j = 0; j < jmax; ++j)
1520  {
1521  CLMetabGlyph* cg = pLayout->getListOfMetaboliteGlyphs()[j];
1522  Attributes.erase();
1523  Attributes.add("key", cg->getKey());
1524  Attributes.add("name", cg->getObjectName());
1525 
1526  if (!cg->getModelObjectKey().empty() && cg->hasValidModelReference())
1527  {
1528  Attributes.add("metabolite", cg->getModelObjectKey());
1529  }
1530  else
1531  {
1532  // we set the model reference to the empty string so that
1533  // the warnings message only appears on the first save operation
1534  cg->setModelObjectKey("");
1535 
1536  if (!this->mMCXML21Issued)
1537  {
1539  this->mMCXML21Issued = true;
1540  }
1541 
1542  // Bug 1973: we still write out the attribute, so that older
1543  // versions of COPASI do not refuse to read the model
1544  Attributes.add("metabolite", "");
1545  }
1546 
1547  if (cg->getObjectRole().find_first_not_of(" \t\r\n") != std::string::npos)
1548  {
1549  Attributes.add("objectRole", cg->getObjectRole());
1550  }
1551 
1552  startSaveElement("MetaboliteGlyph", Attributes);
1553 
1555 
1556  endSaveElement("MetaboliteGlyph");
1557  }
1558 
1559  endSaveElement("ListOfMetabGlyphs");
1560  }
1561 
1562  //reaction glyphs
1563  if (pLayout->getListOfReactionGlyphs().size() > 0)
1564  {
1565  startSaveElement("ListOfReactionGlyphs");
1566 
1567  jmax = pLayout->getListOfReactionGlyphs().size();
1568 
1569  for (j = 0; j < jmax; ++j)
1570  {
1571  CLReactionGlyph* cg = pLayout->getListOfReactionGlyphs()[j];
1572  Attributes.erase();
1573  Attributes.add("key", cg->getKey());
1574  Attributes.add("name", cg->getObjectName());
1575 
1576  if (!cg->getModelObjectKey().empty() && cg->hasValidModelReference())
1577  {
1578  Attributes.add("reaction", cg->getModelObjectKey());
1579  }
1580  else
1581  {
1582  // we set the model reference to the empty string so that
1583  // the warnings message only appears on the first save operation
1584  cg->setModelObjectKey("");
1585 
1586  if (!this->mMCXML21Issued)
1587  {
1589  this->mMCXML21Issued = true;
1590  }
1591  }
1592 
1593  if (cg->getObjectRole().find_first_not_of(" \t\r\n") != std::string::npos)
1594  {
1595  Attributes.add("objectRole", cg->getObjectRole());
1596  }
1597 
1598  startSaveElement("ReactionGlyph", Attributes);
1599 
1600  if (cg->getCurve().getNumCurveSegments() == 0)
1602  else
1603  saveCurve(cg->getCurve());
1604 
1605  // metab reference glyphs
1606  startSaveElement("ListOfMetaboliteReferenceGlyphs");
1607  size_t k, kmax = cg->getListOfMetabReferenceGlyphs().size();
1608 
1609  for (k = 0; k < kmax; ++k)
1610  {
1612  Attributes.erase();
1613  Attributes.add("key", mrg->getKey());
1614  Attributes.add("name", mrg->getObjectName());
1615  Attributes.add("metaboliteGlyph", mrg->getMetabGlyphKey());
1616  //Attributes.add("metaboliteReference", mrg->getXXX());
1617  Attributes.add("role", CLMetabReferenceGlyph::XMLRole[mrg->getRole()]);
1618 
1619  if (mrg->getObjectRole().find_first_not_of(" \t\r\n") != std::string::npos)
1620  {
1621  Attributes.add("objectRole", mrg->getObjectRole());
1622  }
1623 
1624  startSaveElement("MetaboliteReferenceGlyph", Attributes);
1625 
1626  if (mrg->getCurve().getNumCurveSegments() == 0)
1628  else
1629  saveCurve(mrg->getCurve());
1630 
1631  endSaveElement("MetaboliteReferenceGlyph");
1632  }
1633 
1634  endSaveElement("ListOfMetaboliteReferenceGlyphs");
1635 
1636  endSaveElement("ReactionGlyph");
1637  }
1638 
1639  endSaveElement("ListOfReactionGlyphs");
1640  }
1641 
1642  //text Glyphs
1643  if (pLayout->getListOfTextGlyphs().size() > 0)
1644  {
1645  startSaveElement("ListOfTextGlyphs");
1646 
1647  jmax = pLayout->getListOfTextGlyphs().size();
1648 
1649  for (j = 0; j < jmax; ++j)
1650  {
1651  CLTextGlyph* cg = pLayout->getListOfTextGlyphs()[j];
1652  // we only export the text glyph if it either has a text
1653  // or a valid originOfText
1654  std::string id = cg->getModelObjectKey();
1655 
1656  if (cg->isTextSet() || id.find_first_not_of(" \t\r\n") != std::string::npos)
1657  {
1658  Attributes.erase();
1659  Attributes.add("key", cg->getKey());
1660  Attributes.add("name", cg->getObjectName());
1661  Attributes.add("graphicalObject", cg->getGraphicalObjectKey());
1662 
1663  if (cg->isTextSet())
1664  {
1665  Attributes.add("text", cg->getText());
1666  }
1667  else
1668  {
1669  // check if the object actually exists
1670  if (cg->hasValidModelReference())
1671  {
1672  Attributes.add("originOfText", id);
1673  }
1674  else
1675  {
1676  // set the text to unset instead
1677  Attributes.add("text", "unset");
1678  // set the invalid key to the empty string
1679  cg->setModelObjectKey("");
1680  cg->setText("unset");
1681 
1682  if (!this->mMCXML21Issued)
1683  {
1685  this->mMCXML21Issued = true;
1686  }
1687  }
1688  }
1689 
1690  if (cg->getObjectRole().find_first_not_of(" \t\r\n") != std::string::npos)
1691  {
1692  Attributes.add("objectRole", cg->getObjectRole());
1693  }
1694 
1695  startSaveElement("TextGlyph", Attributes);
1696 
1698 
1699  endSaveElement("TextGlyph");
1700  }
1701  }
1702 
1703  endSaveElement("ListOfTextGlyphs");
1704  }
1705 
1706  //additional graphical objects
1707  if (pLayout->getListOfGeneralGlyphs().size() > 0)
1708  {
1709  startSaveElement("ListOfAdditionalGraphicalObjects");
1710 
1711  jmax = pLayout->getListOfGeneralGlyphs().size();
1712 
1713  for (j = 0; j < jmax; ++j)
1714  {
1715  CLGeneralGlyph* cg = pLayout->getListOfGeneralGlyphs()[j];
1716  Attributes.erase();
1717  Attributes.add("key", cg->getKey());
1718  Attributes.add("name", cg->getObjectName());
1719 
1720  if (!cg->getModelObjectKey().empty() && cg->hasValidModelReference())
1721  {
1722  Attributes.add("reference", cg->getModelObjectKey());
1723  }
1724  else
1725  {
1726  // we set the model reference to the empty string so that
1727  // the warnings message only appears on the first save operation
1728  cg->setModelObjectKey("");
1729 
1730  //a general glyph does not necessarily have a model reference.
1731  //so no warning is issued
1732  /*if (!this->mMCXML21Issued)
1733  {
1734  CCopasiMessage(CCopasiMessage::WARNING, MCXML + 21);
1735  this->mMCXML21Issued = true;
1736  }*/
1737  }
1738 
1739  if (cg->getObjectRole().find_first_not_of(" \t\r\n") != std::string::npos)
1740  {
1741  Attributes.add("objectRole", cg->getObjectRole());
1742  }
1743 
1744  startSaveElement("AdditionalGraphicalObject", Attributes);
1745 
1746  //if (cg->getCurve().getNumCurveSegments() == 0)
1748  //else
1749  // saveCurve(cg->getCurve());
1750 
1751  // reference glyphs
1752 
1753  endSaveElement("AdditionalGraphicalObject");
1754  }
1755 
1756  endSaveElement("ListOfAdditionalGraphicalObjects");
1757  }
1758 
1759  // save the local render information
1760  if (pLayout->getListOfLocalRenderInformationObjects().size() > 0)
1761  {
1763  }
1764 
1765  endSaveElement("Layout");
1766  }
1767 
1768  // save the global render information list
1770  {
1772  }
1773 
1774  endSaveElement("ListOfLayouts");
1775 
1776  return success;
1777 }
void saveBoundingBox(const CLBoundingBox &bb)
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
Definition: CLayout.h:120
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
bool isTextSet() const
Definition: CLGlyphs.h:161
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const CLBoundingBox & getBoundingBox() const
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
virtual size_t size() const
virtual std::string getText() const
Definition: CLGlyphs.cpp:238
const std::string & getObjectRole() const
#define MCXML
void saveListOfGlobalRenderInformation(const CCopasiVector< CLGlobalRenderInformation > &list)
const std::string & getMetabGlyphKey() const
void saveListOfLocalRenderInformation(const CCopasiVector< CLLocalRenderInformation > &list)
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
virtual const std::string & getKey() const
void setModelObjectKey(const std::string &k)
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
virtual const std::string & getKey() const
Definition: CLayout.h:71
bool haveLayoutList() const
Definition: CCopasiXML.cpp:386
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
void saveCurve(const CLCurve &c)
const std::string & getModelObjectKey() const
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
void setText(const std::string &t)
Definition: CLGlyphs.cpp:250
bool endSaveElement(const std::string &name)
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
static const std::string XMLRole[]
bool hasValidModelReference() const
bool mMCXML21Issued
Definition: CCopasiXML.h:604
const CLCurve & getCurve() const
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
const std::string & getGraphicalObjectKey() const
Definition: CLGlyphs.h:163
bool add(const std::string &name, const CType &value)
const CLDimensions & getDimensions() const
Definition: CLayout.h:76
const CCopasiVector< CLGlobalRenderInformation > & getListOfGlobalRenderInformationObjects() const
void CCopasiXML::saveLinearGradient ( const CLLinearGradient gradient)
private

Saves a single linear gradient definition.

Definition at line 2114 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CLLinearGradient::getXPoint1(), CLLinearGradient::getXPoint2(), CLLinearGradient::getYPoint1(), CLLinearGradient::getYPoint2(), CLLinearGradient::getZPoint1(), CLLinearGradient::getZPoint2(), saveGradientAttributes(), saveGradientElements(), CCopasiXMLInterface::startSaveElement(), and CLRelAbsVector::toString().

Referenced by saveRenderInformationDefinitionElements().

2115 {
2116  CXMLAttributeList attributes;
2117  // first we create the common attributes
2118  saveGradientAttributes(gradient, attributes);
2119  // now we add the attributes specific to the radial gradient
2120  attributes.add("x1", gradient.getXPoint1().toString());
2121  attributes.add("y1", gradient.getYPoint1().toString());
2122 
2123  if (gradient.getZPoint1() != CLRelAbsVector(0.0, 0.0))
2124  {
2125  attributes.add("z1", gradient.getZPoint1().toString());
2126  }
2127 
2128  attributes.add("x2", gradient.getXPoint2().toString());
2129  attributes.add("y2", gradient.getYPoint2().toString());
2130 
2131  if (gradient.getZPoint2() != CLRelAbsVector(0.0, 0.0))
2132  {
2133  attributes.add("z2", gradient.getZPoint2().toString());
2134  }
2135 
2136  startSaveElement("LinearGradient", attributes);
2137  // save the gradient stops
2138  saveGradientElements(gradient);
2139  endSaveElement("LinearGradient");
2140 }
const CLRelAbsVector & getYPoint1() const
const CLRelAbsVector & getZPoint1() const
void saveGradientElements(const CLGradientBase &gradient)
bool startSaveElement(const std::string &name)
void saveGradientAttributes(const CLGradientBase &gradient, CXMLAttributeList &attributes)
const CLRelAbsVector & getXPoint2() const
const CLRelAbsVector & getZPoint2() const
bool endSaveElement(const std::string &name)
std::string toString() const
const CLRelAbsVector & getYPoint2() const
const CLRelAbsVector & getXPoint1() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveLineEnding ( const CLLineEnding lineEnding)
private

Saves a line ending definiton,

Definition at line 2215 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CLLineEnding::getBoundingBox(), CLLineEnding::getGroup(), CLLineEnding::getId(), CLLineEnding::getIsEnabledRotationalMapping(), saveBoundingBox(), saveGroupElement(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveRenderInformationDefinitionElements().

2216 {
2217  // create the attributes
2218  CXMLAttributeList attributes;
2219  attributes.add("id", lineEnding.getId());
2220  attributes.add("enableRotationalMapping", lineEnding.getIsEnabledRotationalMapping() ? std::string("true") : std::string("false"));
2221  startSaveElement("LineEnding", attributes);
2222  // a line ending has a bounding box
2223  saveBoundingBox(*(lineEnding.getBoundingBox()));
2224  // and a group element
2225  assert(lineEnding.getGroup() != NULL);
2226  saveGroupElement(*lineEnding.getGroup());
2227  endSaveElement("LineEnding");
2228 }
void saveBoundingBox(const CLBoundingBox &bb)
bool startSaveElement(const std::string &name)
void saveGroupElement(const CLGroup &group)
const CLGroup * getGroup() const
const std::string & getId() const
CLBoundingBox * getBoundingBox()
bool endSaveElement(const std::string &name)
bool getIsEnabledRotationalMapping() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveListOfGlobalRenderInformation ( const CCopasiVector< CLGlobalRenderInformation > &  list)
private

Saves the list of global render information objects.

Definition at line 1923 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), saveGlobalRenderInformation(), CCopasiVector< T >::size(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveLayoutList().

1924 {
1925  startSaveElement("ListOfGlobalRenderInformation");
1926  size_t i, iMax = list.size();
1927 
1928  for (i = 0; i < iMax; ++i)
1929  {
1930  saveGlobalRenderInformation(*list[i]);
1931  }
1932 
1933  endSaveElement("ListOfGlobalRenderInformation");
1934 }
bool startSaveElement(const std::string &name)
virtual size_t size() const
bool endSaveElement(const std::string &name)
void saveGlobalRenderInformation(const CLGlobalRenderInformation &renderInfo)
void CCopasiXML::saveListOfLocalRenderInformation ( const CCopasiVector< CLLocalRenderInformation > &  list)
private

Saves the list of local render information objects.

Definition at line 1939 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), saveLocalRenderInformation(), CCopasiVector< T >::size(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveLayoutList().

1940 {
1941  startSaveElement("ListOfRenderInformation");
1942  size_t i, iMax = list.size();
1943 
1944  for (i = 0; i < iMax; ++i)
1945  {
1946  saveLocalRenderInformation(*list[i]);
1947  }
1948 
1949  endSaveElement("ListOfRenderInformation");
1950 }
bool startSaveElement(const std::string &name)
virtual size_t size() const
void saveLocalRenderInformation(const CLLocalRenderInformation &renderInfo)
bool endSaveElement(const std::string &name)
void CCopasiXML::saveLocalRenderInformation ( const CLLocalRenderInformation renderInfo)
private

Saves a single local render information object.

Definition at line 1984 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), CLLocalRenderInformation::getNumStyles(), CLLocalRenderInformation::getStyle(), saveLocalStyle(), saveRenderInformationAttributes(), saveRenderInformationDefinitionElements(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveListOfLocalRenderInformation().

1985 {
1986  // first we create the attributes that are common to all render information objects
1987  CXMLAttributeList attributes;
1988  saveRenderInformationAttributes(renderInfo, attributes);
1989  startSaveElement("RenderInformation", attributes);
1990  // now we save the definition that are the same for all render information objects
1992  // last we save the global styles
1993  size_t i, iMax = renderInfo.getNumStyles();
1994 
1995  if (iMax > 0)
1996  {
1997  startSaveElement("ListOfStyles");
1998 
1999  for (i = 0; i < iMax; ++i)
2000  {
2001  saveLocalStyle(*(dynamic_cast<const CLLocalStyle*>(renderInfo.getStyle(i))));
2002  }
2003 
2004  endSaveElement("ListOfStyles");
2005  }
2006 
2007  endSaveElement("RenderInformation");
2008 }
bool startSaveElement(const std::string &name)
void saveLocalStyle(const CLLocalStyle &style)
CLLocalStyle * getStyle(size_t i)
void saveRenderInformationAttributes(const CLRenderInformationBase &renderInfo, CXMLAttributeList &attributes)
bool endSaveElement(const std::string &name)
void saveRenderInformationDefinitionElements(const CLRenderInformationBase &renderInfo)
void CCopasiXML::saveLocalStyle ( const CLLocalStyle style)
private

Saves a single local style element.

Definition at line 2233 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLStyle::createStringFromSet(), CCopasiXMLInterface::endSaveElement(), CLLocalStyle::getKeyList(), CLLocalStyle::getNumKeys(), saveStyleAttributes(), saveStyleElements(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveLocalRenderInformation().

2234 {
2235  // first we create the attributes
2236  CXMLAttributeList attributes;
2237  saveStyleAttributes(style, attributes);
2238 
2239  // now we add the attributes that are specific to local styles
2240  if (style.getNumKeys() > 0)
2241  {
2242  attributes.add("keyList", CLStyle::createStringFromSet(style.getKeyList()));
2243  }
2244 
2245  startSaveElement("Style", attributes);
2246  saveStyleElements(style);
2247  endSaveElement("Style");
2248 }
bool startSaveElement(const std::string &name)
const std::set< std::string > & getKeyList() const
void saveStyleAttributes(const CLStyle &style, CXMLAttributeList &attributes)
size_t getNumKeys() const
void saveStyleElements(const CLStyle &style)
bool endSaveElement(const std::string &name)
static std::string createStringFromSet(const std::set< std::string > &set)
Definition: CLStyle.cpp:182
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveModel ( )
private

Save the model.

Returns
bool success

Definition at line 395 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CModelParameterGroup::begin(), CCopasiVector< T >::begin(), CModelParameterGroup::end(), CCopasiVector< T >::end(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CModelEntity::FIXED, CModel::getAreaUnitName(), CEvent::getAssignments(), CModel::getAvogadro(), CReaction::getChemEq(), CMetab::getCompartment(), CModel::getCompartments(), CEvent::getDelayAssignment(), CEvent::getDelayExpression(), CCompartment::getDimensionality(), CStateTemplate::getEntities(), CModel::getEvents(), CModelEntity::getExpression(), CEvent::getFireAtInitialTime(), CReaction::getFunction(), CReaction::getFunctionParameters(), CModelEntity::getInitialExpression(), CModelParameterSet::getKey(), CFunction::getKey(), CModelEntity::getKey(), CReaction::getKey(), CEvent::getKey(), CCopasiParameterGroup::getKey(), CModel::getKey(), CModel::getLengthUnitName(), CModel::getMetabolites(), CModel::getModelParameterSet(), CModel::getModelParameterSets(), CModel::getModelType(), CModel::getModelValues(), CChemEq::getModifiers(), CCopasiParameterGroup::getName(), CCopasiObject::getObjectName(), CReaction::getParameterMappings(), CReaction::getParameters(), CEvent::getPersistentTrigger(), CChemEq::getProducts(), CModel::getQuantityUnitName(), CModel::getReactions(), CModelEntity::getSBMLId(), CEvent::getSBMLId(), CReaction::getSBMLId(), CModel::getStateTemplate(), CModelEntity::getStatus(), CChemEq::getSubstrates(), CModel::getTimeUnitName(), CEvent::getTriggerExpression(), CCopasiRootContainer::getUndefinedFunction(), CCopasiParameterGroup::getValue(), CModel::getVolumeUnitName(), haveModel(), CReaction::isFast(), CReaction::isReversible(), CCopasiXMLInterface::mIndent, CModel::ModelTypeNames, mpModel, CCopasiXMLInterface::mpOstream, mSBMLReference, CCopasiParameter::Value::pDOUBLE, CModelEntity::REACTIONS, saveAnnotation(), CCopasiXMLInterface::saveData(), CCopasiXMLInterface::saveElement(), saveModelParameter(), CXMLAttributeList::setValue(), CFunctionParameters::size(), CStateTemplate::size(), CCopasiVector< T >::size(), CCopasiParameterGroup::size(), CXMLAttributeList::skip(), CCopasiXMLInterface::startSaveElement(), and CModelEntity::XMLStatus.

Referenced by save().

396 {
397  bool success = true;
398 
399  if (!haveModel()) return success;
400 
401  CXMLAttributeList Attributes;
402  Attributes.add("key", mpModel->getKey());
403  Attributes.add("name", mpModel->getObjectName());
404  Attributes.add("simulationType", CModelEntity::XMLStatus[mpModel->getStatus()]);
405  Attributes.add("timeUnit", mpModel->getTimeUnitName());
406  Attributes.add("volumeUnit", mpModel->getVolumeUnitName());
407  Attributes.add("areaUnit", mpModel->getAreaUnitName());
408  Attributes.add("lengthUnit", mpModel->getLengthUnitName());
409  Attributes.add("quantityUnit", mpModel->getQuantityUnitName());
410  Attributes.add("type", CModel::ModelTypeNames[mpModel->getModelType()]);
411  Attributes.add("avogadroConstant", mpModel->getAvogadro());
412 
413  // This is now optional
414  // Attributes.add("stateVariable",
415  // mpModel->getStateTemplate().getKey(mpModel->getKey()));
416 
417  startSaveElement("Model", Attributes);
418 
420 
421  if (mpModel->getInitialExpression() != "")
422  {
423  startSaveElement("InitialExpression");
425  endSaveElement("InitialExpression");
426  }
427 
428  size_t i, imax;
429 
430  // Compartment
431  if ((imax = mpModel->getCompartments().size()) > 0)
432  {
433  startSaveElement("ListOfCompartments");
434 
435  Attributes.erase();
436  Attributes.add("key", "");
437  Attributes.add("name", "");
438  Attributes.add("simulationType", "");
439  Attributes.add("dimensionality", "");
440 
441  size_t i, imax = mpModel->getCompartments().size();
442 
443  for (i = 0; i < imax; i++)
444  {
445  CCompartment * pComp = mpModel->getCompartments()[i];
446 
447  Attributes.setValue(0, pComp->getKey());
448  Attributes.setValue(1, pComp->getObjectName());
449  CModelEntity::Status SimulationType = pComp->getStatus();
450  Attributes.setValue(2, CModelEntity::XMLStatus[SimulationType]);
451  Attributes.setValue(3, pComp->getDimensionality());
452 
453  startSaveElement("Compartment", Attributes);
454 
455  saveAnnotation(pComp);
456 
457  if (SimulationType != CModelEntity::FIXED &&
458  pComp->getExpression() != "")
459  {
460  startSaveElement("Expression");
461  saveData(pComp->getExpression());
462  endSaveElement("Expression");
463  }
464 
465  if (pComp->getInitialExpression() != "")
466  {
467  startSaveElement("InitialExpression");
468  saveData(pComp->getInitialExpression());
469  endSaveElement("InitialExpression");
470  }
471 
472  endSaveElement("Compartment");
473 
474  if (pComp->getSBMLId() != "")
475  mSBMLReference[pComp->getSBMLId()] = pComp->getKey();
476  }
477 
478  endSaveElement("ListOfCompartments");
479  }
480 
481  // Metabolites (aka. Species)
482  if ((imax = mpModel->getMetabolites().size()) > 0)
483  {
484  startSaveElement("ListOfMetabolites");
485 
486  Attributes.erase();
487  Attributes.add("key", "");
488  Attributes.add("name", "");
489  Attributes.add("simulationType", "");
490  Attributes.add("compartment", "");
491 
492  for (i = 0; i < imax; i++)
493  {
494  CMetab * pMetab = mpModel->getMetabolites()[i];
495 
496  Attributes.setValue(0, pMetab->getKey());
497  Attributes.setValue(1, pMetab->getObjectName());
498  CModelEntity::Status SimulationType = pMetab->getStatus();
499  Attributes.setValue(2, CModelEntity::XMLStatus[SimulationType]);
500  Attributes.setValue(3, pMetab->getCompartment()->getKey());
501 
502  startSaveElement("Metabolite", Attributes);
503 
504  saveAnnotation(pMetab);
505 
506  if (SimulationType != CModelEntity::FIXED &&
507  SimulationType != CModelEntity::REACTIONS &&
508  pMetab->getExpression() != "")
509  {
510  startSaveElement("Expression");
511  saveData(pMetab->getExpression());
512  endSaveElement("Expression");
513  }
514 
515  if (pMetab->getInitialExpression() != "")
516  {
517  startSaveElement("InitialExpression");
518  saveData(pMetab->getInitialExpression());
519  endSaveElement("InitialExpression");
520  }
521 
522  endSaveElement("Metabolite");
523 
524  if (pMetab->getSBMLId() != "")
525  mSBMLReference[pMetab->getSBMLId()] = pMetab->getKey();
526  }
527 
528  endSaveElement("ListOfMetabolites");
529  }
530 
531  // Model Values (aka. Global Quantities)
532  if ((imax = mpModel->getModelValues().size()) > 0)
533  {
534  startSaveElement("ListOfModelValues");
535 
536  Attributes.erase();
537  Attributes.add("key", "");
538  Attributes.add("name", "");
539  Attributes.add("simulationType", "");
540 
541  for (i = 0; i < imax; i++)
542  {
543  CModelValue * pMV = mpModel->getModelValues()[i];
544 
545  Attributes.setValue(0, pMV->getKey());
546  Attributes.setValue(1, pMV->getObjectName());
547  CModelEntity::Status SimulationType = pMV->getStatus();
548  Attributes.setValue(2, CModelEntity::XMLStatus[SimulationType]);
549 
550  startSaveElement("ModelValue", Attributes);
551 
552  saveAnnotation(pMV);
553 
554  if (SimulationType != CModelEntity::FIXED &&
555  pMV->getExpression() != "")
556  {
557  startSaveElement("Expression");
558  saveData(pMV->getExpression());
559  endSaveElement("Expression");
560  }
561 
562  if (pMV->getInitialExpression() != "")
563  {
564  startSaveElement("InitialExpression");
566  endSaveElement("InitialExpression");
567  }
568 
569  endSaveElement("ModelValue");
570 
571  if (pMV->getSBMLId() != "")
572  mSBMLReference[pMV->getSBMLId()] = pMV->getKey();
573  }
574 
575  endSaveElement("ListOfModelValues");
576  }
577 
578  // Reactions
579  if ((imax = mpModel->getReactions().size()) > 0)
580  {
581  startSaveElement("ListOfReactions");
582 
583  CXMLAttributeList Attr;
584  const CCopasiVector< CChemEqElement > * pReactantList;
585  size_t j, jmax;
586 
587  std::vector< const CCopasiObject * > ObjectList;
588  size_t k, kmax;
589 
590  Attributes.erase();
591  Attributes.add("key", "");
592  Attributes.add("name", "");
593  Attributes.add("reversible", "");
594  Attributes.add("fast", "");
595 
596  for (i = 0; i < imax; i++)
597  {
598  CReaction * pReaction = mpModel->getReactions()[i];
599 
600  Attributes.setValue(0, pReaction->getKey());
601  Attributes.setValue(1, pReaction->getObjectName());
602  Attributes.setValue(2, pReaction->isReversible() ? "true" : "false");
603  Attributes.setValue(3, pReaction->isFast() ? "true" : "false");
604 
605  if (pReaction->getSBMLId() != "")
606  mSBMLReference[pReaction->getSBMLId()] = pReaction->getKey();
607 
608  startSaveElement("Reaction", Attributes);
609 
610  saveAnnotation(pReaction);
611 
612  Attr.erase();
613  Attr.add("metabolite", "");
614  Attr.add("stoichiometry", "");
615 
616  pReactantList = & pReaction->getChemEq().getSubstrates();
617 
618  if ((jmax = pReactantList->size()) > 0)
619  {
620  startSaveElement("ListOfSubstrates");
621 
622  for (j = 0; j < jmax; j++)
623  {
624  Attr.setValue(0, (*pReactantList)[j]->getMetaboliteKey());
625  Attr.setValue(1, (*pReactantList)[j]->getMultiplicity());
626 
627  saveElement("Substrate", Attr);
628  }
629 
630  endSaveElement("ListOfSubstrates");
631  }
632 
633  //startSaveElement("ListOfProducts"); // this seems to belong further down
634 
635  pReactantList = & pReaction->getChemEq().getProducts();
636 
637  if ((jmax = pReactantList->size()) > 0)
638  {
639  startSaveElement("ListOfProducts"); //this seems to belong here
640 
641  for (j = 0; j < jmax; j++)
642  {
643  Attr.setValue(0, (*pReactantList)[j]->getMetaboliteKey());
644  Attr.setValue(1, (*pReactantList)[j]->getMultiplicity());
645 
646  saveElement("Product", Attr);
647  }
648 
649  endSaveElement("ListOfProducts");
650  }
651 
652  pReactantList = & pReaction->getChemEq().getModifiers();
653 
654  if ((jmax = pReactantList->size()) > 0)
655  {
656  startSaveElement("ListOfModifiers");
657 
658  for (j = 0, jmax = pReactantList->size(); j < jmax; j++)
659  {
660  Attr.setValue(0, (*pReactantList)[j]->getMetaboliteKey());
661  Attr.setValue(1, (*pReactantList)[j]->getMultiplicity());
662 
663  saveElement("Modifier", Attr);
664  }
665 
666  endSaveElement("ListOfModifiers");
667  }
668 
669  const CCopasiParameterGroup * pParamList;
670 
671  pParamList = & pReaction->getParameters();
672 
673  if ((jmax = pParamList->size()) > 0)
674  {
675  startSaveElement("ListOfConstants");
676 
677  Attr.erase();
678  Attr.add("key", "");
679  Attr.add("name", "");
680  Attr.add("value", "");
681 
682  for (j = 0; j < jmax; j++)
683  {
684  Attr.setValue(0, pParamList->getKey(j));
685  Attr.setValue(1, pParamList->getName(j));
686  Attr.setValue(2, * pParamList->getValue(j).pDOUBLE);
687 
688  saveElement("Constant", Attr);
689  }
690 
691  endSaveElement("ListOfConstants");
692  }
693 
695  {
696  Attr.erase();
697  Attr.add("function", pReaction->getFunction()->getKey());
698  startSaveElement("KineticLaw", Attr);
699 
700  if ((jmax = pReaction->getFunctionParameters().size()))
701  {
702  startSaveElement("ListOfCallParameters");
703  const std::vector< std::vector<std::string> > & rMap =
704  pReaction->getParameterMappings();
705 
706  for (j = 0; j < jmax; j++)
707  {
708  Attr.erase();
709  Attr.add("functionParameter",
710  pReaction->
711  getFunction()->getVariables()[j]->getKey());
712 
713  startSaveElement("CallParameter", Attr);
714 
715  Attr.erase();
716  Attr.add("reference", "");
717 
718  for (k = 0, kmax = rMap[j].size(); k < kmax; k++)
719  {
720  Attr.setValue(0, rMap[j][k]);
721  saveElement("SourceParameter", Attr);
722  }
723 
724  endSaveElement("CallParameter");
725  }
726 
727  endSaveElement("ListOfCallParameters");
728  }
729 
730  endSaveElement("KineticLaw");
731  }
732 
733  endSaveElement("Reaction");
734  }
735 
736  endSaveElement("ListOfReactions");
737  }
738 
739  // Events (added 07.04.08)
740  if ((imax = mpModel->getEvents().size()) > 0)
741  {
742  startSaveElement("ListOfEvents");
743 
744  Attributes.erase();
745  Attributes.add("key", "");
746  Attributes.add("name", "");
747  Attributes.add("delayAssignment", "");
748  Attributes.add("fireAtInitialTime", "");
749  Attributes.add("persistentTrigger", "");
750 
751  for (i = 0; i < imax; i++)
752  {
753  CEvent * pEvent = mpModel->getEvents()[i];
754 
755  Attributes.setValue(0, pEvent->getKey());
756  Attributes.setValue(1, pEvent->getObjectName());
757 
758  if (pEvent->getDelayExpression() != "")
759  {
760  Attributes.setValue(2, pEvent->getDelayAssignment() ? "true" : "false");
761  }
762  else
763  {
764  Attributes.skip(2);
765  }
766 
767  Attributes.setValue(3, pEvent->getFireAtInitialTime());
768  Attributes.setValue(4, pEvent->getPersistentTrigger());
769 
770  startSaveElement("Event", Attributes);
771 
772  saveAnnotation(pEvent);
773 
774  if (pEvent->getTriggerExpression() != "")
775  {
776  startSaveElement("TriggerExpression");
777  saveData(pEvent->getTriggerExpression());
778  endSaveElement("TriggerExpression");
779  }
780 
781  if (pEvent->getDelayExpression() != "")
782  {
783  startSaveElement("DelayExpression");
784  saveData(pEvent->getDelayExpression());
785  endSaveElement("DelayExpression");
786  }
787 
788  const CCopasiVectorN< CEventAssignment > & Assignments = pEvent->getAssignments();
789 
790  if (Assignments.size() > 0)
791  {
792  startSaveElement("ListOfAssignments");
793 
794  CXMLAttributeList Attr;
795  Attr.add("targetKey", "");
796 
799 
800  for (; it != end; ++it)
801  {
802  Attr.setValue(0, (*it)->getTargetKey());
803 
804  startSaveElement("Assignment", Attr);
805 
806  startSaveElement("Expression");
807  saveData((*it)->getExpression());
808  endSaveElement("Expression");
809 
810  endSaveElement("Assignment");
811  }
812 
813  endSaveElement("ListOfAssignments");
814  }
815 
816  endSaveElement("Event");
817 
818  if (pEvent->getSBMLId() != "")
819  mSBMLReference[pEvent->getSBMLId()] = pEvent->getKey();
820  }
821 
822  endSaveElement("ListOfEvents");
823  }
824 
825  // Save the model parameter sets
826  Attributes.erase();
827  const CModelParameterSet * pSet = & mpModel->getModelParameterSet();
828  Attributes.add("activeSet", pSet->getKey());
829 
830  startSaveElement("ListOfModelParameterSets", Attributes);
831 
832  Attributes.erase();
833  Attributes.add("key", "");
834  Attributes.add("name", "");
835 
836  pSet = & mpModel->getModelParameterSet();
837 
838  Attributes.setValue(0, pSet->getKey());
839  Attributes.setValue(1, pSet->getObjectName());
840 
841  startSaveElement("ModelParameterSet", Attributes);
842 
843  saveAnnotation(pSet);
844 
846  CModelParameterGroup::const_iterator endSet = pSet->end();
847 
848  for (; itSet != endSet; ++itSet)
849  {
850  saveModelParameter(*itSet);
851  }
852 
853  endSaveElement("ModelParameterSet");
854 
855  imax = mpModel->getModelParameterSets().size();
856 
857  for (i = 0; i < imax; i++)
858  {
859  pSet = mpModel->getModelParameterSets()[i];
860 
861  Attributes.setValue(0, pSet->getKey());
862  Attributes.setValue(1, pSet->getObjectName());
863 
864  startSaveElement("ModelParameterSet", Attributes);
865 
866  saveAnnotation(pSet);
867 
868  itSet = pSet->begin();
869  endSet = pSet->end();
870 
871  for (; itSet != endSet; ++itSet)
872  {
873  saveModelParameter(*itSet);
874  }
875 
876  endSaveElement("ModelParameterSet");
877  }
878 
879  endSaveElement("ListOfModelParameterSets");
880 
881  // The State an state Template is only save for backwards compatibility
882  startSaveElement("StateTemplate");
883 
884  Attributes.erase();
885  // This is now optional.
886  // Attributes.add("key", "");
887  Attributes.add("objectReference", "");
888  std::pair< std::string, std::string > Variable;
889 
890  CModelEntity *const* ppEntity = mpModel->getStateTemplate().getEntities();
891  CModelEntity *const* ppEntityEnd = ppEntity + mpModel->getStateTemplate().size();
892 
893  for (; ppEntity != ppEntityEnd; ++ppEntity)
894  {
895  Attributes.setValue(0, (*ppEntity)->getKey());
896 
897  saveElement("StateTemplateVariable", Attributes);
898  }
899 
900  endSaveElement("StateTemplate");
901 
902  Attributes.erase();
903  Attributes.add("type", "initialState");
904  startSaveElement("InitialState", Attributes);
905  *mpOstream << mIndent;
906  ppEntity = mpModel->getStateTemplate().getEntities();
907 
908  for (; ppEntity != ppEntityEnd; ++ppEntity)
909  {
910  *mpOstream << (DBL)(*ppEntity)->getInitialValue() << " ";
911  }
912 
913  *mpOstream << std::endl;
914 
915  endSaveElement("InitialState");
916 
917  endSaveElement("Model");
918 
919  return success;
920 }
Definition: CEvent.h:152
const C_FLOAT64 & getAvogadro() const
Definition: CModel.cpp:2349
const CCopasiVectorN< CEventAssignment > & getAssignments() const
Definition: CEvent.cpp:678
static const char * ModelTypeNames[]
Definition: CModel.h:117
const CModelParameterSet & getModelParameterSet() const
Definition: CModel.cpp:1072
const bool & getDelayAssignment() const
Definition: CEvent.cpp:419
virtual const std::string & getName(const size_t &index) const
static CFunction * getUndefinedFunction()
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const std::string & getSBMLId() const
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
unsigned C_INT32 getDimensionality() const
virtual size_t size() const
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
bool saveData(const std::string &data)
iterator begin()
std::string getTimeUnitName() const
Definition: CModel.cpp:2238
std::string getExpression() const
bool haveModel() const
Definition: CCopasiXML.cpp:262
std::string getTriggerExpression() const
Definition: CEvent.cpp:524
Definition: CMetab.h:178
const size_t & size() const
Definition: CState.cpp:242
const std::string & getKey() const
Definition: CFunction.cpp:58
std::string getKey(const std::string &name) const
bool skip(const size_t &index)
const std::string & getSBMLId() const
Definition: CReaction.cpp:1654
bool setValue(const size_t &index, const CType &value)
const CCopasiVector< CChemEqElement > & getProducts() const
Definition: CChemEq.cpp:63
bool saveAnnotation(const CAnnotation *pAnnotation)
Definition: CCopasiXML.cpp:922
const bool & getPersistentTrigger() const
Definition: CEvent.cpp:439
const CFunction * getFunction() const
Definition: CReaction.cpp:252
iterator end()
const CFunctionParameters & getFunctionParameters() const
Definition: CReaction.cpp:576
virtual const std::string & getKey() const
virtual const std::string & getKey() const
std::string getInitialExpression() const
std::string getLengthUnitName() const
Definition: CModel.cpp:2215
std::map< std::string, std::string > mSBMLReference
Definition: CCopasiXML.h:594
const CCopasiVectorN< CModelParameterSet > & getModelParameterSets() const
Definition: CModel.cpp:1066
const CCopasiVector< CChemEqElement > & getSubstrates() const
Definition: CChemEq.cpp:60
const std::string & getKey() const
Definition: CModel.cpp:1142
bool isReversible() const
Definition: CReaction.cpp:229
static const char * XMLStatus[]
Definition: CModelValue.h:72
std::string getDelayExpression() const
Definition: CEvent.cpp:591
const bool & isFast() const
Definition: CReaction.cpp:1712
std::string getAreaUnitName() const
Definition: CModel.cpp:2193
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::string getQuantityUnitName() const
Definition: CModel.cpp:2321
const CCopasiVector< CChemEqElement > & getModifiers() const
Definition: CChemEq.cpp:66
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
std::vector< CModelParameter * >::const_iterator const_iterator
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
bool endSaveElement(const std::string &name)
const ModelType & getModelType() const
Definition: CModel.cpp:2339
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
const CCopasiParameter::Value & getValue(const std::string &name) const
const std::string & getSBMLId() const
Definition: CEvent.cpp:403
const bool & getFireAtInitialTime() const
Definition: CEvent.cpp:429
const CModelEntity::Status & getStatus() const
std::string getVolumeUnitName() const
Definition: CModel.cpp:2170
CModel * mpModel
Definition: CCopasiXML.h:553
const std::vector< std::vector< std::string > > & getParameterMappings() const
Definition: CReaction.h:285
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
virtual const std::string & getKey() const
Definition: CEvent.cpp:287
bool saveModelParameter(const CModelParameter *pModelParameter)
Definition: CCopasiXML.cpp:963
bool add(const std::string &name, const CType &value)
CModelEntity ** getEntities()
Definition: CState.cpp:204
bool CCopasiXML::saveModelParameter ( const CModelParameter pModelParameter)
private

Save a model parameter

Parameters
constCModelParameter * pModelParameter
Returns
bool success

Definition at line 963 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CModelParameter::getCN(), CModelParameter::getCompareResult(), CModelParameter::getInitialExpression(), CModelParameter::getSimulationType(), CModelParameter::getType(), CModelParameter::getValue(), CModelParameter::Group, CModelParameter::Missing, CModelParameter::ParticleNumbers, CModelParameter::Reaction, CCopasiXMLInterface::saveData(), CCopasiXMLInterface::saveElement(), CCopasiXMLInterface::startSaveElement(), CModelParameter::TypeNames, and CModelEntity::XMLStatus.

Referenced by saveModel().

964 {
965  // We do not save model parameters which are marked missing to preserve
966  // their missing state.
967  if (pModelParameter->getCompareResult() == CModelParameter::Missing)
968  {
969  return true;
970  }
971 
972  bool success = true;
973 
974  CXMLAttributeList Attributes;
975 
976  if (pModelParameter->getType() != CModelParameter::Reaction &&
977  pModelParameter->getType() != CModelParameter::Group)
978  {
979  Attributes.add("cn", pModelParameter->getCN());
980  Attributes.add("value", pModelParameter->getValue(CModelParameter::ParticleNumbers));
981  Attributes.add("type", CModelParameter::TypeNames[pModelParameter->getType()]);
982  Attributes.add("simulationType", CModelEntity::XMLStatus[pModelParameter->getSimulationType()]);
983 
984  if (pModelParameter->getInitialExpression() != "")
985  {
986  startSaveElement("ModelParameter", Attributes);
987  startSaveElement("InitialExpression");
988  saveData(pModelParameter->getInitialExpression());
989  endSaveElement("InitialExpression");
990  endSaveElement("ModelParameter");
991  }
992  else
993  {
994  saveElement("ModelParameter", Attributes);
995  }
996  }
997  else
998  {
999  Attributes.add("cn", pModelParameter->getCN());
1000  Attributes.add("type", CModelParameter::TypeNames[pModelParameter->getType()]);
1001 
1002  startSaveElement("ModelParameterGroup", Attributes);
1003 
1004  CModelParameterGroup::const_iterator it = static_cast< const CModelParameterGroup * >(pModelParameter)->begin();
1005  CModelParameterGroup::const_iterator end = static_cast< const CModelParameterGroup * >(pModelParameter)->end();
1006 
1007  for (; it != end; ++it)
1008  {
1009  success &= saveModelParameter(*it);
1010  }
1011 
1012  endSaveElement("ModelParameterGroup");
1013  }
1014 
1015  return success;
1016 }
std::string getInitialExpression() const
const CompareResult & getCompareResult() const
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
bool startSaveElement(const std::string &name)
bool saveData(const std::string &data)
static const char * TypeNames[]
const CCopasiObjectName & getCN() const
virtual const double & getValue(const Framework &framework) const
static const char * XMLStatus[]
Definition: CModelValue.h:72
const CModelEntity::Status & getSimulationType() const
std::vector< CModelParameter * >::const_iterator const_iterator
bool endSaveElement(const std::string &name)
const Type & getType() const
bool saveModelParameter(const CModelParameter *pModelParameter)
Definition: CCopasiXML.cpp:963
bool add(const std::string &name, const CType &value)
bool CCopasiXML::savePlotList ( )
private

Save the list of plots.

Returns
bool success

Definition at line 1106 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CPlotItem::getChannels(), CPlotSpecification::getItems(), CPlotItem::getNumChannels(), CCopasiObject::getObjectName(), CPlotItem::getType(), havePlotList(), CPlotSpecification::isActive(), CPlotDataChannelSpec::max, CPlotDataChannelSpec::maxAutoscale, CPlotDataChannelSpec::min, CPlotDataChannelSpec::minAutoscale, mpPlotList, CCopasiXMLInterface::saveElement(), CCopasiXMLInterface::saveParameterGroup(), CCopasiVector< T >::size(), CCopasiXMLInterface::startSaveElement(), and CPlotItem::XMLType.

Referenced by save().

1107 {
1108  //std::cerr << "Saving plot list. " << std::endl;
1109  bool success = true;
1110 
1111  if (!havePlotList())
1112  {
1113  //std::cerr << "No plot list defined." << std::endl;
1114  return success;
1115  }
1116 
1117  size_t i, imax = mpPlotList->size();
1118 
1119  //std::cerr << "Saving " << imax << " plots." << std::endl;
1120  if (!imax) return success;
1121 
1122  CXMLAttributeList Attributes;
1123 
1124  startSaveElement("ListOfPlots");
1125 
1126  for (i = 0; i < imax; i++)
1127  {
1128  const CPlotSpecification* pPlot = (*mpPlotList)[i];
1129 
1130  Attributes.erase();
1131  Attributes.add("name", pPlot->getObjectName());
1132  Attributes.add("type", CPlotSpecification::XMLType[pPlot->getType()]);
1133  Attributes.add("active", pPlot->isActive());
1134  startSaveElement("PlotSpecification", Attributes);
1135  saveParameterGroup(* pPlot->CCopasiParameter::getValue().pGROUP);
1136  startSaveElement("ListOfPlotItems");
1137  size_t j, jmax = pPlot->getItems().size();
1138 
1139  //std::cerr << "Saving " << jmax << "PlotItems." << std::endl;
1140  for (j = 0; j < jmax; j++)
1141  {
1142  const CPlotItem* pPlotItem = pPlot->getItems()[j];
1143  Attributes.erase();
1144  Attributes.add("name", pPlotItem->getObjectName());
1145  Attributes.add("type", CPlotItem::XMLType[pPlotItem->getType()]);
1146  startSaveElement("PlotItem", Attributes);
1147  saveParameterGroup(* pPlotItem->CCopasiParameter::getValue().pGROUP);
1148  startSaveElement("ListOfChannels");
1149  size_t k, kmax = pPlotItem->getNumChannels();
1150 
1151  //std::cerr << "Saving " << kmax << " Channels." << std::endl;
1152  for (k = 0; k < kmax; k++)
1153  {
1154  const CPlotDataChannelSpec pDataChannelSpec = pPlotItem->getChannels()[k];
1155  Attributes.erase();
1156  Attributes.add("cn", pDataChannelSpec);
1157 
1158  if (!pDataChannelSpec.minAutoscale)
1159  {
1160  Attributes.add("min", pDataChannelSpec.min);
1161  }
1162 
1163  if (!pDataChannelSpec.maxAutoscale)
1164  {
1165  Attributes.add("max", pDataChannelSpec.max);
1166  }
1167 
1168  saveElement("ChannelSpec", Attributes);
1169  }
1170 
1171  endSaveElement("ListOfChannels");
1172  endSaveElement("PlotItem");
1173  }
1174 
1175  endSaveElement("ListOfPlotItems");
1176  endSaveElement("PlotSpecification");
1177  }
1178 
1179  endSaveElement("ListOfPlots");
1180  return success;
1181 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
virtual size_t size() const
bool saveParameterGroup(const std::vector< CCopasiParameter * > &group)
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
size_t getNumChannels() const
Definition: CPlotItem.cpp:220
const bool & isActive() const
bool havePlotList() const
Definition: CCopasiXML.cpp:328
static const char * XMLType[]
Definition: CPlotItem.h:104
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
const CCopasiVector< CPlotItem > & getItems() const
bool endSaveElement(const std::string &name)
bool add(const std::string &name, const CType &value)
void CCopasiXML::savePolygonElement ( const CLPolygon polygon)
private

saves a single image element.

Definition at line 2690 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), CLPolygon::getListOfElements(), save2DAttributes(), saveCurveElements(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveTransformation2D().

2691 {
2692  CXMLAttributeList attributes;
2693  // first we add the attributes for a 2D object
2694  save2DAttributes(polygon, attributes);
2695  startSaveElement("Polygon", attributes);
2697  endSaveElement("Polygon");
2698 }
void saveCurveElements(const std::vector< CLRenderPoint * > &curveElements)
bool startSaveElement(const std::string &name)
void save2DAttributes(const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
bool endSaveElement(const std::string &name)
std::vector< CLRenderPoint * > * getListOfElements()
Definition: CLPolygon.cpp:108
void CCopasiXML::savePosition ( const CLPoint p,
const std::string &  tag = "Position" 
)
private

Definition at line 1364 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CXMLAttributeList::erase(), CLPoint::getX(), CLPoint::getY(), and CCopasiXMLInterface::saveElement().

Referenced by saveBoundingBox(), and saveCurve().

1365 {
1366  CXMLAttributeList Attributes;
1367  Attributes.erase();
1368  Attributes.add("x", p.getX());
1369  Attributes.add("y", p.getY());
1370  saveElement(tag, Attributes);
1371 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveRadialGradient ( const CLRadialGradient gradient)
private

Saves a single radial gradient definition.

Definition at line 2145 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CLRadialGradient::getCenterX(), CLRadialGradient::getCenterY(), CLRadialGradient::getCenterZ(), CLRadialGradient::getFocalPointX(), CLRadialGradient::getFocalPointY(), CLRadialGradient::getFocalPointZ(), CLRadialGradient::getRadius(), saveGradientAttributes(), saveGradientElements(), CCopasiXMLInterface::startSaveElement(), and CLRelAbsVector::toString().

Referenced by saveRenderInformationDefinitionElements().

2146 {
2147  CXMLAttributeList attributes;
2148  // first we create the common attributes
2149  saveGradientAttributes(gradient, attributes);
2150  // now we add the attributes specific to the radial gradient
2151  attributes.add("cx", gradient.getCenterX().toString());
2152  attributes.add("cy", gradient.getCenterY().toString());
2153  attributes.add("cz", gradient.getCenterZ().toString());
2154  attributes.add("r", gradient.getRadius().toString());
2155  attributes.add("fx", gradient.getFocalPointX().toString());
2156  attributes.add("fy", gradient.getFocalPointY().toString());
2157  attributes.add("fz", gradient.getFocalPointZ().toString());
2158  startSaveElement("RadialGradient", attributes);
2159  // save the gradient stops
2160  saveGradientElements(gradient);
2161  endSaveElement("RadialGradient");
2162 }
const CLRelAbsVector & getRadius() const
const CLRelAbsVector & getCenterY() const
const CLRelAbsVector & getCenterX() const
void saveGradientElements(const CLGradientBase &gradient)
bool startSaveElement(const std::string &name)
void saveGradientAttributes(const CLGradientBase &gradient, CXMLAttributeList &attributes)
const CLRelAbsVector & getCenterZ() const
const CLRelAbsVector & getFocalPointY() const
bool endSaveElement(const std::string &name)
std::string toString() const
const CLRelAbsVector & getFocalPointX() const
bool add(const std::string &name, const CType &value)
const CLRelAbsVector & getFocalPointZ() const
void CCopasiXML::saveRectangleElement ( const CLRectangle rectangle)
private

saves a single rectangle element.

Definition at line 2603 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLRectangle::getHeight(), CLRectangle::getRadiusX(), CLRectangle::getRadiusY(), CLRectangle::getWidth(), CLRectangle::getX(), CLRectangle::getY(), CLRectangle::getZ(), save2DAttributes(), CCopasiXMLInterface::saveElement(), and CLRelAbsVector::toString().

Referenced by saveTransformation2D().

2604 {
2605  CXMLAttributeList attributes;
2606  // first we add the attributes for a 2D object
2607  save2DAttributes(rectangle, attributes);
2608  // now we add the rectangle specific attributes
2609  attributes.add("x", rectangle.getX().toString());
2610  attributes.add("y", rectangle.getY().toString());
2611 
2612  if (rectangle.getZ() != CLRelAbsVector(0.0, 0.0))
2613  {
2614  attributes.add("z", rectangle.getZ().toString());
2615  }
2616 
2617  attributes.add("width", rectangle.getWidth().toString());
2618  attributes.add("height", rectangle.getHeight().toString());
2619 
2620  if (rectangle.getRadiusX() != CLRelAbsVector(0.0, 0.0))
2621  {
2622  attributes.add("rx", rectangle.getRadiusX().toString());
2623  }
2624 
2625  if (rectangle.getRadiusY() != CLRelAbsVector(0.0, 0.0))
2626  {
2627  attributes.add("ry", rectangle.getRadiusY().toString());
2628  }
2629 
2630  saveElement("Rectangle", attributes);
2631 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const CLRelAbsVector & getRadiusY() const
const CLRelAbsVector & getWidth() const
const CLRelAbsVector & getX() const
const CLRelAbsVector & getY() const
const CLRelAbsVector & getRadiusX() const
const CLRelAbsVector & getHeight() const
void save2DAttributes(const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
std::string toString() const
bool add(const std::string &name, const CType &value)
const CLRelAbsVector & getZ() const
void CCopasiXML::saveRenderCurveElement ( const CLRenderCurve curve)
private

saves a single image element.

Definition at line 2703 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), save1DAttributes(), saveCurveElements(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveTransformation2D().

2704 {
2705  CXMLAttributeList attributes;
2706  // first we add the attributes for a 1D object
2707  save1DAttributes(curve, attributes);
2708  // next we add the arrow head attributes
2709  saveArrowHeadAttributes<CLRenderCurve>(curve, attributes);
2710  startSaveElement("Curve", attributes);
2711  saveCurveElements(*curve.getListOfCurveElements());
2712  endSaveElement("Curve");
2713 }
void save1DAttributes(const CLGraphicalPrimitive1D &primitive, CXMLAttributeList &attributes)
void saveCurveElements(const std::vector< CLRenderPoint * > &curveElements)
bool startSaveElement(const std::string &name)
bool endSaveElement(const std::string &name)
void CCopasiXML::saveRenderInformationAttributes ( const CLRenderInformationBase renderInfo,
CXMLAttributeList attributes 
)
private

Saves the attributes that render information objects have in common.

Definition at line 2010 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLRenderInformationBase::getBackgroundColor(), CLRenderInformationBase::getKey(), CLRenderInformationBase::getName(), and CLRenderInformationBase::getReferenceRenderInformationKey().

Referenced by saveGlobalRenderInformation(), and saveLocalRenderInformation().

2011 {
2012  // save the key
2013  attributes.add("key", renderInfo.getKey());
2014  // save the name
2015  std::string s = renderInfo.getName();
2016  const char* ws = " \t\n\r";
2017 
2018  if (s.find_first_not_of(ws) != std::string::npos)
2019  {
2020  attributes.add("name", s);
2021  }
2022 
2023  // save the background color
2024  s = renderInfo.getBackgroundColor();
2025 
2026  if (s.find_first_not_of(ws) != std::string::npos)
2027  {
2028  // save the name
2029  attributes.add("backgroundColor", s);
2030  }
2031 
2032  // save the reference render information key
2033  s = renderInfo.getReferenceRenderInformationKey();
2034 
2035  if (s.find_first_not_of(ws) != std::string::npos)
2036  {
2037  // save the name
2038  attributes.add("referenceRenderInformation", s);
2039  }
2040 }
const std::string & getBackgroundColor() const
const std::string & getReferenceRenderInformationKey() const
const std::string & getKey() const
const std::string & getName() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveRenderInformationDefinitionElements ( const CLRenderInformationBase renderInfo)
private

Saves color definitions, gradient definitions and line endings.

Saves color definitions , gradient definitions and line endings.

Definition at line 2045 of file CCopasiXML.cpp.

References CCopasiXMLInterface::endSaveElement(), CLRenderInformationBase::getColorDefinition(), CLRenderInformationBase::getGradientDefinition(), CLRenderInformationBase::getLineEnding(), CLRenderInformationBase::getNumColorDefinitions(), CLRenderInformationBase::getNumGradientDefinitions(), CLRenderInformationBase::getNumLineEndings(), saveColorDefinition(), saveLinearGradient(), saveLineEnding(), saveRadialGradient(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveGlobalRenderInformation(), and saveLocalRenderInformation().

2046 {
2047  size_t i, iMax = renderInfo.getNumColorDefinitions();
2048 
2049  if (iMax > 0)
2050  {
2051  startSaveElement("ListOfColorDefinitions");
2052 
2053  for (i = 0; i < iMax; ++i)
2054  {
2055  saveColorDefinition(*(renderInfo.getColorDefinition(i)));
2056  }
2057 
2058  endSaveElement("ListOfColorDefinitions");
2059  }
2060 
2061  iMax = renderInfo.getNumGradientDefinitions();
2062 
2063  if (iMax > 0)
2064  {
2065  startSaveElement("ListOfGradientDefinitions");
2066  const CLGradientBase* pGradient = NULL;
2067 
2068  for (i = 0; i < iMax; ++i)
2069  {
2070  pGradient = renderInfo.getGradientDefinition(i);
2071 
2072  if (dynamic_cast<const CLRadialGradient*>(pGradient))
2073  {
2074  saveRadialGradient(*static_cast<const CLRadialGradient*>(pGradient));
2075  }
2076  else if (dynamic_cast<const CLLinearGradient*>(pGradient))
2077  {
2078  saveLinearGradient(*static_cast<const CLLinearGradient*>(pGradient));
2079  }
2080  }
2081 
2082  endSaveElement("ListOfGradientDefinitions");
2083  }
2084 
2085  iMax = renderInfo.getNumLineEndings();
2086 
2087  if (iMax > 0)
2088  {
2089  startSaveElement("ListOfLineEndings");
2090 
2091  for (i = 0; i < iMax; ++i)
2092  {
2093  saveLineEnding(*(renderInfo.getLineEnding(i)));
2094  }
2095 
2096  endSaveElement("ListOfLineEndings");
2097  }
2098 }
void saveColorDefinition(const CLColorDefinition &color)
bool startSaveElement(const std::string &name)
void saveLinearGradient(const CLLinearGradient &gradient)
CLColorDefinition * getColorDefinition(size_t index)
CLLineEnding * getLineEnding(size_t index)
void saveLineEnding(const CLLineEnding &lineEnding)
bool endSaveElement(const std::string &name)
CLGradientBase * getGradientDefinition(size_t index)
void saveRadialGradient(const CLRadialGradient &gradient)
void CCopasiXML::saveRenderPoint ( const CLRenderPoint point)
private

saves a single render point element.

Definition at line 2734 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLRenderCubicBezier::basePoint1_X(), CLRenderCubicBezier::basePoint1_Y(), CLRenderCubicBezier::basePoint1_Z(), CLRenderCubicBezier::basePoint2_X(), CLRenderCubicBezier::basePoint2_Y(), CLRenderCubicBezier::basePoint2_Z(), CCopasiXMLInterface::saveElement(), CLRelAbsVector::toString(), CLRenderPoint::x(), CLRenderPoint::y(), and CLRenderPoint::z().

Referenced by saveCurveElements().

2735 {
2736  CXMLAttributeList attributes;
2737  attributes.add("x", point.x().toString());
2738  attributes.add("y", point.y().toString());
2739 
2740  if (point.z() != CLRelAbsVector(0.0, 0.0))
2741  {
2742  attributes.add("z", point.z().toString());
2743  }
2744 
2745  const CLRenderCubicBezier* pCB = dynamic_cast<const CLRenderCubicBezier*>(&point);
2746 
2747  if (pCB != NULL)
2748  {
2749  attributes.add("basePoint1_x", pCB->basePoint1_X().toString());
2750  attributes.add("basePoint1_y", pCB->basePoint1_Y().toString());
2751 
2752  if (pCB->basePoint1_Z() != CLRelAbsVector(0.0, 0.0))
2753  {
2754  attributes.add("basePoint1_z", pCB->basePoint1_Z().toString());
2755  }
2756 
2757  attributes.add("basePoint2_x", pCB->basePoint2_X().toString());
2758  attributes.add("basePoint2_y", pCB->basePoint2_Y().toString());
2759 
2760  if (pCB->basePoint2_Z() != CLRelAbsVector(0.0, 0.0))
2761  {
2762  attributes.add("basePoint2_z", pCB->basePoint2_Z().toString());
2763  }
2764  }
2765 
2766  saveElement("Element", attributes);
2767 }
const CLRelAbsVector & basePoint1_X() const
const CLRelAbsVector & basePoint2_Y() const
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const CLRelAbsVector & z() const
const CLRelAbsVector & basePoint2_Z() const
const CLRelAbsVector & basePoint2_X() const
const CLRelAbsVector & y() const
std::string toString() const
const CLRelAbsVector & basePoint1_Z() const
const CLRelAbsVector & x() const
const CLRelAbsVector & basePoint1_Y() const
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveRenderTextElement ( const CLText text)
private

saves a single text element.

Definition at line 2666 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CLText::getX(), CLText::getY(), CLText::getZ(), save1DAttributes(), CCopasiXMLInterface::saveData(), CCopasiXMLInterface::startSaveElement(), and CLRelAbsVector::toString().

Referenced by saveTransformation2D().

2667 {
2668  CXMLAttributeList attributes;
2669  // first we add the attributes for a 1D object
2670  save1DAttributes(text, attributes);
2671  // save text attributes
2672  attributes.add("x", text.getX().toString());
2673  attributes.add("y", text.getY().toString());
2674 
2675  if (text.getZ() != CLRelAbsVector(0.0, 0.0))
2676  {
2677  attributes.add("z", text.getZ().toString());
2678  }
2679 
2680  // next we add the text specific attributes
2681  saveTextAttributes<CLText>(text, attributes);
2682  startSaveElement("Text", attributes);
2683  saveData(text.getText());
2684  endSaveElement("Text");
2685 }
void save1DAttributes(const CLGraphicalPrimitive1D &primitive, CXMLAttributeList &attributes)
bool startSaveElement(const std::string &name)
const CLRelAbsVector & getZ() const
Definition: CLText.cpp:222
const CLRelAbsVector & getY() const
Definition: CLText.cpp:214
bool saveData(const std::string &data)
bool endSaveElement(const std::string &name)
std::string toString() const
const CLRelAbsVector & getX() const
Definition: CLText.cpp:206
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveReportList ( )
private

Save the list of reports.

Returns
bool success

Definition at line 1297 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CReportDefinition::getBodyAddr(), CReportDefinition::getComment(), CReportDefinition::getFooterAddr(), CReportDefinition::getHeaderAddr(), CReportDefinition::getKey(), CCopasiObject::getObjectName(), CReportDefinition::getPrecision(), CReportDefinition::getSeparator(), CCopasiStaticString::getStaticString(), CReportDefinition::getTableAddr(), CReportDefinition::getTaskType(), CReportDefinition::getTitle(), haveReportList(), CReportDefinition::isTable(), mpReportList, CCopasiXMLInterface::saveElement(), saveReportSection(), CCopasiXMLInterface::saveXhtml(), CXMLAttributeList::setValue(), CCopasiVector< T >::size(), CCopasiXMLInterface::startSaveElement(), and CCopasiTask::XMLType.

Referenced by save().

1298 {
1299  bool success = true;
1300 
1301  if (!haveReportList()) return success;
1302 
1303  size_t i, imax = mpReportList->size();
1304 
1305  if (!imax) return success;
1306 
1307  CXMLAttributeList Attributes;
1308  CReportDefinition * pReport = NULL;
1309 
1310  startSaveElement("ListOfReports");
1311 
1312  for (i = 0; i < imax; i++)
1313  {
1314  pReport = (*mpReportList)[i];
1315 
1316  Attributes.erase();
1317  Attributes.add("key", pReport->getKey());
1318  Attributes.add("name", pReport->getObjectName());
1319  Attributes.add("taskType", CCopasiTask::XMLType[pReport->getTaskType()]);
1320  Attributes.add("separator", pReport->getSeparator().getStaticString());
1321  Attributes.add("precision", pReport->getPrecision());
1322 
1323  startSaveElement("Report", Attributes);
1324 
1325  startSaveElement("Comment");
1326  saveXhtml(pReport->getComment());
1327  endSaveElement("Comment");
1328 
1329  if (pReport->isTable())
1330  {
1331  Attributes.erase();
1332  Attributes.add("printTitle", pReport->getTitle());
1333  startSaveElement("Table", Attributes);
1334 
1335  const std::vector <CRegisteredObjectName> & Table = * pReport->getTableAddr();
1336  size_t j, jmax = Table.size();
1337 
1338  Attributes.erase();
1339  Attributes.add("cn", "");
1340 
1341  for (j = 0; j < jmax; j++)
1342  {
1343  Attributes.setValue(0, Table[j]);
1344  saveElement("Object", Attributes);
1345  }
1346 
1347  endSaveElement("Table");
1348  }
1349  else
1350  {
1351  saveReportSection("Header", * pReport->getHeaderAddr());
1352  saveReportSection("Body", * pReport->getBodyAddr());
1353  saveReportSection("Footer", * pReport->getFooterAddr());
1354  }
1355 
1356  endSaveElement("Report");
1357  }
1358 
1359  endSaveElement("ListOfReports");
1360 
1361  return success;
1362 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
virtual size_t size() const
const CCopasiTask::Type & getTaskType() const
const CCopasiReportSeparator & getSeparator() const
bool saveXhtml(const std::string &xhtml)
const std::string & getComment() const
const unsigned C_INT32 & getPrecision() const
static const char * XMLType[]
Definition: CCopasiTask.h:72
const std::string & getStaticString() const
bool setValue(const size_t &index, const CType &value)
std::vector< CRegisteredObjectName > * getTableAddr()
std::vector< CRegisteredObjectName > * getFooterAddr()
virtual const std::string & getKey() const
bool endSaveElement(const std::string &name)
std::vector< CRegisteredObjectName > * getBodyAddr()
bool saveReportSection(const std::string &name, const std::vector< CRegisteredObjectName > &section)
bool haveReportList() const
Definition: CCopasiXML.cpp:348
std::vector< CRegisteredObjectName > * getHeaderAddr()
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveReportSection ( const std::string &  name,
const std::vector< CRegisteredObjectName > &  section 
)
private

Save a Report Section such as Header, Body or Footer.

Parameters
conststd::string & name
conststd::vector <CCopasiObjectName> & section
Returns
bool success

Definition at line 1259 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CCopasiXMLInterface::saveData(), CCopasiXMLInterface::saveElement(), CXMLAttributeList::set(), and CCopasiXMLInterface::startSaveElement().

Referenced by saveReportList().

1261 {
1262  CXMLAttributeList Attributes;
1263  Attributes.add("NoName", "");
1264 
1265  size_t j, jmax = section.size();
1266 
1267  if (jmax)
1268  {
1269  startSaveElement(name);
1270 
1271  for (j = 0; j < jmax; j++)
1272  {
1273  if (section[j].getObjectType() == "html")
1274  {
1275  //Write in Text
1276  startSaveElement("html");
1277  Attributes.set(0, "xmlns", "http://www.w3.org/1999/xhtml");
1278  startSaveElement("body", Attributes);
1279  saveData(section[j].getObjectName()); //TODO check
1280  endSaveElement("body");
1281  endSaveElement("html");
1282  }
1283  else
1284  {
1285  //Write in Object
1286  Attributes.set(0, "cn", section[j]);
1287  saveElement("Object", Attributes);
1288  }
1289  }
1290 
1291  endSaveElement(name);
1292  }
1293 
1294  return true;
1295 }
bool set(const size_t &index, const std::string &name, const CType &value)
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
bool startSaveElement(const std::string &name)
bool saveData(const std::string &data)
bool endSaveElement(const std::string &name)
bool add(const std::string &name, const CType &value)
bool CCopasiXML::saveSBMLReference ( )
private

Save the SBML reference information

Returns
bool success

Definition at line 1831 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CDirEntry::fileName(), CCopasiDataModel::getSBMLFileName(), CDirEntry::isRelativePath(), CDirEntry::makePathRelative(), mpDataModel, CCopasiXMLInterface::mPWD, mSBMLReference, CCopasiXMLInterface::saveElement(), CXMLAttributeList::setValue(), and CCopasiXMLInterface::startSaveElement().

Referenced by save().

1832 {
1833  // if there is no model, there are no SBML references to save,
1834  // so no reason to fail saving at this point
1835  if (!this->mpDataModel) return true;
1836 
1837  if (this->mpDataModel->getSBMLFileName() == "" ||
1838  mSBMLReference.size() == 0)
1839  return true;
1840 
1841  CXMLAttributeList Attributes;
1842 
1843  std::string SBMLFile = this->mpDataModel->getSBMLFileName();
1844 
1845  if (!CDirEntry::isRelativePath(SBMLFile) &&
1846  !CDirEntry::makePathRelative(SBMLFile, mPWD))
1847  SBMLFile = CDirEntry::fileName(SBMLFile);
1848 
1849  Attributes.add("file", SBMLFile);
1850 
1851  startSaveElement("SBMLReference", Attributes);
1852  Attributes.erase();
1853  Attributes.add("SBMLid", "");
1854  Attributes.add("COPASIkey", "");
1855 
1856  std::map<std::string, std::string>::const_iterator it = mSBMLReference.begin();
1857  std::map<std::string, std::string>::const_iterator end = mSBMLReference.end();
1858 
1859  for (; it != end; ++it)
1860  {
1861  Attributes.setValue(0, it->first);
1862  Attributes.setValue(1, it->second);
1863 
1864  saveElement("SBMLMap", Attributes);
1865  }
1866 
1867  endSaveElement("SBMLReference");
1868 
1869  return true;
1870 }
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
bool startSaveElement(const std::string &name)
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
bool setValue(const size_t &index, const CType &value)
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
const std::string & getSBMLFileName() const
std::map< std::string, std::string > mSBMLReference
Definition: CCopasiXML.h:594
bool endSaveElement(const std::string &name)
static bool makePathRelative(std::string &absolutePath, const std::string &relativeTo)
Definition: CDirEntry.cpp:434
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveStyleAttributes ( const CLStyle style,
CXMLAttributeList attributes 
)
private

Adds the attributes common to both style types.

Definition at line 2266 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLStyle::createStringFromSet(), CLStyle::getKey(), CLStyle::getNumRoles(), CLStyle::getNumTypes(), CLStyle::getRoleList(), and CLStyle::getTypeList().

Referenced by saveGlobalStyle(), and saveLocalStyle().

2267 {
2268  attributes.add("key", style.getKey());
2269 
2270  if (style.getNumRoles() > 0)
2271  {
2272  attributes.add("roleList", CLStyle::createStringFromSet(style.getRoleList()));
2273  }
2274 
2275  if (style.getNumTypes() > 0)
2276  {
2277  attributes.add("typeList", CLStyle::createStringFromSet(style.getTypeList()));
2278  }
2279 }
size_t getNumTypes() const
Definition: CLStyle.cpp:139
const std::set< std::string > & getRoleList() const
Definition: CLStyle.cpp:201
size_t getNumRoles() const
Definition: CLStyle.cpp:107
const std::set< std::string > & getTypeList() const
Definition: CLStyle.cpp:206
const std::string & getKey() const
Definition: CLStyle.cpp:228
static std::string createStringFromSet(const std::set< std::string > &set)
Definition: CLStyle.cpp:182
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveStyleElements ( const CLStyle style)
private

Saves the elements common to both style types.

Definition at line 2284 of file CCopasiXML.cpp.

References CLStyle::getGroup(), and saveGroupElement().

Referenced by saveGlobalStyle(), and saveLocalStyle().

2285 {
2286  assert(style.getGroup() != NULL);
2287  saveGroupElement(*(style.getGroup()));
2288 }
const CLGroup * getGroup() const
Definition: CLStyle.cpp:91
void saveGroupElement(const CLGroup &group)
bool CCopasiXML::saveTaskList ( )
private

Save the list of tasks.

Returns
bool success

Definition at line 1184 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CReport::append(), CReport::confirmOverwrite(), CCopasiXMLInterface::endSaveElement(), CXMLAttributeList::erase(), CDirEntry::fileName(), CReportDefinition::getKey(), CCopasiTask::getKey(), CCopasiTask::getMethod(), CCopasiObject::getObjectName(), CCopasiTask::getProblem(), CCopasiTask::getReport(), CReport::getReportDefinition(), CCopasiMethod::getSubType(), CReport::getTarget(), CCopasiTask::getType(), haveTaskList(), CDirEntry::isRelativePath(), CCopasiTask::isScheduled(), CCopasiTask::isUpdateModel(), CDirEntry::makePathRelative(), mpTaskList, CCopasiXMLInterface::mPWD, pTask, CCopasiXMLInterface::saveElement(), CCopasiXMLInterface::saveParameterGroup(), CCopasiVector< T >::size(), CCopasiXMLInterface::startSaveElement(), CCopasiMethod::XMLSubType, and CCopasiTask::XMLType.

Referenced by save().

1185 {
1186  bool success = true;
1187 
1188  if (!haveTaskList()) return success;
1189 
1190  size_t i, imax = mpTaskList->size();
1191 
1192  if (!imax) return success;
1193 
1194  CXMLAttributeList Attributes;
1195  CCopasiTask * pTask = NULL;
1196 
1197  startSaveElement("ListOfTasks");
1198 
1199  for (i = 0; i < imax; i++)
1200  {
1201  pTask = (*mpTaskList)[i];
1202 
1203  Attributes.erase();
1204  Attributes.add("key", pTask->getKey());
1205  Attributes.add("name", pTask->getObjectName());
1206  Attributes.add("type", CCopasiTask::XMLType[pTask->getType()]);
1207  Attributes.add("scheduled", pTask->isScheduled() ? "true" : "false");
1208  Attributes.add("updateModel", pTask->isUpdateModel() ? "true" : "false");
1209 
1210  startSaveElement("Task", Attributes);
1211 
1212  // Report Element
1213  CReport & tReport = pTask->getReport();
1214 
1215  if (tReport.getReportDefinition())
1216  {
1217  Attributes.erase();
1218  Attributes.add("reference", tReport.getReportDefinition()->getKey());
1219 
1220  std::string Target = tReport.getTarget();
1221 
1222  if (!CDirEntry::isRelativePath(Target) &&
1224  Target = CDirEntry::fileName(Target);
1225 
1226  Attributes.add("target", Target);
1227  Attributes.add("append", tReport.append());
1228  Attributes.add("confirmOverwrite", tReport.confirmOverwrite());
1229  saveElement("Report", Attributes);
1230  }
1231 
1232  //Problem Element
1233  CCopasiProblem *tProblem = pTask->getProblem();
1234 
1235  Attributes.erase();
1236  startSaveElement("Problem");
1237  saveParameterGroup(* tProblem->CCopasiParameter::getValue().pGROUP);
1238  endSaveElement("Problem");
1239 
1240  // Method Element
1241  CCopasiMethod *tMethod = pTask->getMethod();
1242 
1243  Attributes.erase();
1244  Attributes.add("name", tMethod->CCopasiParameter::getObjectName());
1245  Attributes.add("type", CCopasiMethod::XMLSubType[tMethod->getSubType()]);
1246  startSaveElement("Method", Attributes);
1247  saveParameterGroup(* tMethod->CCopasiParameter::getValue().pGROUP);
1248  endSaveElement("Method");
1249 
1250  endSaveElement("Task");
1251  }
1252 
1253  endSaveElement("ListOfTasks");
1254 
1255  return success;
1256 }
CCopasiProblem * getProblem()
const bool & confirmOverwrite() const
Definition: CReport.cpp:101
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
virtual size_t size() const
const bool & isUpdateModel() const
bool saveParameterGroup(const std::vector< CCopasiParameter * > &group)
const bool & isScheduled() const
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
const std::string & getTarget() const
Definition: CReport.cpp:89
const CCopasiMethod::SubType & getSubType() const
static const char * XMLType[]
Definition: CCopasiTask.h:72
CTSSATask * pTask
const bool & append() const
Definition: CReport.cpp:95
bool haveTaskList() const
Definition: CCopasiXML.cpp:308
virtual const std::string & getKey() const
CCopasiMethod * getMethod()
CReport & getReport()
bool endSaveElement(const std::string &name)
virtual const std::string & getKey() const
Type getType() const
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
static const char * XMLSubType[]
CReportDefinition * getReportDefinition()
Definition: CReport.cpp:83
static bool makePathRelative(std::string &absolutePath, const std::string &relativeTo)
Definition: CDirEntry.cpp:434
bool add(const std::string &name, const CType &value)
template<typename TEXTELEMENT >
void CCopasiXML::saveTextAttributes ( const TEXTELEMENT &  text,
CXMLAttributeList attributes 
)
private

Saves the attributes for a text element. We make this a template so that we can use it for a group as well as a text element.

Definition at line 2413 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLText::ANCHOR_BOTTOM, CLText::ANCHOR_END, CLText::ANCHOR_MIDDLE, CLText::ANCHOR_START, CLText::ANCHOR_TOP, CLText::STYLE_ITALIC, and CLText::WEIGHT_BOLD.

2414 {
2415  // text size
2416  if (text.isSetFontSize())
2417  {
2418  attributes.add("font-size", text.getFontSize().toString());
2419  }
2420 
2421  // font family
2422  if (text.isSetFontFamily())
2423  {
2424  attributes.add("font-family", text.getFontFamily());
2425  }
2426 
2427  // font weight
2428  if (text.isSetFontWeight())
2429  {
2430  switch (text.getFontWeight())
2431  {
2432  case CLText::WEIGHT_BOLD:
2433  attributes.add("font-weight", "bold");
2434  break;
2435 
2436  default:
2437  break;
2438  }
2439  }
2440 
2441  // font style
2442  if (text.isSetFontStyle())
2443  {
2444  switch (text.getFontStyle())
2445  {
2446  case CLText::STYLE_ITALIC:
2447  attributes.add("font-style", "italic");
2448  break;
2449 
2450  default:
2451  break;
2452  }
2453  }
2454 
2455  // text anchor
2456  if (text.isSetTextAnchor())
2457  {
2458  switch (text.getTextAnchor())
2459  {
2460  case CLText::ANCHOR_MIDDLE:
2461  attributes.add("text-anchor", "middle");
2462  break;
2463 
2464  case CLText::ANCHOR_END:
2465  attributes.add("text-anchor", "end");
2466  break;
2467 
2468  case CLText::ANCHOR_START:
2469  attributes.add("text-anchor", "start");
2470  break;
2471 
2472  default:
2473  break;
2474  }
2475  }
2476 
2477  // vertical text anchor
2478  if (text.isSetVTextAnchor())
2479  {
2480  switch (text.getVTextAnchor())
2481  {
2482  case CLText::ANCHOR_MIDDLE:
2483  attributes.add("vtext-anchor", "middle");
2484  break;
2485 
2486  case CLText::ANCHOR_BOTTOM:
2487  attributes.add("vtext-anchor", "bottom");
2488  break;
2489 
2490  case CLText::ANCHOR_TOP:
2491  attributes.add("vtext-anchor", "top");
2492  break;
2493 
2494  default:
2495  break;
2496  }
2497  }
2498 }
bool add(const std::string &name, const CType &value)
void CCopasiXML::saveTransformation2D ( const CLTransformation2D transformation)
private

Saves a class that is subclasses from Transformation2D. This covers images, curves, rectangles, ellipses, polygons, text elements and groups.

Definition at line 2524 of file CCopasiXML.cpp.

References saveEllipseElement(), saveGroupElement(), saveImageElement(), savePolygonElement(), saveRectangleElement(), saveRenderCurveElement(), and saveRenderTextElement().

Referenced by saveGroupElement().

2525 {
2526  if (dynamic_cast<const CLGraphicalPrimitive1D*>(&transformation))
2527  {
2528  if (dynamic_cast<const CLRenderCurve*>(&transformation))
2529  {
2530  saveRenderCurveElement(static_cast<const CLRenderCurve&>(transformation));
2531  }
2532  else if (dynamic_cast<const CLGraphicalPrimitive2D*>(&transformation))
2533  {
2534  if (dynamic_cast<const CLRectangle*>(&transformation))
2535  {
2536  saveRectangleElement(static_cast<const CLRectangle&>(transformation));
2537  }
2538  else if (dynamic_cast<const CLEllipse*>(&transformation))
2539  {
2540  saveEllipseElement(static_cast<const CLEllipse&>(transformation));
2541  }
2542  else if (dynamic_cast<const CLPolygon*>(&transformation))
2543  {
2544  savePolygonElement(static_cast<const CLPolygon&>(transformation));
2545  }
2546  else if (dynamic_cast<const CLGroup*>(&transformation))
2547  {
2548  saveGroupElement(static_cast<const CLGroup&>(transformation));
2549  }
2550  else
2551  {
2552  // we should never end up here.
2553  assert(false);
2554  }
2555  }
2556  else if (dynamic_cast<const CLText*>(&transformation))
2557  {
2558  saveRenderTextElement(static_cast<const CLText&>(transformation));
2559  }
2560  else
2561  {
2562  // we should never end up here.
2563  assert(false);
2564  }
2565  }
2566  else if (dynamic_cast<const CLImage*>(&transformation))
2567  {
2568  saveImageElement(static_cast<const CLImage&>(transformation));
2569  }
2570  else
2571  {
2572  // we should never end up here.
2573  assert(false);
2574  }
2575 }
void saveImageElement(const CLImage &image)
void saveRectangleElement(const CLRectangle &rectangle)
void saveGroupElement(const CLGroup &group)
void savePolygonElement(const CLPolygon &polygon)
void saveEllipseElement(const CLEllipse &ellipse)
void saveRenderTextElement(const CLText &text)
void saveRenderCurveElement(const CLRenderCurve &curve)
void CCopasiXML::saveTransformationAttributes ( const CLTransformation2D transformation,
CXMLAttributeList attributes 
)
private

Saves the attributes for a transformation.

Definition at line 2316 of file CCopasiXML.cpp.

References CXMLAttributeList::add(), CLTransformation2D::get2DTransformationString(), CLTransformation::get3DTransformationString(), CLTransformation::is2DTransformation(), CLTransformation::isIdentityMatrix(), and CLTransformation::isSetMatrix().

Referenced by save1DAttributes(), and saveImageElement().

2317 {
2318  // transformation
2319  if (!transformation.isIdentityMatrix())
2320  {
2321  // check if it is a 2D or a 3D transformation
2322  if (transformation.is2DTransformation())
2323  {
2324  if (transformation.isSetMatrix())
2325  {
2326  attributes.add("transform", transformation.get2DTransformationString());
2327  }
2328  }
2329  else
2330  {
2331  if (transformation.isSetMatrix())
2332  {
2333  attributes.add("transform", transformation.get3DTransformationString());
2334  }
2335  }
2336  }
2337 }
std::string get3DTransformationString() const
std::string get2DTransformationString() const
bool is2DTransformation() const
bool isSetMatrix() const
bool isIdentityMatrix() const
bool add(const std::string &name, const CType &value)
bool CCopasiXML::setDatamodel ( CCopasiDataModel pDataModel)

Set the datamodel.

Parameters
CCopasiDataModel*pDataModel
Returns
bool success

Definition at line 299 of file CCopasiXML.cpp.

References mpDataModel.

Referenced by CCopasiDataModel::loadModel(), save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

300 {
301  this->mpDataModel = pDataModel;
302  return true;
303 }
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
bool CCopasiXML::setFunctionList ( CCopasiVectorN< CFunction > *  pFunctionList)

Set the function list.

Parameters
CopasiVectorN<CFunction > * pFunctionList
Returns
bool success

Definition at line 270 of file CCopasiXML.cpp.

References mpFunctionList.

Referenced by buildFunctionList(), CFunctionDB::load(), CCopasiDataModel::loadModel(), and CFunctionDB::save().

271 {
272  mpFunctionList = pFunctionList;
273  return true;
274 }
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
bool CCopasiXML::setGUI ( SCopasiXMLGUI pGUI)

Set the GUI.

Parameters
SCopasiXMLGUI*pGUI
Returns
bool success

Definition at line 359 of file CCopasiXML.cpp.

References mpGUI.

Referenced by CCopasiDataModel::loadModel(), save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

360 {
361  mpGUI = pGUI;
362  return true;
363 }
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
bool CCopasiXML::setLayoutList ( const CListOfLayouts reportList)

Set the layout list.

Parameters
constCListOfLayouts & reportList
Returns
bool success

Definition at line 377 of file CCopasiXML.cpp.

References mpLayoutList.

Referenced by save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

378 {
379  mpLayoutList = const_cast<CListOfLayouts *>(&layoutList);
380  return true;
381 }
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
bool CCopasiXML::setModel ( CModel pModel)

Set the model.

Parameters
CModel* pModel
Returns
bool success

Definition at line 254 of file CCopasiXML.cpp.

References mpModel.

Referenced by save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

255 {
256  mpModel = pModel;
257  return true;
258 }
CModel * mpModel
Definition: CCopasiXML.h:553
bool CCopasiXML::setPlotList ( COutputDefinitionVector pPlotList)

Set the plot list.

Parameters
COutputDefinitionVector* pPlotList
Returns
bool success

Definition at line 319 of file CCopasiXML.cpp.

References mpPlotList.

Referenced by save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

320 {
321  mpPlotList = pPlotList;
322  return true;
323 }
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
bool CCopasiXML::setReportList ( CReportDefinitionVector pReportList)

Set the report list.

Parameters
CReportDefinitionVector*pReportList
Returns
bool success

Definition at line 339 of file CCopasiXML.cpp.

References mpReportList.

Referenced by save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

340 {
341  mpReportList = pReportList;
342  return true;
343 }
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
bool CCopasiXML::setTaskList ( CCopasiVectorN< CCopasiTask > *  pTaskList)

Set the task list.

Parameters
CCopasiVectorN<CCopasiTask > *pTaskList
Returns
bool success

Definition at line 288 of file CCopasiXML.cpp.

References mpTaskList.

Referenced by save_cps_model_to_stream(), and CCopasiDataModel::saveModel().

289 {
290  mpTaskList = pTaskList;
291  return true;
292 }
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565

Member Data Documentation

bool CCopasiXML::mMCXML21Issued
private

Remember if we already issued MCXML21

Definition at line 604 of file CCopasiXML.h.

Referenced by saveLayoutList().

CCopasiDataModel* CCopasiXML::mpDataModel
private

Pointer to the datamodel

Definition at line 599 of file CCopasiXML.h.

Referenced by buildFunctionList(), load(), saveSBMLReference(), and setDatamodel().

CCopasiVectorN< CFunction >* CCopasiXML::mpFunctionList
private

Pointer to a vector of functions which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 559 of file CCopasiXML.h.

Referenced by freeFunctionList(), getFunctionList(), haveFunctionList(), load(), saveFunctionList(), and setFunctionList().

SCopasiXMLGUI* CCopasiXML::mpGUI
private

Pointer to a GUI related information, which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 583 of file CCopasiXML.h.

Referenced by freeGUI(), getGUI(), haveGUI(), load(), saveGUI(), and setGUI().

CListOfLayouts* CCopasiXML::mpLayoutList
private

Pointer to a vector of plots which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 589 of file CCopasiXML.h.

Referenced by freeLayoutList(), getLayoutList(), haveLayoutList(), load(), saveLayoutList(), and setLayoutList().

CModel* CCopasiXML::mpModel
private

Pointer to a model which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 553 of file CCopasiXML.h.

Referenced by freeModel(), getModel(), haveModel(), load(), saveModel(), and setModel().

COutputDefinitionVector* CCopasiXML::mpPlotList
private

Pointer to a vector of plots which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 577 of file CCopasiXML.h.

Referenced by freePlotList(), getPlotList(), havePlotList(), load(), savePlotList(), and setPlotList().

CReportDefinitionVector* CCopasiXML::mpReportList
private

Pointer to a vector of reports which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 571 of file CCopasiXML.h.

Referenced by freeReportList(), getReportList(), haveReportList(), load(), saveReportList(), and setReportList().

CCopasiVectorN< CCopasiTask >* CCopasiXML::mpTaskList
private

Pointer to a vector of tasks which has been loaded or is to be saved. The ownership is handed to the user.

Definition at line 565 of file CCopasiXML.h.

Referenced by fixBuild55(), fixBuild81(), freeTaskList(), getTaskList(), haveTaskList(), load(), saveTaskList(), and setTaskList().

std::map< std::string, std::string > CCopasiXML::mSBMLReference
private

SBML Reference

Definition at line 594 of file CCopasiXML.h.

Referenced by saveFunctionList(), saveModel(), and saveSBMLReference().


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