COPASI API  4.16.103
CLReactionGlyph.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // 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 //#include<iostream>
16 
17 #define USE_LAYOUT 1
18 
19 #include <sbml/packages/layout/sbml/ReactionGlyph.h>
20 #include <sbml/packages/layout/sbml/SpeciesReferenceGlyph.h>
21 
22 #if LIBSBML_VERSION >= 50800
23 #include <sbml/packages/layout/sbml/GraphicalObject.h>
24 #include <sbml/packages/layout/sbml/Layout.h>
25 #include <sbml/packages/layout/sbml/SpeciesGlyph.h>
26 #include <sbml/packages/layout/sbml/CompartmentGlyph.h>
27 #include <sbml/packages/layout/sbml/GeneralGlyph.h>
28 #include <sbml/packages/layout/sbml/ReferenceGlyph.h>
29 #endif
30 
31 #include "copasi.h"
32 
33 #include "CLReactionGlyph.h"
34 #include "report/CKeyFactory.h"
36 
37 CLGlyphWithCurve::CLGlyphWithCurve(const std::string & name,
38  const CCopasiContainer * pParent)
39  : CLGraphicalObject(name, pParent),
40  mCurve()
41 {}
42 
44  const CCopasiContainer * pParent)
45  : CLGraphicalObject(src, pParent),
46  mCurve(src.mCurve)
47 {}
48 
49 CLGlyphWithCurve::CLGlyphWithCurve(const GraphicalObject & sbml,
50  const std::map<std::string, std::string> & modelmap,
51  std::map<std::string, std::string> & layoutmap,
52  const CCopasiContainer * pParent)
53  : CLGraphicalObject(sbml, layoutmap, pParent),
54  mCurve() //initialized in the body below
55 {
56 #if LIBSBML_VERSION >= 50800
57  const GeneralGlyph* general = dynamic_cast<const GeneralGlyph *>(&sbml);
58 
59  if (general && general->isSetCurve())
60  {
61  CLCurve copy(*general->getCurve());
62  mCurve = copy;
63  }
64 
65  const ReferenceGlyph* rG = dynamic_cast<const ReferenceGlyph *>(&sbml);
66 
67  if (rG && rG->isSetCurve())
68  {
69  CLCurve copy(*rG->getCurve());
70  mCurve = copy;
71  }
72 
73 #endif // LIBSBML_VERSION >= 50800
74 }
75 
77 {
78  if (this == &rhs) return * this; //do nothing if lhs and rhs are the same
79 
81 
82  //handle the specific glyph stuff:
83  mCurve = rhs.mCurve;
84 
85  return *this;
86 }
87 
89 {
91  mCurve.moveBy(p);
92 }
93 
94 std::ostream & operator<<(std::ostream &os, const CLGlyphWithCurve & g)
95 {
96  //TODO: bounding box?
97  os << g.mCurve;
98 
99  return os;
100 }
101 
102 void CLGlyphWithCurve::print(std::ostream * ostream) const
103 {*ostream << *this;}
104 
105 //***************************
106 
107 CLReferenceGlyph::CLReferenceGlyph(const std::string & name,
108  const CCopasiContainer * pParent)
109  : CLGlyphWithCurve(name, pParent)
110  , mGlyphKey()
111  , mRole()
112 {}
113 
115  const CCopasiContainer * pParent)
116  : CLGlyphWithCurve(src, pParent)
117  , mGlyphKey(src.mGlyphKey)
118  , mRole(src.mRole)
119 {}
120 
121 #if LIBSBML_VERSION >= 50800
122 CLReferenceGlyph::CLReferenceGlyph(const ReferenceGlyph & sbml,
123  const std::map<std::string, std::string> & modelmap,
124  std::map<std::string, std::string> & layoutmap,
125  const CCopasiContainer * pParent)
126  : CLGlyphWithCurve(sbml, modelmap, layoutmap, pParent)
127  , mGlyphKey() //initialized in the body below
128  , mRole() //initialized in the body below
129 {
130  //get the copasi key corresponding to the sbml id for the species reference
131  if (sbml.isSetReferenceId())
132  {
133  std::map<std::string, std::string>::const_iterator it = modelmap.find(sbml.getReferenceId());
134 
135  if (it != modelmap.end())
136  setModelObjectKey(it->second);
137  }
138 
139  //get the copasi key corresponding to the sbml id for the species glyph
140  if (sbml.isSetGlyphId())
141  {
142  std::map<std::string, std::string>::const_iterator it = layoutmap.find(sbml.getGlyphId());
143 
144  if (it != layoutmap.end())
145  mGlyphKey = it->second;
146  }
147 
148  if (sbml.isSetRole())
149  mRole = sbml.getRole();
150 }
151 
152 #endif // LIBSBML_VERSION >= 50800
153 
155 {
156  if (this == &rhs) return * this; //do nothing if lhs and rhs are the same
157 
159 
160  //handle the specific glyph stuff:
161  mGlyphKey = rhs.mGlyphKey;
162  mRole = rhs.mRole;
163 
164  return *this;
165 }
166 
168 {
170  return dynamic_cast<CLMetabGlyph*>(tmp);
171 }
172 
173 void CLReferenceGlyph::exportToSBML(ReferenceGlyph * g, //TODO
174  const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
175  std::map<std::string, const SBase*>& sbmlIDs,
176  const std::map<const CLBase*, const SBase*> & layoutmap) const
177 {
178  if (!g) return;
179 
180  //call the coresponding method of the base class
181  CLGraphicalObject::exportToSBML(g, copasimodelmap, sbmlIDs);
182 
183  //reference to species glyph
185 
186  if (tmp)
187  {
188  std::map<const CLBase*, const SBase*>::const_iterator it = layoutmap.find(tmp);
189 
190  if (it != layoutmap.end())
191  {
192  if (it->second)
193  {
194  //we need to cast here since layout objects in libsbml don´t inherit the getId() method
195  //from SBase
196  const GraphicalObject* pGO = dynamic_cast<const GraphicalObject*>(it->second);
197 
198  if (pGO)
199  g->setGlyphId(pGO->getId());
200  }
201  }
202  }
203 
204  g->setRole(mRole);
205 
206  //curve
207  mCurve.exportToSBML(g->getCurve(), copasimodelmap);
208 }
209 
210 std::ostream & operator<<(std::ostream &os, const CLReferenceGlyph & g)
211 {
212  os << " ReferenceGlyph: " << dynamic_cast<const CLGraphicalObject&>(g);
213 
214  const CLGraphicalObject* tmp = g.getTargetGlyph();
215 
216  if (tmp)
217  os << " refers to a Glyph that refers to "
218  << tmp->getModelObjectDisplayName() << std::endl;
219 
220  os << g.mCurve; //TODO refer to base class?
221 
222  return os;
223 }
224 
225 void CLReferenceGlyph::print(std::ostream * ostream) const
226 {*ostream << *this;}
227 
228 //*********************************************************************
229 
230 const std::string CLMetabReferenceGlyph::RoleName[] =
231 {
232  "undefined role",
233  "substrate",
234  "product",
235  "side substrate",
236  "side product",
237  "modifier",
238  "activator",
239  "inhibitor"
240  ""
241 };
242 
243 const std::string CLMetabReferenceGlyph::XMLRole[] =
244 {
245  "undefinedRole",
246  "substrate",
247  "product",
248  "sideSubstrate",
249  "sideProduct",
250  "modifier",
251  "activator",
252  "inhibitor",
253  ""
254 };
255 
257  const CCopasiContainer * pParent)
258  : CLGlyphWithCurve(name, pParent),
259  mMetabGlyphKey(),
260  mRole(UNDEFINED)
261 {}
262 
264  const CCopasiContainer * pParent)
265  : CLGlyphWithCurve(src, pParent),
266  mMetabGlyphKey(src.mMetabGlyphKey),
267  mRole(src.mRole)
268 {}
269 
270 CLMetabReferenceGlyph::CLMetabReferenceGlyph(const SpeciesReferenceGlyph & sbml,
271  const std::map<std::string, std::string> & modelmap,
272  std::map<std::string, std::string> & layoutmap,
273  const CCopasiContainer * pParent)
274  : CLGlyphWithCurve(sbml, modelmap, layoutmap, pParent),
275  mMetabGlyphKey(), //initialized in the body below
276  mRole((Role)sbml.getRole())
277 {
278  //get the copasi key corresponding to the sbml id for the species reference
279  if (sbml.getSpeciesReferenceId() != "")
280  {
281  std::map<std::string, std::string>::const_iterator it = modelmap.find(sbml.getSpeciesReferenceId());
282 
283  if (it != modelmap.end())
284  setModelObjectKey(it->second);
285  }
286 
287  //get the copasi key corresponding to the sbml id for the species glyph
288  if (sbml.getSpeciesGlyphId() != "")
289  {
290  std::map<std::string, std::string>::const_iterator it = layoutmap.find(sbml.getSpeciesGlyphId());
291 
292  if (it != layoutmap.end())
293  mMetabGlyphKey = it->second;
294  }
295 
296  //curve
297  if (sbml.getCurve())
298  {
299  CLCurve copy(*sbml.getCurve());
300  mCurve = copy;
301  }
302 }
303 
305 {
306  if (this == &rhs) return * this; //do nothing if lhs and rhs are the same
307 
309 
310  //handle the specific glyph stuff:
312  mRole = rhs.mRole;
313 
314  return *this;
315 }
316 
318 {
320  return dynamic_cast<CLMetabGlyph*>(tmp);
321 }
322 
323 void CLMetabReferenceGlyph::exportToSBML(SpeciesReferenceGlyph * g,
324  const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
325  std::map<std::string, const SBase*>& sbmlIDs,
326  const std::map<const CLBase*, const SBase*> & layoutmap) const
327 {
328  if (!g) return;
329 
330  //call the coresponding method of the base class
331  CLGraphicalObject::exportToSBML(g, copasimodelmap, sbmlIDs);
332 
333  //reference to species glyph
334  CLMetabGlyph* tmp = getMetabGlyph();
335 
336  if (tmp)
337  {
338  std::map<const CLBase*, const SBase*>::const_iterator it = layoutmap.find(tmp);
339 
340  if (it != layoutmap.end())
341  {
342  if (it->second)
343  {
344  //we need to cast here since layout objects in libsbml don´t inherit the getId() method
345  //from SBase
346  const GraphicalObject* pGO = dynamic_cast<const GraphicalObject*>(it->second);
347 
348  if (pGO)
349  g->setSpeciesGlyphId(pGO->getId());
350  }
351  }
352  }
353 
354  //curve
355  mCurve.exportToSBML(g->getCurve(), copasimodelmap);
356 
357  //Role
358  g->setRole((SpeciesReferenceRole_t)mRole);
359  //this depends on the copasi role enum being synchronous to the sbml one
360 }
361 
362 std::ostream & operator<<(std::ostream &os, const CLMetabReferenceGlyph & g)
363 {
364  os << " MetabReferenceGlyph: " << dynamic_cast<const CLGraphicalObject&>(g);
365 
366  os << " Role: " << CLMetabReferenceGlyph::RoleName[g.getRole()] << "\n";
367 
368  const CLMetabGlyph* tmp = g.getMetabGlyph();
369 
370  if (tmp)
371  os << " refers to a MetabGlyph that refers to "
372  << tmp->getModelObjectDisplayName() << std::endl;
373 
374  os << g.mCurve;
375 
376  return os;
377 }
378 
379 void CLMetabReferenceGlyph::print(std::ostream * ostream) const
380 {*ostream << *this;}
381 
382 //*********** CLGeneralGlyph ****************************************
383 
384 CLGeneralGlyph::CLGeneralGlyph(const std::string & name,
385  const CCopasiContainer * pParent)
386  : CLGlyphWithCurve(name, pParent)
387  , mvReferences("ListOfReferenceGlyphs", this)
388  , mvSubglyphs("ListOfSubglyphs", this)
389 {}
390 
392  const CCopasiContainer * pParent)
393  : CLGlyphWithCurve(src, pParent)
394  , mvReferences(src.mvReferences, this)
395  , mvSubglyphs("ListOfSubglyphs", this)
396 {
397  size_t i, imax = src.mvSubglyphs.size();
398 
399  for (i = 0; i < imax; ++i)
400  addSubglyph(src.mvSubglyphs[i]->clone());
401 }
402 
403 //TODO this is a placeholder for the upcoming sbml generalGlyph handling
404 CLGeneralGlyph::CLGeneralGlyph(const GraphicalObject & sbml,
405  const std::map<std::string, std::string> & modelmap,
406  std::map<std::string, std::string> & layoutmap,
407  const CCopasiContainer * pParent)
408  : CLGlyphWithCurve(sbml, modelmap, layoutmap, pParent)
409  , mvReferences("ListOfReferenceGlyphs", this)
410  , mvSubglyphs("ListOfSubglyphs", this)
411 {
412 #if LIBSBML_VERSION >= 50800
413 
414  const GeneralGlyph* general = dynamic_cast<const GeneralGlyph *>(&sbml);
415 
416  if (!general)
417  return;
418 
419  //get the copasi key corresponding to the sbml id for the reaction
420  if (general->isSetReferenceId())
421  {
422  std::map<std::string, std::string>::const_iterator it = modelmap.find(general->getReferenceId());
423 
424  if (it != modelmap.end())
425  setModelObjectKey(it->second);
426 
427  it = layoutmap.find(general->getReferenceId());
428 
429  if (it != layoutmap.end())
430  setModelObjectKey(it->second);
431  }
432 
433  //species reference glyphs
434  C_INT32 i, imax = general->getListOfReferenceGlyphs()->size();
435 
436  for (i = 0; i < imax; ++i)
437  {
438  const ReferenceGlyph* tmp
439  = dynamic_cast<const ReferenceGlyph*>(general->getListOfReferenceGlyphs()->get(i));
440 
441  if (tmp)
442  addReferenceGlyph(new CLReferenceGlyph(*tmp, modelmap, layoutmap));
443  }
444 
445  imax = general->getListOfSubGlyphs()->size();
446 
447  for (i = 0; i < imax; ++i)
448  {
449  const GraphicalObject* graphical = general->getListOfSubGlyphs()->get(i);
450  const TextGlyph* text = dynamic_cast<const TextGlyph*>(graphical);
451  const SpeciesGlyph* species = dynamic_cast<const SpeciesGlyph*>(graphical);
452  const CompartmentGlyph* comp = dynamic_cast<const CompartmentGlyph*>(graphical);
453 
454  if (text)
455  addSubglyph(new CLTextGlyph(*text, modelmap, layoutmap));
456  else if (species)
457  addSubglyph(new CLMetabGlyph(*species, modelmap, layoutmap));
458  else if (comp)
459  addSubglyph(new CLCompartmentGlyph(*comp, modelmap, layoutmap));
460  else
461  addSubglyph(new CLGeneralGlyph(*graphical, modelmap, layoutmap));
462  }
463 
464 #endif // LIBSBML_VERSION >= 50800
465 }
466 
468 {
469  if (this == &rhs) return * this; //do nothing if lhs and rhs are the same
470 
472 
473  //handle the specific glyph stuff:
474 
475  size_t i, imax = rhs.mvReferences.size();
476 
478 
479  for (i = 0; i < imax; ++i)
481 
482  imax = rhs.mvSubglyphs.size();
483  mvSubglyphs.clear();
484 
485  for (i = 0; i < imax; ++i)
486  addSubglyph(rhs.mvSubglyphs[i]->clone());
487 
488  return *this;
489 }
490 
492 {
493  if (glyph)
494  mvSubglyphs.add(glyph, true); //true means vector takes ownership
495 }
496 
498 {
499  if (glyph)
500  mvReferences.add(glyph, true); //true means vector takes ownership
501 }
502 
504 {
506 
507  size_t i, imax = mvReferences.size();
508 
509  for (i = 0; i < imax; ++i)
510  mvReferences[i]->moveBy(p);
511 
512  imax = mvSubglyphs.size();
513 
514  for (i = 0; i < imax; ++i)
515  mvSubglyphs[i]->moveBy(p);
516 }
517 
518 void CLGeneralGlyph::exportToSBML(GraphicalObject * g, //TODO
519  const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
520  std::map<std::string, const SBase*>& sbmlIDs,
521  std::map<const CLBase*, const SBase*> & layoutmap) const
522 {
523  if (!g) return;
524 
525  //call the coresponding method of the base class
526  CLGraphicalObject::exportToSBML(g, copasimodelmap, sbmlIDs);
527 
528 #if LIBSBML_VERSION >= 50800
529 
530  GeneralGlyph *general = dynamic_cast<GeneralGlyph *>(g);
531 
532  if (!general) return;
533 
534  //reference to model objects
535  CCopasiObject* tmp = getModelObject();
536 
537  if (tmp)
538  {
539  std::map<const CCopasiObject*, SBase*>::const_iterator it = copasimodelmap.find(tmp);
540 
541  if (it != copasimodelmap.end())
542  {
543  if (it->second)
544  general->setReferenceId(it->second->getId());
545  }
546 
547  const CLBase* base = dynamic_cast<const CLBase*>(tmp);
548 
549  if (base)
550  {
551  std::map<const CLBase*, const SBase*>::const_iterator it2 = layoutmap.find(base);
552 
553  if (it2 != layoutmap.end())
554  {
555  if (it2->second)
556  general->setReferenceId(it2->second->getId());
557  }
558  }
559  }
560 
561  //curve
562  mCurve.exportToSBML(general->getCurve(), copasimodelmap);
563 
564  //reference glyphs
565  size_t i, imax = mvReferences.size();
566 
567  for (i = 0; i < imax; ++i)
568  {
569  CLReferenceGlyph * tmp = mvReferences[i];
570 
571  //check if the glyph exists in the libsbml data
572  std::map<const CCopasiObject*, SBase*>::const_iterator it;
573  it = copasimodelmap.find(tmp);
574 
575  ReferenceGlyph * pG;
576 
577  if (it == copasimodelmap.end()) //not found
578  {
579  pG = general->createReferenceGlyph();
580  }
581  else
582  {
583  pG = dynamic_cast<ReferenceGlyph*>(it->second);
584  }
585 
586  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
587  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
588  }
589 
590  imax = mvSubglyphs.size();
591 
592  for (i = 0; i < imax; ++i)
593  {
594  CLGraphicalObject * tmp = mvSubglyphs[i];
595  CLMetabGlyph * metab = dynamic_cast<CLMetabGlyph*>(tmp);
596  CLCompartmentGlyph* comp = dynamic_cast<CLCompartmentGlyph*>(tmp);
597  CLGeneralGlyph* gg = dynamic_cast<CLGeneralGlyph*>(tmp);
598  CLTextGlyph* text = dynamic_cast<CLTextGlyph*>(tmp);
599 
600  //check if the glyph exists in the libsbml data
601  std::map<const CCopasiObject*, SBase*>::const_iterator it;
602  it = copasimodelmap.find(tmp);
603 
604  GraphicalObject * pG;
605 
606  if (it == copasimodelmap.end()) //not found
607  {
608  if (metab)
609  pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createSpeciesGlyph();
610  else if (comp)
611  pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createCompartmentGlyph();
612  else if (gg)
613  pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createGeneralGlyph();
614  else if (text)
615  pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createTextGlyph();
616  else
617  pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createAdditionalGraphicalObject();
618  }
619  else
620  {
621  pG = dynamic_cast<GraphicalObject*>(it->second);
622  }
623 
624  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
625 
626  if (metab)
627  metab->exportToSBML(static_cast<SpeciesGlyph*>(pG), copasimodelmap, sbmlIDs);
628  else if (comp)
629  comp->exportToSBML(static_cast<CompartmentGlyph*>(pG), copasimodelmap, sbmlIDs);
630  else if (text)
631  text->exportToSBML(static_cast<TextGlyph*>(pG), copasimodelmap, sbmlIDs);
632  else if (gg)
633  gg->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
634  else
635  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs);
636  }
637 
638 #endif // LIBSBML_VERSION >= 50800
639 }
640 
641 std::ostream & operator<<(std::ostream &os, const CLGeneralGlyph & g)
642 {
643  os << "GeneralGlyph: " << dynamic_cast<const CLGraphicalObject&>(g);
644  os << g.mCurve;
645 
646  size_t i, imax = g.mvReferences.size();
647 
648  if (imax)
649  {
650  os << " List of reference glyphs: \n";
651 
652  for (i = 0; i < imax; ++i)
653  os << *g.mvReferences[i];
654  }
655 
656  imax = g.mvSubglyphs.size();
657 
658  if (imax)
659  {
660  os << " List of reference glyphs: \n";
661 
662  for (i = 0; i < imax; ++i)
663  os << *g.mvSubglyphs[i];
664  }
665 
666  return os;
667 }
668 
669 void CLGeneralGlyph::print(std::ostream * ostream) const
670 {*ostream << *this;}
671 
672 //*********** CLReactionGlyph ****************************************
673 
674 CLReactionGlyph::CLReactionGlyph(const std::string & name,
675  const CCopasiContainer * pParent)
676  : CLGlyphWithCurve(name, pParent),
677  mvMetabReferences("ListOfMetabReferenceGlyphs", this)
678 {}
679 
681  const CCopasiContainer * pParent)
682  : CLGlyphWithCurve(src, pParent),
683  mvMetabReferences(src.mvMetabReferences, this)
684 {
685  //TODO
686 }
687 
688 CLReactionGlyph::CLReactionGlyph(const ReactionGlyph & sbml,
689  const std::map<std::string, std::string> & modelmap,
690  std::map<std::string, std::string> & layoutmap,
691  const CCopasiContainer * pParent)
692  : CLGlyphWithCurve(sbml, modelmap, layoutmap, pParent),
693  mvMetabReferences("ListOfMetabReferenceGlyphs", this)
694 {
695  //get the copasi key corresponding to the sbml id for the reaction
696  if (sbml.getReactionId() != "")
697  {
698  std::map<std::string, std::string>::const_iterator it = modelmap.find(sbml.getReactionId());
699 
700  if (it != modelmap.end())
701  setModelObjectKey(it->second);
702  }
703 
704  //species reference glyphs
705  C_INT32 i, imax = sbml.getListOfSpeciesReferenceGlyphs()->size();
706 
707  for (i = 0; i < imax; ++i)
708  {
709  const SpeciesReferenceGlyph* tmp
710  = dynamic_cast<const SpeciesReferenceGlyph*>(sbml.getListOfSpeciesReferenceGlyphs()->get(i));
711 
712  if (tmp)
713  addMetabReferenceGlyph(new CLMetabReferenceGlyph(*tmp, modelmap, layoutmap));
714  }
715 
716  //curve
717  if (sbml.getCurve())
718  {
719  CLCurve copy(*sbml.getCurve());
720  mCurve = copy;
721  }
722 }
723 
725 {
726  if (this == &rhs) return * this; //do nothing if lhs and rhs are the same
727 
729 
730  //handle the specific glyph stuff:
731  size_t i, imax = rhs.mvMetabReferences.size();
732 
733  for (i = 0; i < imax; ++i)
735 
736  return *this;
737 }
738 
739 /*const std::vector<CLMetabReferenceGlyph*> CLReactionGlyph::getListOfMetabReferenceGlyphs() const
740 {
741  std::vector<CLMetabReferenceGlyph*> ret;
742  size_t i, imax = mvReferences.size();
743 
744  for (i = 0; i < imax; ++i)
745  {
746  CLMetabReferenceGlyph * tmp = dynamic_cast<CLMetabReferenceGlyph*>(mvReferences[i]);
747  if(tmp)
748  ret.push_back(tmp);
749  }
750  return ret;
751 }*/
752 
754 {
755  if (glyph)
756  mvMetabReferences.add(glyph, true); //true means vector takes ownership
757 }
758 
760 {
762 
763  size_t i, imax = mvMetabReferences.size();
764 
765  for (i = 0; i < imax; ++i)
766  mvMetabReferences[i]->moveBy(p);
767 }
768 
769 void CLReactionGlyph::exportToSBML(ReactionGlyph * g,
770  const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
771  std::map<std::string, const SBase*>& sbmlIDs,
772  std::map<const CLBase*, const SBase*> & layoutmap) const
773 {
774  if (!g) return;
775 
776  //call the coresponding method of the base class
777  CLGraphicalObject::exportToSBML(g, copasimodelmap, sbmlIDs);
778 
779  //reference to model objects
780  CCopasiObject* tmp = getModelObject();
781 
782  if (tmp)
783  {
784  std::map<const CCopasiObject*, SBase*>::const_iterator it = copasimodelmap.find(tmp);
785 
786  if (it != copasimodelmap.end())
787  {
788  if (it->second)
789  g->setReactionId(it->second->getId());
790  }
791  }
792 
793  //curve
794  mCurve.exportToSBML(g->getCurve(), copasimodelmap);
795 
796  //Metab reference glyphs
797  size_t i, imax = mvMetabReferences.size();
798 
799  for (i = 0; i < imax; ++i)
800  {
802 
803  //check if the glyph exists in the libsbml data
804  std::map<const CCopasiObject*, SBase*>::const_iterator it;
805  it = copasimodelmap.find(tmp);
806 
807  SpeciesReferenceGlyph * pG;
808 
809  if (it == copasimodelmap.end()) //not found
810  {
811  pG = new SpeciesReferenceGlyph;
812  g->getListOfSpeciesReferenceGlyphs()->appendAndOwn(pG);
813  }
814  else
815  {
816  pG = dynamic_cast<SpeciesReferenceGlyph*>(it->second);
817  }
818 
819  layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
820  tmp->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
821  }
822 }
823 
824 std::ostream & operator<<(std::ostream &os, const CLReactionGlyph & g)
825 {
826  os << "ReactionGlyph: " << dynamic_cast<const CLGraphicalObject&>(g);
827  os << g.mCurve;
828 
829  size_t i, imax = g.mvMetabReferences.size();
830 
831  if (imax)
832  {
833  os << " List of metab reference glyphs: \n";
834 
835  for (i = 0; i < imax; ++i)
836  os << *g.mvMetabReferences[i];
837  }
838 
839  return os;
840 }
841 
842 void CLReactionGlyph::print(std::ostream * ostream) const
843 {*ostream << *this;}
std::string getModelObjectDisplayName(bool regular=true, bool richtext=false) const
void print(std::ostream *ostream) const
std::string mGlyphKey
CLGlyphWithCurve & operator=(const CLGlyphWithCurve &rhs)
virtual void exportToSBML(ReactionGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, std::map< const CLBase *, const SBase * > &layoutmap) const
virtual void moveBy(const CLPoint &p)
std::ostream & operator<<(std::ostream &os, const CLGlyphWithCurve &g)
void addReferenceGlyph(CLReferenceGlyph *glyph)
void exportToSBML(Curve *c, const std::map< const CCopasiObject *, SBase * > &copasimodelmap) const
Definition: CLCurve.cpp:148
virtual size_t size() const
CLReactionGlyph(const std::string &name="ReactionGlyph", const CCopasiContainer *pParent=NULL)
CLGeneralGlyph & operator=(const CLGeneralGlyph &rhs)
CCopasiObject * get(const std::string &key)
void addSubglyph(CLGraphicalObject *glyph)
void addMetabReferenceGlyph(CLMetabReferenceGlyph *glyph)
void print(std::ostream *ostream) const
CLGraphicalObject * getTargetGlyph() const
virtual void exportToSBML(CompartmentGlyph *cg, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLGlyphs.cpp:145
#define C_INT32
Definition: copasi.h:90
virtual void moveBy(const CLPoint &p)
Definition: CLCurve.cpp:187
CLMetabReferenceGlyph(const std::string &name="MetabReferenceGlyph", const CCopasiContainer *pParent=NULL)
void setModelObjectKey(const std::string &k)
virtual void exportToSBML(SpeciesReferenceGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, const std::map< const CLBase *, const SBase * > &layoutmap) const
CLGlyphWithCurve(const std::string &name="ReferenceGlyph", const CCopasiContainer *pParent=NULL)
Definition: CLBase.h:54
CLMetabReferenceGlyph & operator=(const CLMetabReferenceGlyph &rhs)
virtual bool add(const CType &src)
virtual void exportToSBML(GraphicalObject *sbmlobject, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
virtual void exportToSBML(SpeciesGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLGlyphs.cpp:73
Definition: CLBase.h:33
CLMetabGlyph * getMetabGlyph() const
std::string mRole
CCopasiVector< CLReferenceGlyph > mvReferences
CLReferenceGlyph(const std::string &name="ReferenceGlyph", const CCopasiContainer *pParent=NULL)
CCopasiVector< CLGraphicalObject > mvSubglyphs
CLGraphicalObject & operator=(const CLGraphicalObject &rhs)
CCopasiObject * getModelObject() const
static CKeyFactory * getKeyFactory()
virtual void moveBy(const CLPoint &p)
void print(std::ostream *ostream) const
virtual void moveBy(const CLPoint &p)
virtual void clear()
virtual void exportToSBML(TextGlyph *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs) const
Definition: CLGlyphs.cpp:267
CCopasiVector< CLMetabReferenceGlyph > mvMetabReferences
virtual void exportToSBML(GraphicalObject *g, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, std::map< const CLBase *, const SBase * > &layoutmap) const
void print(std::ostream *ostream) const
virtual void moveBy(const CLPoint &p)
void print(std::ostream *ostream) const
CLReactionGlyph & operator=(const CLReactionGlyph &rhs)
CLReferenceGlyph & operator=(const CLReferenceGlyph &rhs)
CLGeneralGlyph(const std::string &name="GeneralGlyph", const CCopasiContainer *pParent=NULL)