COPASI API  4.16.103
CCopasiXML.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2003 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /*!
16  \file CCopasiXML.cpp
17  \brief Implementation file of class CCopasiXML.
18  */
19 
20 /**
21  * CCopasiXML class.
22  * This class implements a CCopasiXMLInterface to the COPASI XML specified in
23  * http://www.copasi.org/schema/copasi.xsd
24  *
25  * Created for COPASI by Stefan Hoops 2003
26  * Copyright Stefan Hoops
27  */
28 #include <iostream>
29 #include <map>
30 #include <locale>
31 
32 #include "copasi.h"
33 
34 #include "CCopasiXML.h"
35 #include "CCopasiXMLParser.h"
37 
41 #include "utilities/CSlider.h"
42 #include "model/CModel.h"
43 #include "model/CState.h"
44 #include "function/CFunctionDB.h"
47 #include "utilities/CCopasiTask.h"
50 #include "utilities/CDirEntry.h"
51 #include "utilities/utility.h"
53 #include "plot/CPlotItem.h"
54 #include "layout/CListOfLayouts.h"
56 #include "scan/CScanTask.h"
57 
70 #include "copasi/layout/CLGroup.h"
72 #include "copasi/layout/CLImage.h"
74 #include "copasi/layout/CLText.h"
82 
83 // class CCopasiTask;
84 // class CCopasiReport;
85 
86 // static
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 {}
99 
101 
102 bool CCopasiXML::save(std::ostream & os,
103  const std::string & relativeTo)
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 }
168 
169 bool CCopasiXML::load(std::istream & is,
170  const std::string & relativeTo)
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 
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 }
253 
255 {
256  mpModel = pModel;
257  return true;
258 }
259 
261 
262 bool CCopasiXML::haveModel() const {return mpModel != NULL;}
263 
265 {
266  pdelete(mpModel);
267  return true;
268 }
269 
271 {
272  mpFunctionList = pFunctionList;
273  return true;
274 }
275 
277 {return mpFunctionList;}
278 
280 {return mpFunctionList != NULL;}
281 
283 {
285  return true;
286 }
287 
289 {
290  mpTaskList = pTaskList;
291  return true;
292 }
293 
294 /**
295  * Set the datamodel.
296  * @param CCopasiDataModel* pDataModel
297  * @return bool success
298  */
300 {
301  this->mpDataModel = pDataModel;
302  return true;
303 }
304 
306 {return mpTaskList;}
307 
309 {return mpTaskList != NULL;}
310 
312 {
314  return true;
315 }
316 
317 //************
318 
320 {
321  mpPlotList = pPlotList;
322  return true;
323 }
324 
326 {return mpPlotList;}
327 
329 {return mpPlotList != NULL;}
330 
332 {
334  return true;
335 }
336 
337 //************
338 
340 {
341  mpReportList = pReportList;
342  return true;
343 }
344 
346 {return mpReportList;}
347 
349 {return mpReportList != NULL;}
350 
352 {
354  return true;
355 }
356 
357 //************
358 
360 {
361  mpGUI = pGUI;
362  return true;
363 }
364 
366 
367 bool CCopasiXML::haveGUI() const {return mpGUI != NULL;}
368 
370 {
371  pdelete(mpGUI);
372  return true;
373 }
374 
375 //************
376 
378 {
379  mpLayoutList = const_cast<CListOfLayouts *>(&layoutList);
380  return true;
381 }
382 
384 {return mpLayoutList;}
385 
387 {return mpLayoutList != NULL;}
388 
390 {
392  return true;
393 }
394 
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 }
921 
922 bool CCopasiXML::saveAnnotation(const CAnnotation * pAnnotation)
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 }
962 
963 bool CCopasiXML::saveModelParameter(const CModelParameter * pModelParameter)
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 }
1017 
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 }
1105 
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 }
1182 
1183 //Mrinmayee
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 }
1257 
1258 //Mrinmayee
1259 bool CCopasiXML::saveReportSection(const std::string & name,
1260  const std::vector <CRegisteredObjectName> & section)
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 }
1296 
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 }
1363 
1364 void CCopasiXML::savePosition(const CLPoint& p, const std::string & tag)
1365 {
1366  CXMLAttributeList Attributes;
1367  Attributes.erase();
1368  Attributes.add("x", p.getX());
1369  Attributes.add("y", p.getY());
1370  saveElement(tag, Attributes);
1371 }
1372 
1374 {
1375  CXMLAttributeList Attributes;
1376  Attributes.erase();
1377  Attributes.add("width", d.getWidth());
1378  Attributes.add("height", d.getHeight());
1379  saveElement("Dimensions", Attributes);
1380 }
1381 
1383 {
1384  startSaveElement("BoundingBox");
1385  savePosition(bb.getPosition());
1387  endSaveElement("BoundingBox");
1388 }
1389 
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 }
1430 
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 }
1778 
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 }
1830 
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 }
1871 
1873 {
1874  bool success = true;
1875 
1876  CCopasiVectorN< CFunction > * pFunctionList
1878 
1880 
1881  if (!setFunctionList(pFunctionList)) success = false;
1882 
1883  return success;
1884 }
1885 
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 }
1902 
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 }
1919 
1920 /**
1921  * Saves the list of global render information objects.
1922  */
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 }
1935 
1936 /**
1937  * Saves the list of local render information objects.
1938  */
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 }
1951 
1952 /**
1953  * Saves a single global render information object.
1954  */
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 }
1980 
1981 /**
1982  * Saves a single local render information object.
1983  */
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 }
2009 
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 }
2041 
2042 /**
2043  * Saves color definitions , gradient definitions and line endings.
2044  */
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 }
2099 
2100 /**
2101  * Save a single color definition element.
2102  */
2104 {
2105  CXMLAttributeList attributes;
2106  attributes.add("id", color.getId());
2107  attributes.add("value", color.createValueString());
2108  saveElement("ColorDefinition", attributes);
2109 }
2110 
2111 /**
2112  * Saves a single linear gradient definition.
2113  */
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 }
2141 
2142 /**
2143  * Saves a single radial gradient definition.
2144  */
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 }
2163 
2164 /**
2165  * Adds the attributes common to radial and linear gradient.
2166  */
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 }
2187 
2188 /**
2189  * Saves the elements that are common to linear and radial gradients.
2190  */
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 }
2203 
2204 /**
2205  * Saves a single gradient stop element.
2206  */
2208 {
2209  CXMLAttributeList attributes;
2210  attributes.add("offset", stop.getOffset().toString());
2211  attributes.add("stop-color", stop.getStopColor());
2212  saveElement("Stop", attributes);
2213 }
2214 
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 }
2229 
2230 /**
2231  * Saves a single local style element.
2232  */
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 }
2249 
2250 /**
2251  * Saves a single local style element.
2252  */
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 }
2262 
2263 /**
2264  * Adds the attributes common to both style types.
2265  */
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 }
2280 
2281 /**
2282  * Saves the elements common to both style types.
2283  */
2285 {
2286  assert(style.getGroup() != NULL);
2287  saveGroupElement(*(style.getGroup()));
2288 }
2289 
2290 /**
2291  * Saves a group element.
2292  */
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 }
2312 
2313 /**
2314  * Saves the attributes for a transformation.
2315  */
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 }
2338 
2339 /**
2340  * Saves the attributes for a 1D element
2341  */
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 }
2376 
2377 /**
2378  * Saves the attributes for a 2D element
2379  */
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 }
2407 
2408 /**
2409  * Saves the attributes for a text element.
2410  * We make this a template so that we can use it for a group as well as a text element.
2411  */
2412 template<typename TEXTELEMENT>
2413 void CCopasiXML::saveTextAttributes(const TEXTELEMENT& text, CXMLAttributeList& attributes)
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 }
2499 
2500 /**
2501  * Saves the startHead and endHead attribute as found in group and curves.
2502  * We write it as a template so that it can be used on curves and group elements.
2503  */
2504 template<typename HEADELEMENT>
2505 void CCopasiXML::saveArrowHeadAttributes(const HEADELEMENT& element, CXMLAttributeList& attributes)
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 }
2519 
2520 /**
2521  * Saves a class that is subclasses from Transformation2D.
2522  * This covers images, curves, rectangles, ellipses, polygons, text elements and groups.
2523  */
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 }
2576 
2577 /**
2578  * saves a single image element.
2579  */
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 }
2599 
2600 /**
2601  * saves a single rectangle element.
2602  */
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 }
2632 
2633 /**
2634  * saves a single ellipse element.
2635  */
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 }
2662 
2663 /**
2664  * saves a single text element.
2665  */
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 }
2686 
2687 /**
2688  * saves a single image element.
2689  */
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 }
2699 
2700 /**
2701  * saves a single image element.
2702  */
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 }
2714 
2715 /**
2716  * saves a vector of curve elements. This can be called from the polygon as well as the curve.
2717  */
2718 void CCopasiXML::saveCurveElements(const std::vector<CLRenderPoint*>& curveElements)
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 }
2730 
2731 /**
2732  * saves a single render point element.
2733  */
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 & getRadius() const
bool freePlotList()
Definition: CCopasiXML.cpp:331
Definition: CEvent.h:152
size_t getNumTypes() const
Definition: CLStyle.cpp:139
std::string get3DTransformationString() const
CCopasiVectorN< CFunction > * getFunctionList() const
Definition: CCopasiXML.cpp:276
CLRelAbsVector & getX()
Definition: CLImage.cpp:198
std::string get2DTransformationString() const
CCopasiVector< CSlider > * getSliderList()
const C_FLOAT64 & getAvogadro() const
Definition: CModel.cpp:2349
const CLRelAbsVector & basePoint1_X() const
std::string getInitialExpression() const
const CLRelAbsVector & getCenterY() const
const CCopasiVectorN< CEventAssignment > & getAssignments() const
Definition: CEvent.cpp:678
const CLRelAbsVector & getYPoint1() const
void saveColorDefinition(const CLColorDefinition &color)
static const char * ModelTypeNames[]
Definition: CModel.h:117
void saveBoundingBox(const CLBoundingBox &bb)
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
Definition: CLayout.h:120
void saveDimensions(const CLDimensions &d)
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
const CModelParameterSet & getModelParameterSet() const
Definition: CModel.cpp:1072
const CLRelAbsVector & getCenterX() const
void save1DAttributes(const CLGraphicalPrimitive1D &primitive, CXMLAttributeList &attributes)
const bool & getDelayAssignment() const
Definition: CEvent.cpp:419
virtual const std::string & getName(const size_t &index) const
#define pdelete(p)
Definition: copasi.h:215
const char * convertScaleToScaleName(Scale scale)
Definition: CSlider.cpp:396
Definition: CLText.h:27
static CFunction * getUndefinedFunction()
const CLRelAbsVector & getZPoint1() const
const CLRelAbsVector & basePoint2_Y() const
#define BUFFER_SIZE
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
bool is2DTransformation() const
const CLRelAbsVector & getHeight() const
Definition: CLImage.cpp:116
bool isTextSet() const
Definition: CLGlyphs.h:161
void saveGradientElements(const CLGradientBase &gradient)
CCopasiProblem * getProblem()
const bool & confirmOverwrite() const
Definition: CReport.cpp:101
bool set(const size_t &index, const std::string &name, const CType &value)
const CompareResult & getCompareResult() const
bool saveElement(const std::string &name, CXMLAttributeList &attributeList)
const CLBoundingBox & getBoundingBox() const
const std::string & getSBMLId() const
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
void saveCurveElements(const std::vector< CLRenderPoint * > &curveElements)
const std::string & getObjectName() const
bool startSaveElement(const std::string &name)
void saveLocalStyle(const CLLocalStyle &style)
static bool isRelativePath(const std::string &path)
Definition: CDirEntry.cpp:414
void saveTransformation2D(const CLTransformation2D &transformation)
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
CCopasiVectorN< CCopasiTask > * getTaskList() const
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
unsigned C_INT32 getDimensionality() const
CReportDefinitionVector * mpReportList
Definition: CCopasiXML.h:571
virtual size_t size() const
virtual std::string getText() const
Definition: CLGlyphs.cpp:238
const CLRelAbsVector & getZ() const
Definition: CLText.cpp:222
const CLRelAbsVector & z() const
const CLRelAbsVector & getY() const
Definition: CLText.cpp:214
bool freeModel()
Definition: CCopasiXML.cpp:264
bool setModel(CModel *pModel)
Definition: CCopasiXML.cpp:254
const bool & isUpdateModel() const
void fixBuild81()
bool saveParameterGroup(const std::vector< CCopasiParameter * > &group)
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
bool haveGUI() const
Definition: CCopasiXML.cpp:367
const CLRelAbsVector & getRadiusY() const
const std::string & getBackgroundColor() const
bool saveData(const std::string &data)
CListOfLayouts * getLayoutList() const
Definition: CCopasiXML.cpp:383
iterator begin()
const CLRelAbsVector & getWidth() const
const std::vector< CLLineSegment > & getCurveSegments() const
Definition: CLCurve.h:154
const CCopasiTask::Type & getTaskType() const
#define fatalError()
void saveRenderPoint(const CLRenderPoint &point)
std::string getTimeUnitName() const
Definition: CModel.cpp:2238
const CCopasiReportSeparator & getSeparator() const
const std::string & getSliderObjectCN() const
Definition: CSlider.cpp:179
CLRelAbsVector & getY()
Definition: CLImage.cpp:206
const std::string & getObjectRole() const
bool setFunctionList(CCopasiVectorN< CFunction > *pFunctionList)
Definition: CCopasiXML.cpp:270
const std::string & getAssociatedEntityKey() const
Definition: CSlider.cpp:101
virtual const std::string & getKey() const
#define MCXML
const std::string & getId() const
const std::string & getKey() const
Definition: CSlider.cpp:91
static const char * TypeNames[]
const CLRelAbsVector & basePoint2_Z() const
const bool & isScheduled() const
SCopasiXMLGUI * mpGUI
Definition: CCopasiXML.h:583
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
bool saveReportList()
std::vector< CFunction * > getUsedFunctions(const CModel *pModel) const
bool saveXhtml(const std::string &xhtml)
size_t getNumChannels() const
Definition: CPlotItem.cpp:220
const CEvaluationTree::Type & getType() const
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
const std::string & getTarget() const
Definition: CReport.cpp:89
const std::set< std::string > & getKeyList() const
bool savePlotList()
CCopasiVectorN< CFunction > * mpFunctionList
Definition: CCopasiXML.h:559
#define C_INVALID_INDEX
Definition: copasi.h:222
std::string getExpression() const
bool haveModel() const
Definition: CCopasiXML.cpp:262
CLGradientStop * getGradientStop(size_t i)
std::string getTriggerExpression() const
Definition: CEvent.cpp:524
void fixBuild55()
const CLRelAbsVector & basePoint2_X() const
void saveGradientAttributes(const CLGradientBase &gradient, CXMLAttributeList &attributes)
CSlider::Type getSliderType() const
Definition: CSlider.cpp:188
const CLRelAbsVector & getXPoint2() const
virtual size_t getIndex(const std::string &name) const
CLLocalStyle * getStyle(size_t i)
const bool & isActive() const
SCopasiXMLGUI * getGUI() const
Definition: CCopasiXML.cpp:365
const CCopasiMethod::SubType & getSubType() const
COutputDefinitionVector * getPlotList() const
Definition: CCopasiXML.cpp:325
void saveListOfGlobalRenderInformation(const CCopasiVector< CLGlobalRenderInformation > &list)
void saveTextAttributes(const TEXTELEMENT &text, CXMLAttributeList &attributes)
const std::string & getMetabGlyphKey() const
const std::string & getComment() const
bool haveFunctionList() const
Definition: CCopasiXML.cpp:279
const std::string & getStroke() const
const CCopasiObjectName & getCN() const
Definition: CMetab.h:178
bool freeGUI()
Definition: CCopasiXML.cpp:369
const CLPoint & getBase1() const
Definition: CLCurve.h:82
void saveLinearGradient(const CLLinearGradient &gradient)
const size_t & size() const
Definition: CState.cpp:242
const std::string & getKey() const
Definition: CFunction.cpp:58
const std::string & getMiriamAnnotation() const
bool freeFunctionList()
Definition: CCopasiXML.cpp:282
static const std::string RoleNameXML[]
const unsigned C_INT32 & getPrecision() const
void saveListOfLocalRenderInformation(const CCopasiVector< CLLocalRenderInformation > &list)
const std::string & getImageReference() const
Definition: CLImage.cpp:132
void fixBuild55()
Definition: CFitTask.cpp:129
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
size_t getNumGradientStops() const
void saveStyleAttributes(const CLStyle &style, CXMLAttributeList &attributes)
bool saveModel()
Definition: CCopasiXML.cpp:395
const CLRelAbsVector & getX() const
virtual const std::string & getKey() const
const CLRelAbsVector & getRX() const
Definition: CLEllipse.cpp:151
std::string getKey(const std::string &name) const
CLColorDefinition * getColorDefinition(size_t index)
static const char * TypeName[]
Definition: CSlider.h:45
size_t getNumKeys() const
void setModelObjectKey(const std::string &k)
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const CLRelAbsVector & getY() const
bool skip(const size_t &index)
const CLRelAbsVector & getCY() const
Definition: CLEllipse.cpp:135
const std::string & getReferenceRenderInformationKey() const
const CLRelAbsVector & getRadiusX() const
const std::string & getSBMLId() const
Definition: CReaction.cpp:1654
bool freeTaskList()
Definition: CCopasiXML.cpp:311
const CLRelAbsVector & getCenterZ() const
static const char * XMLType[]
Definition: CCopasiTask.h:72
CTSSATask * pTask
const std::string & getStaticString() const
void saveImageElement(const CLImage &image)
bool havePlotList() const
Definition: CCopasiXML.cpp:328
bool setValue(const size_t &index, const CType &value)
void saveRectangleElement(const CLRectangle &rectangle)
const CCopasiVector< CChemEqElement > & getProducts() const
Definition: CChemEq.cpp:63
bool saveAnnotation(const CAnnotation *pAnnotation)
Definition: CCopasiXML.cpp:922
const std::string & getStopColor() const
const bool & getPersistentTrigger() const
Definition: CEvent.cpp:439
const bool & append() const
Definition: CReport.cpp:95
void saveGlobalStyle(const CLGlobalStyle &style)
const CFunction * getFunction() const
Definition: CReaction.cpp:252
const CLRelAbsVector & y() const
const CLPoint & getBase2() const
Definition: CLCurve.h:83
iterator end()
bool haveTaskList() const
Definition: CCopasiXML.cpp:308
const CLRelAbsVector & getOffset() const
bool setDatamodel(CCopasiDataModel *pDataModel)
Definition: CCopasiXML.cpp:299
const CLPoint & getEnd() const
Definition: CLCurve.h:75
const CFunctionParameters & getFunctionParameters() const
Definition: CReaction.cpp:576
const std::set< std::string > & getRoleList() const
Definition: CLStyle.cpp:201
CCopasiDataModel * mpDataModel
Definition: CCopasiXML.h:599
static const char * XMLType[]
Definition: CPlotItem.h:104
const CLRelAbsVector & getHeight() const
virtual const std::string & getKey() const
size_t getNumRoles() const
Definition: CLStyle.cpp:107
void saveGradientStop(const CLGradientStop &stop)
const std::set< std::string > & getTypeList() const
Definition: CLStyle.cpp:206
void saveTransformationAttributes(const CLTransformation2D &transformation, CXMLAttributeList &attributes)
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
const TriLogic & isReversible() const
Definition: CFunction.cpp:145
Definition: CLBase.h:54
const std::string & getNotes() const
CLLineEnding * getLineEnding(size_t index)
std::vector< CRegisteredObjectName > * getTableAddr()
virtual const std::string & getKey() const
CReportDefinitionVector * getReportList() const
const CLRelAbsVector & getFocalPointY() const
const CLPoint & getPosition() const
Definition: CLBase.h:265
std::vector< CRegisteredObjectName > * getFooterAddr()
bool setTaskList(CCopasiVectorN< CCopasiTask > *pTaskList)
Definition: CCopasiXML.cpp:288
COutputDefinitionVector * mpPlotList
Definition: CCopasiXML.h:577
struct MESSAGES Message
const CLGroup * getGroup() const
Definition: CLStyle.cpp:91
void saveGroupElement(const CLGroup &group)
std::string getInitialExpression() const
const std::string & getSBMLFileName() const
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
int getCurrentColumnNumber()
Definition: CExpat.h:480
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
void setDatamodel(CCopasiDataModel *pDataModel)
std::string getLengthUnitName() const
Definition: CModel.cpp:2215
const CLGroup * getGroup() const
const CLRelAbsVector & getZPoint2() const
std::map< std::string, std::string > mSBMLReference
Definition: CCopasiXML.h:594
bool freeLayoutList()
Definition: CCopasiXML.cpp:389
bool setPlotList(COutputDefinitionVector *pPlotList)
Definition: CCopasiXML.cpp:319
void save2DAttributes(const CLGraphicalPrimitive2D &primitive, CXMLAttributeList &attributes)
void saveLineEnding(const CLLineEnding &lineEnding)
const CCopasiVectorN< CModelParameterSet > & getModelParameterSets() const
Definition: CModel.cpp:1066
void saveArrowHeadAttributes(const HEADELEMENT &element, CXMLAttributeList &attributes)
void saveRenderInformationAttributes(const CLRenderInformationBase &renderInfo, CXMLAttributeList &attributes)
const std::string & getId() const
virtual const double & getValue(const Framework &framework) const
const CCopasiVector< CChemEqElement > & getSubstrates() const
Definition: CChemEq.cpp:60
virtual const std::string & getKey() const
Definition: CLayout.h:71
const std::string & getKey() const
Definition: CModel.cpp:1142
bool isReversible() const
Definition: CReaction.cpp:229
bool setLayoutList(const CListOfLayouts &reportList)
Definition: CCopasiXML.cpp:377
static CFunctionDB * getFunctionList()
static const char * XMLStatus[]
Definition: CModelValue.h:72
std::string getDelayExpression() const
Definition: CEvent.cpp:591
bool haveLayoutList() const
Definition: CCopasiXML.cpp:386
bool saveSBMLReference()
const CLRelAbsVector & getWidth() const
Definition: CLImage.cpp:108
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
const CLRelAbsVector & getCZ() const
Definition: CLEllipse.cpp:143
virtual const std::string & getKey() const
const std::string & getKey() const
Definition: CLStyle.cpp:228
CReportDefinitionVector * getReportList() const
Definition: CCopasiXML.cpp:345
void saveCurve(const CLCurve &c)
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
void saveLocalRenderInformation(const CLLocalRenderInformation &renderInfo)
const bool & isFast() const
Definition: CReaction.cpp:1712
std::string getAreaUnitName() const
Definition: CModel.cpp:2193
const CModelEntity::Status & getSimulationType() const
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
void savePolygonElement(const CLPolygon &polygon)
const CLRelAbsVector & getRY() const
Definition: CLEllipse.cpp:159
void saveEllipseElement(const CLEllipse &ellipse)
CLBoundingBox * getBoundingBox()
const std::string & getModelObjectKey() const
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
CLRelAbsVector & getZ()
Definition: CLImage.cpp:214
CCopasiMethod * getMethod()
bool isBezier() const
Definition: CLCurve.h:90
CModel * getModel() const
Definition: CCopasiXML.cpp:260
bool setGUI(SCopasiXMLGUI *pGUI)
Definition: CCopasiXML.cpp:359
CReport & getReport()
const std::string & getSBMLId() const
Definition: CFunction.cpp:68
std::string getQuantityUnitName() const
Definition: CModel.cpp:2321
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
bool setReportList(CReportDefinitionVector *pReportList)
Definition: CCopasiXML.cpp:339
const CCopasiVector< CPlotItem > & getItems() const
const std::string & getFillColor() const
void saveStyleElements(const CLStyle &style)
const CCopasiVector< CChemEqElement > & getModifiers() const
Definition: CChemEq.cpp:66
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
bool saveLayoutList()
std::vector< CModelParameter * >::const_iterator const_iterator
void setText(const std::string &t)
Definition: CLGlyphs.cpp:250
void savePosition(const CLPoint &p, const std::string &tag="Position")
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
bool endSaveElement(const std::string &name)
virtual const std::string & getKey() const
CListOfLayouts * mpLayoutList
Definition: CCopasiXML.h:589
bool saveGUI()
const std::string & getKey() const
std::vector< CLRenderPoint * > * getListOfElements()
Definition: CLPolygon.cpp:108
std::vector< CRegisteredObjectName > * getBodyAddr()
std::string UTCTimeStamp()
Definition: utility.cpp:64
Type getType() const
std::string toString() const
const ModelType & getModelType() const
Definition: CModel.cpp:2339
bool freeReportList()
Definition: CCopasiXML.cpp:351
COutputDefinitionVector * getPlotList() const
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
UnsupportedAnnotation & getUnsupportedAnnotations()
void setGUI(SCopasiXMLGUI *pGUI)
void setFunctionList(CCopasiVectorN< CFunction > *pFunctionList)
const std::string & getName() const
CCopasiVectorN< CCopasiTask > * mpTaskList
Definition: CCopasiXML.h:565
const CLRelAbsVector & basePoint1_Z() const
const CLRelAbsVector & getFocalPointX() const
std::string createValueString() const
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
static std::string createStringFromSet(const std::set< std::string > &set)
Definition: CLStyle.cpp:182
bool getIsEnabledRotationalMapping() const
const CLRelAbsVector & getCX() const
Definition: CLEllipse.cpp:127
void saveRenderInformationDefinitionElements(const CLRenderInformationBase &renderInfo)
const CLRelAbsVector & x() const
const CCopasiParameter::Value & getValue(const std::string &name) const
int getCurrentLineNumber() const
Definition: CExpat.h:470
const CLRelAbsVector & basePoint1_Y() const
bool parse(const char *pszBuffer, int nLength=-1, bool fIsFinal=true)
Definition: CExpat.h:135
static const std::string XMLRole[]
const std::string & getSBMLId() const
Definition: CEvent.cpp:403
static const char * XMLType[]
CLGradientBase * getGradientDefinition(size_t index)
SPREADMETHOD getSpreadMethod() const
static const char * XMLSubType[]
const bool & getFireAtInitialTime() const
Definition: CEvent.cpp:429
Definition: CModel.h:50
const Type & getType() const
virtual bool load(std::istream &is, const std::string &pwd)
Definition: CCopasiXML.cpp:169
C_INT32 getVersionDevel() const
Definition: CVersion.cpp:129
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
const CModelEntity::Status & getStatus() const
std::string getVolumeUnitName() const
Definition: CModel.cpp:2170
const CLRelAbsVector & getX() const
Definition: CLText.cpp:206
CModel * mpModel
Definition: CCopasiXML.h:553
const std::string & getId() const
CReportDefinition * getReportDefinition()
Definition: CReport.cpp:83
bool saveFunctionList()
const std::vector< std::vector< std::string > > & getParameterMappings() const
Definition: CReaction.h:285
const XML_LChar * getErrorString()
Definition: CExpat.h:445
static bool makePathRelative(std::string &absolutePath, const std::string &relativeTo)
Definition: CDirEntry.cpp:434
bool isSetMatrix() const
bool hasValidModelReference() const
bool mMCXML21Issued
Definition: CCopasiXML.h:604
bool isIdentityMatrix() const
const std::string & getVersion() const
Definition: CVersion.cpp:139
bool saveReportSection(const std::string &name, const std::vector< CRegisteredObjectName > &section)
CCopasiVectorN< CCopasiTask > * getTaskList() const
Definition: CCopasiXML.cpp:305
bool buildFunctionList()
void saveRadialGradient(const CLRadialGradient &gradient)
bool saveTaskList()
bool haveReportList() const
Definition: CCopasiXML.cpp:348
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
std::vector< CRegisteredObjectName > * getHeaderAddr()
const CLCurve & getCurve() const
const CLRelAbsVector & getYPoint2() const
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
void saveRenderTextElement(const CLText &text)
void saveGlobalRenderInformation(const CLGlobalRenderInformation &renderInfo)
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
virtual const std::string & getKey() const
Definition: CEvent.cpp:287
void fixBuild81()
Definition: CScanTask.cpp:322
unsigned C_INT32 getTickFactor() const
Definition: CSlider.cpp:366
virtual bool save(std::ostream &os, const std::string &relativeTo)
Definition: CCopasiXML.cpp:102
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
Scale getScaling() const
Definition: CSlider.cpp:369
bool saveModelParameter(const CModelParameter *pModelParameter)
Definition: CCopasiXML.cpp:963
const CLRelAbsVector & getXPoint1() const
const std::string & getInfix() const
const std::string & getGraphicalObjectKey() const
Definition: CLGlyphs.h:163
void setLayoutList(CListOfLayouts *pLayoutList)
CFunctionParameters & getVariables()
Definition: CFunction.cpp:148
bool add(const std::string &name, const CType &value)
const std::vector< unsigned int > & getDashArray() const
CModelEntity ** getEntities()
Definition: CState.cpp:204
const CLRelAbsVector & getZ() const
CListOfLayouts * getLayoutList() const
const CLDimensions & getDimensions() const
Definition: CLayout.h:76
const CLPoint & getStart() const
Definition: CLCurve.h:74
CModel * getModel() const
const CCopasiVector< CLGlobalRenderInformation > & getListOfGlobalRenderInformationObjects() const
void saveRenderCurveElement(const CLRenderCurve &curve)
const CLRelAbsVector & getFocalPointZ() const
static const CVersion VERSION
Definition: CVersion.h:164