COPASI API  4.16.103
Static Public Member Functions | Static Protected Member Functions | List of all members
SBMLDocumentLoader Class Reference

#include <SBMLDocumentLoader.h>

Static Public Member Functions

static void combineMaps (const std::map< std::string, std::string > &sourceMap, std::map< std::string, std::string > &destMap)
 
static void convertLayoutObjectIds (CLLocalStyle &style, const std::map< std::string, std::string > &idToKeyMap)
 
static void convertLayoutObjectKeys (LocalStyle &style, const std::map< std::string, std::string > &keyToIdMap)
 
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)
 
template<typename RENDER_INFORMATION >
static void convertRenderInformationReferencesIds (CCopasiVector< RENDER_INFORMATION > &list, const std::map< std::string, std::string > &idToKeyMap)
 
template<typename RENDER_INFORMATION >
static void convertRenderInformationReferencesKeys (ListOf &list, const std::map< std::string, std::string > &keyToIdMap)
 
static CLayoutcreateLayout (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 readListOfLayouts (CListOfLayouts &lol, const ListOf &sbmlList, const std::map< CCopasiObject *, SBase * > &copasimodelmap)
 

Static Protected Member Functions

static void postprocessTextGlyph (const TextGlyph &sbml, const std::map< std::string, std::string > &layoutmap)
 

Detailed Description

Definition at line 43 of file SBMLDocumentLoader.h.

Member Function Documentation

void SBMLDocumentLoader::combineMaps ( const std::map< std::string, std::string > &  sourceMap,
std::map< std::string, std::string > &  destMap 
)
static

converts references to color keys, gradient keys and/or line ending keys in graphical primitives to references to the corresponding Ids. template<typename RENDER_INFORMATION> static void convertPropertyKeys(RENDER_INFORMATION* pObject, const std::map<std::string,std::string>& colorKeyToIdMap, const std::map<std::string,std::string>& gradientKeyToIdMap, const std::map<std::string,std::string>& lineEndingKeyToIdMap); converts references to color keys, gradient keys and/or line ending keys in graphical primitives to references to the corresponding Ids. static void convertPropertyKeys(Transformation2D* pObject, const std::map<std::string,std::string>& colorKeyToIdMap, const std::map<std::string,std::string>& gradientKeyToIdMap, const std::map<std::string,std::string>& lineEndingKeyToIdMap); converts references to color ids in gradient stops to references to the corresponding keys. static void convertColorKeys(GradientBase& gradient, const std::map<std::string,std::string>& colorKeyToIdMap); 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.

converts references to color keys, gradient keys and/or line ending keys in graphical primitives to references to the corresponding Ids. void SBMLDocumentLoader::convertPropertyKeys(Transformation2D* pObject, const std::map<std::string,std::string>& colorKeyToIdMap, const std::map<std::string,std::string>& gradientKeyToIdMap, const std::map<std::string,std::string>& lineEndingKeyToIdMap) { GraphicalPrimitive1D* pGP1=dynamic_cast<GraphicalPrimitive1D*>(pObject); if(pGP1 != NULL) { std::map<std::string,std::string>::const_iterator pos; fix the stroke color std::string s=pGP1->getStroke(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none" && s[0] != '#') { pos=colorKeyToIdMap.find(s); check if we found the color, else it must be a gradient if(pos==colorKeyToIdMap.end()) { pos=gradientKeyToIdMap.find(s); assert(pos != gradientKeyToIdMap.end()); pGP1->setStroke(pos->second); } else { pGP1->setStroke(pos->second); } } GraphicalPrimitive2D* pGP2=dynamic_cast<GraphicalPrimitive2D*>(pObject); if(pGP2 != NULL) { fix the fill color std::string s=pGP2->getFillColor(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none" && s[0] != '#') { pos=colorKeyToIdMap.find(s); check if we found the color, else it must be a gradient if(pos==colorKeyToIdMap.end()) { pos=gradientKeyToIdMap.find(s); assert(pos != gradientKeyToIdMap.end()); pGP2->setFillColor(pos->second); } else { pGP2->setFillColor(pos->second); } } Group* pG=dynamic_cast<Group*>(pObject); if(pG != NULL) { fix the line endings s=pG->getStartHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingKeyToIdMap.find(s); assert(pos != lineEndingKeyToIdMap.end()); pG->setStartHead(pos->second); } s=pG->getEndHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingKeyToIdMap.find(s); assert(pos != lineEndingKeyToIdMap.end()); pG->setEndHead(pos->second); } call this method for all children size_t i,iMax=pG->getNumElements(); for(i=0; i < iMax; ++i) { SBMLDocumentLoader::convertPropertyKeys(dynamic_cast<Transformation2D*>(pG->getElement(i)),colorKeyToIdMap,gradientKeyToIdMap,lineEndingKeyToIdMap); } } } else { RenderCurve* pC=dynamic_cast<RenderCurve*>(pObject); if(pC != NULL) { fix the line endings s=pC->getStartHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingKeyToIdMap.find(s); assert(pos != lineEndingKeyToIdMap.end()); pC->setStartHead(pos->second); } s=pC->getEndHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingKeyToIdMap.find(s); assert(pos != lineEndingKeyToIdMap.end()); pC->setEndHead(pos->second); } } } } } converts references to color ids in gradient stops to references to the corresponding keys. void SBMLDocumentLoader::convertColorKeys(GradientBase& gradient, const std::map<std::string,std::string>& colorKeyToIdMap) { size_t i,iMax=gradient.getNumGradientStops(); GradientStop* pStop=NULL; std::map<std::string,std::string>::const_iterator pos; for(i=0; i < iMax; ++i) { pStop=gradient.getGradientStop(i); std::string color=pStop->getStopColor(); if(color.find_first_not_of(" \t\n\r") != std::string::npos && color != "none" && color[0] != '#') { pos=colorKeyToIdMap.find(color); assert(pos!=colorKeyToIdMap.end()); pStop->setStopColor(pos->second); } } } 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.

Definition at line 601 of file SBMLDocumentLoader.cpp.

605 {
606  std::map<std::string, std::string>::const_iterator it = sourceMap.begin(), endit = sourceMap.end();
607 
608  while (it != endit)
609  {
610  if (destMap.find(it->first) == destMap.end())
611  {
612  destMap.insert(*it);
613  }
614 
615  ++it;
616  }
617 }
void SBMLDocumentLoader::convertLayoutObjectIds ( CLLocalStyle style,
const std::map< std::string, std::string > &  idToKeyMap 
)
static

Converts references to ids of layout objects to the corresponding key.

Definition at line 313 of file SBMLDocumentLoader.cpp.

References CLLocalStyle::getKeyList(), and CLLocalStyle::setKeyList().

Referenced by createLayout().

314 {
315  std::set<std::string> keys;
316  std::map<std::string, std::string>::const_iterator pos;
317  std::set<std::string>::const_iterator it = style.getKeyList().begin(), endit = style.getKeyList().end();
318 
319  while (it != endit)
320  {
321  pos = idToKeyMap.find(*it);
322  assert(pos != idToKeyMap.end());
323  keys.insert(pos->second);
324  ++it;
325  }
326 
327  style.setKeyList(keys);
328 }
const std::set< std::string > & getKeyList() const
void setKeyList(const std::set< std::string > &keyList)
void SBMLDocumentLoader::convertLayoutObjectKeys ( LocalStyle &  style,
const std::map< std::string, std::string > &  keyToIdMap 
)
static

Converts references to keys of layout objects to the corresponding id.

converts references to color ids, gradient ids and/or line ending ids in graphical primitives to references to the corresponding keys. void SBMLDocumentLoader::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) { CLGraphicalPrimitive1D* pGP1=dynamic_cast<CLGraphicalPrimitive1D*>(pObject); if(pGP1 != NULL) { std::map<std::string,std::string>::const_iterator pos; fix the stroke color std::string s=pGP1->getStroke(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none" && s[0] != '#') { pos=colorIdToKeyMap.find(s); check if we found the color, else it must be a gradient if(pos==colorIdToKeyMap.end()) { pos=gradientIdToKeyMap.find(s); assert(pos != gradientIdToKeyMap.end()); pGP1->setStroke(pos->second); } else { pGP1->setStroke(pos->second); } } CLGraphicalPrimitive2D* pGP2=dynamic_cast<CLGraphicalPrimitive2D*>(pObject); if(pGP2 != NULL) { fix the fill color std::string s=pGP2->getFillColor(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none" && s[0] != '#') { pos=colorIdToKeyMap.find(s); check if we found the color, else it must be a gradient if(pos==colorIdToKeyMap.end()) { pos=gradientIdToKeyMap.find(s); assert(pos != gradientIdToKeyMap.end()); pGP2->setFillColor(pos->second); } else { pGP2->setFillColor(pos->second); } } CLGroup* pG=dynamic_cast<CLGroup*>(pObject); if(pG != NULL) { fix the line endings s=pG->getStartHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingIdToKeyMap.find(s); assert(pos != lineEndingIdToKeyMap.end()); pG->setStartHead(pos->second); } s=pG->getEndHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingIdToKeyMap.find(s); assert(pos != lineEndingIdToKeyMap.end()); pG->setEndHead(pos->second); } call this method for all children size_t i,iMax=pG->getNumElements(); for(i=0; i < iMax; ++i) { SBMLDocumentLoader::convertPropertyIds(dynamic_cast<CLTransformation2D*>(pG->getElement(i)),colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap); } } } else { CLRenderCurve* pC=dynamic_cast<CLRenderCurve*>(pObject); if(pC != NULL) { fix the line endings s=pC->getStartHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingIdToKeyMap.find(s); assert(pos != lineEndingIdToKeyMap.end()); pC->setStartHead(pos->second); } s=pC->getEndHead(); if(s.find_first_not_of(" \t\n\r") != std::string::npos && s != "none") { pos=lineEndingIdToKeyMap.find(s); assert(pos != lineEndingIdToKeyMap.end()); pC->setEndHead(pos->second); } } } } } converts references to color ids in gradient stops to references to the corresponding keys. void SBMLDocumentLoader::convertColorIds(CLGradientBase& gradient, const std::map<std::string,std::string>& colorIdToKeyMap) { size_t i,iMax=gradient.getNumGradientStops(); CLGradientStop* pStop=NULL; std::map<std::string,std::string>::const_iterator pos; for(i=0; i < iMax; ++i) { pStop=gradient.getGradientStop(i); std::string color=pStop->getStopColor(); if(color.find_first_not_of(" \t\n\r") != std::string::npos && color != "none" && color[0] != '#') { pos=colorIdToKeyMap.find(color); assert(pos!=colorIdToKeyMap.end()); pStop->setStopColor(pos->second); } } } Converts references to keys of layout objects to the corresponding id.

Definition at line 457 of file SBMLDocumentLoader.cpp.

Referenced by CLayout::exportToSBML().

458 {
459  std::set<std::string> ids;
460  std::map<std::string, std::string>::const_iterator pos;
461  std::set<std::string>::const_iterator it = style.getIdList().begin(), endit = style.getIdList().end();
462 
463  while (it != endit)
464  {
465  pos = keyToIdMap.find(*it);
466  assert(pos != keyToIdMap.end());
467  ids.insert(pos->second);
468  ++it;
469  }
470 
471  style.setIdList(ids);
472 }
static void SBMLDocumentLoader::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 
)
static

converts references to color ids, gradient ids and/or line ending ids in graphical primitives to references to the corresponding keys.

template<typename RENDER_INFORMATION >
static void SBMLDocumentLoader::convertRenderInformationReferencesIds ( CCopasiVector< RENDER_INFORMATION > &  list,
const std::map< std::string, std::string > &  idToKeyMap 
)
inlinestatic

converts the sbml id for render render information objects into the corresponding copasi key where they are used in a reference. This is used for the import from SBML.

Definition at line 75 of file SBMLDocumentLoader.h.

References CCopasiVector< T >::size().

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  }
virtual size_t size() const
template<typename RENDER_INFORMATION >
static void SBMLDocumentLoader::convertRenderInformationReferencesKeys ( ListOf &  list,
const std::map< std::string, std::string > &  keyToIdMap 
)
inlinestatic

converts references to color ids in gradient stops to references to the corresponding keys. static void convertColorIds(CLGradientBase& gradient, const std::map<std::string,std::string>& colorIdToKeyMap); converts the copasi key for global render information objects into the corresponding sbml id where they are used in a reference. This is used for the SBML export.

Definition at line 122 of file SBMLDocumentLoader.h.

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  }
CLayout * SBMLDocumentLoader::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

Definition at line 142 of file SBMLDocumentLoader.cpp.

References CLayout::addCompartmentGlyph(), CLayout::addGeneralGlyph(), CLayout::addLocalRenderInformation(), CLayout::addMetaboliteGlyph(), CLayout::addReactionGlyph(), CLayout::addTextGlyph(), C_INT32, convertLayoutObjectIds(), CLRenderInformationBase::getKey(), CLayout::getListOfLocalRenderInformationObjects(), CLLocalRenderInformation::getNumStyles(), CLLocalRenderInformation::getStyle(), and postprocessTextGlyph().

Referenced by DataModelGUI::importCellDesigner(), and readListOfLayouts().

148 {
149  CLayout* layout = new CLayout(sbmlLayout, layoutmap, pParent);
150 
151  //compartments
152  unsigned C_INT32 i, iMax = sbmlLayout.getListOfCompartmentGlyphs()->size();
153 
154  for (i = 0; i < iMax; ++i)
155  {
156  const CompartmentGlyph* tmp
157  = dynamic_cast<const CompartmentGlyph*>(sbmlLayout.getListOfCompartmentGlyphs()->get(i));
158 
159  if (tmp)
160  layout->addCompartmentGlyph(new CLCompartmentGlyph(*tmp, modelmap, layoutmap));
161  }
162 
163  //species
164  iMax = sbmlLayout.getListOfSpeciesGlyphs()->size();
165 
166  for (i = 0; i < iMax; ++i)
167  {
168  const SpeciesGlyph* tmp
169  = dynamic_cast<const SpeciesGlyph*>(sbmlLayout.getListOfSpeciesGlyphs()->get(i));
170 
171  if (tmp)
172  layout->addMetaboliteGlyph(new CLMetabGlyph(*tmp, modelmap, layoutmap));
173  }
174 
175  //reactions
176  iMax = sbmlLayout.getListOfReactionGlyphs()->size();
177 
178  for (i = 0; i < iMax; ++i)
179  {
180  const ReactionGlyph* tmp
181  = dynamic_cast<const ReactionGlyph*>(sbmlLayout.getListOfReactionGlyphs()->get(i));
182 
183  if (tmp)
184  layout->addReactionGlyph(new CLReactionGlyph(*tmp, modelmap, layoutmap));
185  }
186 
187  //text
188  iMax = sbmlLayout.getListOfTextGlyphs()->size();
189 
190  for (i = 0; i < iMax; ++i)
191  {
192  const TextGlyph* tmp
193  = dynamic_cast<const TextGlyph*>(sbmlLayout.getListOfTextGlyphs()->get(i));
194 
195  if (tmp)
196  layout->addTextGlyph(new CLTextGlyph(*tmp, modelmap, layoutmap));
197  }
198 
199  //additional
200  iMax = sbmlLayout.getListOfAdditionalGraphicalObjects()->size();
201 
202  for (i = 0; i < iMax; ++i)
203  {
204  const GraphicalObject* graphical
205  = dynamic_cast<const GraphicalObject*>(sbmlLayout.getListOfAdditionalGraphicalObjects()->get(i));
206 
207  if (graphical)
208  layout->addGeneralGlyph(new CLGeneralGlyph(*graphical, modelmap, layoutmap));
209  }
210 
211  //second pass text (the text glyph can refer to other glyphs. These references can)
212  //only be resolved after all glyphs are created).
213  iMax = sbmlLayout.getListOfTextGlyphs()->size();
214 
215  for (i = 0; i < iMax; ++i)
216  {
217  const TextGlyph* tmp
218  = dynamic_cast<const TextGlyph*>(sbmlLayout.getListOfTextGlyphs()->get(i));
219 
220  if (tmp)
221  postprocessTextGlyph(*tmp, layoutmap);
222  }
223 
224  RenderLayoutPlugin* rlPlugin = (RenderLayoutPlugin*) sbmlLayout.getPlugin("render");
225  assert(rlPlugin != NULL);
226 
227  // import the local render information
228  iMax = rlPlugin->getNumLocalRenderInformationObjects();
229  std::map<std::string, std::string> idToKeyMap;
230  CLLocalRenderInformation* pLRI = NULL;
231 
232  for (i = 0; i < iMax; ++i)
233  {
234  //colorIdToKeyMap.clear();
235  //gradientIdToKeyMap.clear();
236  //lineEndingIdToKeyMap.clear();
237  //pLRI=new CLLocalRenderInformation(*sbmlLayout.getRenderInformation(i),colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap,layout);
238  pLRI = new CLLocalRenderInformation(*rlPlugin->getRenderInformation(i), layout);
239 
240  if (rlPlugin->getRenderInformation(i)->isSetId())
241  idToKeyMap.insert(std::pair<std::string, std::string>(rlPlugin->getRenderInformation(i)->getId(), pLRI->getKey()));
242  else
243  idToKeyMap.insert(std::pair<std::string, std::string>(pLRI->getKey(), pLRI->getKey()));
244 
245  //colorIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),colorIdToKeyMap));
246  //gradientIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),gradientIdToKeyMap));
247  //lineEndingIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),lineEndingIdToKeyMap));
248  // fix the references to layout objects in id lists
249  size_t j, jMax = pLRI->getNumStyles();
250 
251  for (j = 0; j < jMax; j++)
252  {
254  }
255 
256  layout->addLocalRenderInformation(pLRI);
257  }
258 
259  // fix the references
260  // we have to consider the global ids as well
261  // since all ids in these two map should be unique, we can just combine them
262  size_t count = idToKeyMap.size() + globalIdToKeyMap.size();
263  idToKeyMap.insert(globalIdToKeyMap.begin(), globalIdToKeyMap.end());
264  // make sure the ids were really unique
265  assert(idToKeyMap.size() == count);
266  SBMLDocumentLoader::convertRenderInformationReferencesIds<CLLocalRenderInformation>(layout->getListOfLocalRenderInformationObjects(), idToKeyMap);
267  // fix the color ids, gradient ids and line ending ids.
268 
269  return layout;
270 }
void addReactionGlyph(CLReactionGlyph *glyph)
Definition: CLayout.cpp:251
void addGeneralGlyph(CLGeneralGlyph *glyph)
Definition: CLayout.cpp:263
void addLocalRenderInformation(CLLocalRenderInformation *pRenderInfo)
Definition: CLayout.cpp:646
const CCopasiVector< CLLocalRenderInformation > & getListOfLocalRenderInformationObjects() const
Definition: CLayout.h:149
CLLocalStyle * getStyle(size_t i)
#define C_INT32
Definition: copasi.h:90
void addMetaboliteGlyph(CLMetabGlyph *glyph)
Definition: CLayout.cpp:245
void addTextGlyph(CLTextGlyph *glyph)
Definition: CLayout.cpp:257
static void convertLayoutObjectIds(CLLocalStyle &style, const std::map< std::string, std::string > &idToKeyMap)
void addCompartmentGlyph(CLCompartmentGlyph *glyph)
Definition: CLayout.cpp:239
const std::string & getKey() const
static void postprocessTextGlyph(const TextGlyph &sbml, const std::map< std::string, std::string > &layoutmap)
void SBMLDocumentLoader::postprocessTextGlyph ( const TextGlyph &  sbml,
const std::map< std::string, std::string > &  layoutmap 
)
staticprotected

resolves the graphical object reference of the text glyph

Definition at line 273 of file SBMLDocumentLoader.cpp.

References CKeyFactory::get(), CCopasiRootContainer::getKeyFactory(), and CLTextGlyph::setGraphicalObjectKey().

Referenced by createLayout().

275 {
276  //the corresponding CLTextGlyph should already exist. Let's find it...
277  CLTextGlyph * pTg = NULL;
278 
279  if (sbml.getId() != "")
280  {
281  std::map<std::string, std::string>::const_iterator it = layoutmap.find(sbml.getId());
282 
283  if (it != layoutmap.end())
284  pTg = dynamic_cast<CLTextGlyph *>(CCopasiRootContainer::getKeyFactory()->get(it->second));
285 
286  if (!pTg)
287  {
288  //error?
289  return;
290  }
291  }
292  else
293  {
294  //error?
295  return;
296  }
297 
298  //resolve the graphical object reference
299  assert(pTg);
300 
301  if (sbml.getGraphicalObjectId() != "")
302  {
303  std::map<std::string, std::string>::const_iterator it = layoutmap.find(sbml.getGraphicalObjectId());
304 
305  if (it != layoutmap.end())
306  pTg->setGraphicalObjectKey(it->second);
307  }
308 }
CCopasiObject * get(const std::string &key)
void setGraphicalObjectKey(const std::string &k)
Definition: CLGlyphs.cpp:338
static CKeyFactory * getKeyFactory()
void SBMLDocumentLoader::readListOfLayouts ( CListOfLayouts lol,
const ListOf &  sbmlList,
const std::map< CCopasiObject *, SBase * > &  copasimodelmap 
)
static

Definition at line 47 of file SBMLDocumentLoader.cpp.

References CListOfLayouts::addGlobalRenderInformation(), CListOfLayouts::addLayout(), C_INT32, createLayout(), SBMLUtils::getIdFromSBase(), CLRenderInformationBase::getKey(), and CListOfLayouts::getListOfGlobalRenderInformationObjects().

Referenced by SBMLImporter::parseSBML().

50 {
51  unsigned C_INT32 i, iMax;
52 
53  // read the global render information
54  const ListOfLayouts* pLoL = dynamic_cast<const ListOfLayouts*>(&sbmlList);
55  assert(pLoL != NULL);
56  RenderListOfLayoutsPlugin* rlolPlugin = (RenderListOfLayoutsPlugin*) pLoL ->getPlugin("render");
57 
58  if (rlolPlugin == NULL)
59  {
60  const_cast<SBMLDocument *>(pLoL->getSBMLDocument())->enablePackage(RenderExtension::getXmlnsL3V1V1(), "render", true);
61  rlolPlugin = (RenderListOfLayoutsPlugin*) pLoL ->getPlugin("render");
62  }
63 
64  iMax = rlolPlugin->getNumGlobalRenderInformationObjects();
65  std::map<std::string, std::string> idToKeyMap;
66  CLGlobalRenderInformation* pGRI = NULL;
67 
68  /*
69  std::map<std::string,std::string> colorIdToKeyMap;
70  std::map<std::string,std::string> gradientIdToKeyMap;
71  std::map<std::string,std::string> lineEndingIdToKeyMap;
72  std::map<std::string,std::map<std::string,std::string> > colorIdToKeyMapMap;
73  std::map<std::string,std::map<std::string,std::string> > gradientIdToKeyMapMap;
74  std::map<std::string,std::map<std::string,std::string> > lineEndingIdToKeyMapMap;
75  */
76  for (i = 0; i < iMax; ++i)
77  {
78  //colorIdToKeyMap.clear();
79  //gradientIdToKeyMap.clear();
80  //lineEndingIdToKeyMap.clear();
81  //pGRI=new CLGlobalRenderInformation(*pLoL->getRenderInformation(i),colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap,&lol);
82  pGRI = new CLGlobalRenderInformation(*rlolPlugin->getRenderInformation(i), &lol);
83 
84  if (rlolPlugin->getRenderInformation(i)->isSetId())
85  idToKeyMap.insert(std::pair<std::string, std::string>(rlolPlugin->getRenderInformation(i)->getId(), pGRI->getKey()));
86  else
87  idToKeyMap.insert(std::pair<std::string, std::string>(pGRI->getKey(), pGRI->getKey()));
88 
89  //colorIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getKey(),colorIdToKeyMap));
90  //gradientIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getKey(),gradientIdToKeyMap));
91  //lineEndingIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getKey(),lineEndingIdToKeyMap));
93  }
94 
95  // fix the references
96  SBMLDocumentLoader::convertRenderInformationReferencesIds<CLGlobalRenderInformation>(lol.getListOfGlobalRenderInformationObjects(), idToKeyMap);
97  // fix the color ids, gradient ids and line ending ids.
98 
99  //convert the map as used by the CLxxx constructors
100  std::map<std::string, std::string> modelmap;
101 
102  std::string s1, s2;
103  std::map<CCopasiObject*, SBase*>::const_iterator it;
104  std::map<CCopasiObject*, SBase*>::const_iterator itEnd = copasimodelmap.end();
105 
106  for (it = copasimodelmap.begin(); it != itEnd; ++it)
107  {
108  s1 = SBMLUtils::getIdFromSBase(it->second);
109 
110  if (it->first)
111  s2 = it->first->getKey();
112  else
113  s2 = "";
114 
115  if ((s1 != "") && (s2 != ""))
116  modelmap[s1] = s2;
117  }
118 
119  //iterate through list of layouts
120  iMax = sbmlList.size();
121 
122  for (i = 0; i < iMax; ++i)
123  {
124  std::map<std::string, std::string> layoutmap;
125  const Layout* tmp
126  = dynamic_cast<const Layout*>(sbmlList.get(i));
127 
128  if (tmp)
129  {
130  //CLayout * pLayout = createLayout(*tmp, modelmap, layoutmap,idToKeyMap,expandedColorIdToKeyMapMap,expandedGradientIdToKeyMapMap,expandedLineEndingIdToKeyMapMap);
131  CLayout * pLayout = createLayout(*tmp, modelmap, layoutmap, idToKeyMap);
132  lol.addLayout(pLayout, layoutmap);
133  }
134  }
135 
136  //TODO: the layout object should be added to the copasimodelmap. However,
137  //if this is done, the object also need to be removed if necessary in the
138  //sbml exporter (see comment in CListOfLayouts::exportToSBML()).
139 }
void addGlobalRenderInformation(CLGlobalRenderInformation *pRenderInfo)
#define C_INT32
Definition: copasi.h:90
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)
void addLayout(CLayout *layout, const std::map< std::string, std::string > &m)
static std::string getIdFromSBase(const SBase *s)
Definition: SBMLUtils.cpp:32
const std::string & getKey() const
const CCopasiVector< CLGlobalRenderInformation > & getListOfGlobalRenderInformationObjects() const

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