COPASI API  4.16.103
SBMLDocumentLoader.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef SBMLDOCUMENTLOADER_H_
16 #define SBMLDOCUMENTLOADER_H_
17 
18 #include <string>
19 #include <map>
20 
22 #include "CLLocalStyle.h"
23 #include "CLGradientBase.h"
24 
25 #include <sbml/ListOf.h>
26 
27 class CCopasiObject;
28 class CCopasiContainer;
29 class CListOfLayouts;
30 class CLayout;
31 
32 class CLTransformation2D;
34 class CLTransformation2D;
35 
36 class Layout;
37 class SBase;
38 class TextGlyph;
39 
40 class Transformation2D;
41 class RenderInformationBase;
42 
44 {
45 
46 public:
47 
48  static void readListOfLayouts(CListOfLayouts & lol,
49  const ListOf & sbmlList,
50  const std::map<CCopasiObject*, SBase*> & copasimodelmap);
51 
52  // createLayout is now needed by the code for the CellDesigner import
53  static CLayout * createLayout(const Layout & sbmlLayout,
54  const std::map<std::string, std::string> & modelmap,
55  std::map<std::string, std::string> & layoutmap
56  , const std::map<std::string, std::string>& globalIdToKeyMap
57  , const CCopasiContainer * pParent = NULL
58  );
59 
60 protected:
61 
62  /**
63  * resolves the graphical object reference of the text glyph
64  */
65  static void postprocessTextGlyph(const TextGlyph & sbml,
66  const std::map<std::string, std::string> & layoutmap);
67 
68 public:
69  /**
70  * converts the sbml id for render render information objects into the corresponding copasi key
71  * where they are used in a reference.
72  * This is used for the import from SBML.
73  */
74  template<typename RENDER_INFORMATION>
76  const std::map<std::string, std::string> & idToKeyMap)
77  {
78  size_t i, iMax = list.size();
79  RENDER_INFORMATION* pRI = NULL;
80  std::map<std::string, std::string>::const_iterator pos;
81 
82  for (i = 0; i < iMax; ++i)
83  {
84  pRI = list[i];
85 
86  if (pRI->getReferenceRenderInformationKey().find_first_not_of(" \t\n\r") != std::string::npos)
87  {
88  pos = idToKeyMap.find(pRI->getReferenceRenderInformationKey());
89  assert(pos != idToKeyMap.end());
90  pRI->setReferenceRenderInformationKey(pos->second);
91  }
92  }
93  }
94 
95  /**
96  * Converts references to ids of layout objects to the corresponding key.
97  */
98  static void convertLayoutObjectIds(CLLocalStyle& style, const std::map<std::string, std::string>& idToKeyMap);
99 
100  /**
101  * converts references to color ids, gradient ids and/or line ending ids in graphical primitives
102  * to references to the corresponding keys.
103  */
104  static void convertPropertyIds(CLTransformation2D* pObject,
105  const std::map<std::string, std::string>& colorIdToKeyMap,
106  const std::map<std::string, std::string>& gradientIdToKeyMap,
107  const std::map<std::string, std::string>& lineEndingIdToKeyMap);
108 
109  /**
110  * converts references to color ids in gradient stops
111  * to references to the corresponding keys.
112  static void convertColorIds(CLGradientBase& gradient,
113  const std::map<std::string,std::string>& colorIdToKeyMap);
114  */
115 
116  /**
117  * converts the copasi key for global render information objects into the corresponding sbml id
118  * where they are used in a reference.
119  * This is used for the SBML export.
120  */
121  template<typename RENDER_INFORMATION>
122  static void convertRenderInformationReferencesKeys(ListOf& list,
123  const std::map<std::string, std::string> & keyToIdMap)
124  {
125  size_t i, iMax = list.size();
126  RENDER_INFORMATION* pRI = NULL;
127  std::map<std::string, std::string>::const_iterator pos;
128 
129  for (i = 0; i < iMax; ++i)
130  {
131  pRI = dynamic_cast<RENDER_INFORMATION*>(list.get((unsigned int) i));
132  assert(pRI != NULL);
133 
134  if (pRI->getReferenceRenderInformationId().find_first_not_of(" \t\n\r") != std::string::npos)
135  {
136  pos = keyToIdMap.find(pRI->getReferenceRenderInformationId());
137  assert(pos != keyToIdMap.end());
138  pRI->setReferenceRenderInformationId(pos->second);
139  }
140  }
141  }
142 
143  /**
144  * Converts references to keys of layout objects to the corresponding id.
145  */
146  static void convertLayoutObjectKeys(LocalStyle& style, const std::map<std::string, std::string>& keyToIdMap);
147 
148  /**
149  * converts references to color keys, gradient keys and/or line ending keys in graphical primitives
150  * to references to the corresponding Ids.
151  template<typename RENDER_INFORMATION>
152  static void convertPropertyKeys(RENDER_INFORMATION* pObject,
153  const std::map<std::string,std::string>& colorKeyToIdMap,
154  const std::map<std::string,std::string>& gradientKeyToIdMap,
155  const std::map<std::string,std::string>& lineEndingKeyToIdMap);
156  */
157 
158  /**
159  * converts references to color keys, gradient keys and/or line ending keys in graphical primitives
160  * to references to the corresponding Ids.
161  static void convertPropertyKeys(Transformation2D* pObject,
162  const std::map<std::string,std::string>& colorKeyToIdMap,
163  const std::map<std::string,std::string>& gradientKeyToIdMap,
164  const std::map<std::string,std::string>& lineEndingKeyToIdMap);
165  */
166 
167  /**
168  * converts references to color ids in gradient stops
169  * to references to the corresponding keys.
170  static void convertColorKeys(GradientBase& gradient,
171  const std::map<std::string,std::string>& colorKeyToIdMap);
172  */
173 
174  /**
175  * Adds all elements of the source map into the dest map if an element with the same key does not already exist in the dest map.
176  */
177  static void combineMaps(
178  const std::map<std::string, std::string>& sourceMap,
179  std::map<std::string, std::string>& destMap
180  );
181 
182  /**
183  * Creates maps of maps for the colors, gradients and line endings of the given of render information
184  * objects.
185  * Those maps can than be used to convert the id of a color, gradient or lineEnding from the SBML model
186  * to the key used in the COPASI model.
187  template<typename RENDER_INFORMATION>
188  static void expandIdToKeyMaps(const CLRenderInformationBase* pRenderInfo,
189  CCopasiVector<RENDER_INFORMATION>& renderInformationVector,
190  std::map<std::string,std::map<std::string,std::string> >& colorIdToKeyMapMap,
191  std::map<std::string,std::map<std::string,std::string> >& gradientIdToKeyMapMap,
192  std::map<std::string,std::map<std::string,std::string> >& lineEndingIdToKeyMapMap,
193  const std::map<std::string,std::map<std::string,std::string> >& unexpandedColorIdToKeyMapMap,
194  const std::map<std::string,std::map<std::string,std::string> >& unexpandedGradientIdToKeyMapMap,
195  const std::map<std::string,std::map<std::string,std::string> >& unexpandedLineEndingIdToKeyMapMap,
196  std::set<std::string>& chain,
197  const std::map<std::string,std::map<std::string,std::string> >& expandedGlobalColorIdToKeyMapMap,
198  const std::map<std::string,std::map<std::string,std::string> >& expandedGlobalGradientIdToKeyMapMap,
199  const std::map<std::string,std::map<std::string,std::string> >& expandedGlobalLineEndingIdToKeyMapMap
200  );
201  */
202 
203  /**
204  * Creates maps of maps for the colors, gradients and line endings of the given of render information
205  * objects.
206  * Those maps can than be used to convert the id of a color, gradient or lineEnding from the SBML model
207  * to the key used in the COPASI model.
208  static void expandKeyToIdMaps(const RenderInformationBase* pRenderInfo,
209  ListOf& renderInformationVector,
210  std::map<std::string,std::map<std::string,std::string> >& colorKeyToIdMapMap,
211  std::map<std::string,std::map<std::string,std::string> >& gradientKeyToIdMapMap,
212  std::map<std::string,std::map<std::string,std::string> >& lineEndingKeyToIdMapMap,
213  const std::map<std::string,std::map<std::string,std::string> >& unexpandedColorKeyToIdMapMap,
214  const std::map<std::string,std::map<std::string,std::string> >& unexpandedGradientKeyToIdMapMap,
215  const std::map<std::string,std::map<std::string,std::string> >& unexpandedLineEndingKeyToIdMapMap,
216  std::set<std::string>& chain,
217  const std::map<std::string,std::map<std::string,std::string> >& expandedGlobalColorKeyToIdMapMap,
218  const std::map<std::string,std::map<std::string,std::string> >& expandedGlobalGradientKeyToIdMapMap,
219  const std::map<std::string,std::map<std::string,std::string> >& expandedGlobalLineEndingKeyToIdMapMap
220  );
221  */
222 };
223 
224 #endif /*SBMLDOCUMENTLOADER_H_*/
static void convertPropertyIds(CLTransformation2D *pObject, const std::map< std::string, std::string > &colorIdToKeyMap, const std::map< std::string, std::string > &gradientIdToKeyMap, const std::map< std::string, std::string > &lineEndingIdToKeyMap)
virtual size_t size() const
static void convertLayoutObjectKeys(LocalStyle &style, const std::map< std::string, std::string > &keyToIdMap)
static void convertRenderInformationReferencesIds(CCopasiVector< RENDER_INFORMATION > &list, const std::map< std::string, std::string > &idToKeyMap)
static CLayout * createLayout(const Layout &sbmlLayout, const std::map< std::string, std::string > &modelmap, std::map< std::string, std::string > &layoutmap, const std::map< std::string, std::string > &globalIdToKeyMap, const CCopasiContainer *pParent=NULL)
static void convertRenderInformationReferencesKeys(ListOf &list, const std::map< std::string, std::string > &keyToIdMap)
static void convertLayoutObjectIds(CLLocalStyle &style, const std::map< std::string, std::string > &idToKeyMap)
static void combineMaps(const std::map< std::string, std::string > &sourceMap, std::map< std::string, std::string > &destMap)
static void postprocessTextGlyph(const TextGlyph &sbml, const std::map< std::string, std::string > &layoutmap)
static void readListOfLayouts(CListOfLayouts &lol, const ListOf &sbmlList, const std::map< CCopasiObject *, SBase * > &copasimodelmap)