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

#include <CListOfLayouts.h>

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

Public Member Functions

void addGlobalRenderInformation (CLGlobalRenderInformation *pRenderInfo)
 
void addLayout (CLayout *layout, const std::map< std::string, std::string > &m)
 
 CListOfLayouts (const std::string &name="ListOfLayouts", const CCopasiContainer *pParent=NULL)
 
void exportToSBML (ListOf *lol, std::map< const CCopasiObject *, SBase * > &copasimodelmap, const std::map< std::string, const SBase * > &idMap, unsigned int level, unsigned int version) const
 
const std::string & getKey ()
 
const CCopasiVector
< CLGlobalRenderInformation > & 
getListOfGlobalRenderInformationObjects () const
 
CCopasiVector
< CLGlobalRenderInformation > & 
getListOfGlobalRenderInformationObjects ()
 
CLGlobalRenderInformationgetRenderInformation (size_t index)
 
const CLGlobalRenderInformationgetRenderInformation (size_t index) const
 
 ~CListOfLayouts ()
 
- Public Member Functions inherited from CCopasiVector< CLayout >
virtual bool add (const CType &src)
 
virtual bool add (CType *src, bool adopt=false)
 
iterator begin ()
 
const_iterator begin () const
 
 CCopasiVector (const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const unsigned C_INT32 &flag=CCopasiObject::Vector)
 
 CCopasiVector (const CCopasiVector< CType > &src, const CCopasiContainer *pParent=NULL)
 
virtual void cleanup ()
 
virtual void clear ()
 
void deepCopy (const CCopasiVector< CType > &source)
 
iterator end ()
 
const_iterator end () const
 
virtual size_t getIndex (const CCopasiObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &name) const
 
CCopasiVector< CType > & operator= (const CCopasiVector< CType > &rhs)
 
CCopasiVector< CType > & operator= (const std::vector< CType * > &rhs)
 
const value_typeoperator[] (const size_t &index) const
 
value_typeoperator[] (const size_t &index)
 
virtual void remove (const size_t &index)
 
virtual bool remove (CCopasiObject *pObject)
 
virtual void resize (const size_t &newSize)
 
virtual size_t size () const
 
virtual void swap (const size_t &indexFrom, const size_t &indexTo)
 
virtual ~CCopasiVector ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
virtual const std::string & getKey () const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
virtual void print (std::ostream *ostream) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Private Attributes

std::string mKey
 
CCopasiVector
< CLGlobalRenderInformation
mvGlobalRenderInformationObjects
 

Additional Inherited Members

- Public Types inherited from CCopasiVector< CLayout >
typedef std::vector< CType * >
::const_iterator 
const_iterator
 
typedef std::vector< CType * >
::iterator 
iterator
 
typedef std::vector< CType * >
::value_type 
value_type
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

this class stores a list of layouts. It should also keep the maps that translate from sbml IDs to COPASI keys

Definition at line 29 of file CListOfLayouts.h.

Constructor & Destructor Documentation

CListOfLayouts::CListOfLayouts ( const std::string &  name = "ListOfLayouts",
const CCopasiContainer pParent = NULL 
)

Definition at line 57 of file CListOfLayouts.cpp.

58  :
59  CCopasiVector<CLayout>(name, pParent),
60  mKey(CCopasiRootContainer::getKeyFactory()->add("Layout", this))
61  , mvGlobalRenderInformationObjects("ListOfGlobalRenderInformationObjects", this)
62 {}
std::string mKey
std::string add(const std::string &prefix, CCopasiObject *pObject)
CCopasiVector< CLGlobalRenderInformation > mvGlobalRenderInformationObjects
static CKeyFactory * getKeyFactory()
CListOfLayouts::~CListOfLayouts ( )

Definition at line 64 of file CListOfLayouts.cpp.

References CCopasiRootContainer::getKeyFactory(), mKey, and CKeyFactory::remove().

65 {
67 }
bool remove(const std::string &key)
std::string mKey
static CKeyFactory * getKeyFactory()

Member Function Documentation

void CListOfLayouts::addGlobalRenderInformation ( CLGlobalRenderInformation pRenderInfo)

add local render information to layout. The layout takes ownership of the object.

Definition at line 213 of file CListOfLayouts.cpp.

References CCopasiVector< T >::add(), and mvGlobalRenderInformationObjects.

Referenced by test000097::addGlobalRenderInformation(), SBMLDocumentLoader::readListOfLayouts(), and CCopasiXMLParser::GlobalRenderInformationElement::start().

214 {
215  if (pRenderInfo)
216  {
217  this->mvGlobalRenderInformationObjects.add(pRenderInfo, true); //true means vector takes ownership
218  }
219 }
virtual bool add(const CType &src)
CCopasiVector< CLGlobalRenderInformation > mvGlobalRenderInformationObjects
void CListOfLayouts::addLayout ( CLayout layout,
const std::map< std::string, std::string > &  m 
)

Add a layout to the list. At the moment the map is just ignored. Later it should be stored somewhere

Definition at line 74 of file CListOfLayouts.cpp.

References CCopasiVector< CLayout >::add().

Referenced by test000097::createModel(), DataModelGUI::importCellDesigner(), SBMLDocumentLoader::readListOfLayouts(), and CQLayoutsWidget::slotBtnNewClicked().

75 {
76  if (layout)
77  add(layout, true);
78 
79  //TODO: store map
80 }
virtual bool add(const CType &src)
void CListOfLayouts::exportToSBML ( ListOf *  lol,
std::map< const CCopasiObject *, SBase * > &  copasimodelmap,
const std::map< std::string, const SBase * > &  idMap,
unsigned int  level,
unsigned int  version 
) const

This method writes the information of the copasi layout object into the corresponding sbml object. copasimodelmap maps the copasi model objects to libsbml objects. At the moment we donĀ“t assume layout objects are in the copasimodelmap. idSet should contain all sbml IDs that are used in the currently exported model (including the layouts, but not the objects inside the layout).

Definition at line 82 of file CListOfLayouts.cpp.

References CLayout::exportToSBML(), getKey(), LAYOUT_CREATE_NS, mvGlobalRenderInformationObjects, pdelete, CCopasiVector< T >::size(), and CCopasiVector< CLayout >::size().

Referenced by CSBMLExporter::exportModelToString().

84 {
85  if (!lol) return;
86 
87  size_t i, imax;
88  // the global render information has to be handled first, because we might need
89  // some of the maps for the export of the local render information in the layout
90  ListOfLayouts* pLoL = dynamic_cast<ListOfLayouts*>(lol);
91  assert(pLoL != NULL);
93  GlobalRenderInformation* pGRI = NULL;
94  std::map<std::string, std::string> keyToIdMap;
95 
96  /*
97  std::map<std::string,std::string> colorKeyToIdMap;
98  std::map<std::string,std::string> gradientKeyToIdMap;
99  std::map<std::string,std::string> lineEndingKeyToIdMap;
100  std::map<std::string,std::map<std::string,std::string> > colorKeyToIdMapMap;
101  std::map<std::string,std::map<std::string,std::string> > gradientKeyToIdMapMap;
102  std::map<std::string,std::map<std::string,std::string> > lineEndingKeyToIdMapMap;
103  */
104 
105  RenderListOfLayoutsPlugin* rlolPlugin = (RenderListOfLayoutsPlugin*) lol->getPlugin("render");
106 
107  if (rlolPlugin == NULL)
108  {
109  // we do not yet have a render layout plugin so let us enable it
110  const std::string uri = (lol->getLevel() < 3 ? RenderExtension::getXmlnsL2() : RenderExtension::getXmlnsL3V1V1());
111  lol->enablePackage(uri, "render", true);
112  rlolPlugin = (RenderListOfLayoutsPlugin*) lol->getPlugin("render");
113 
114  if (lol->getLevel() > 2)
115  lol->getSBMLDocument()->setPackageRequired("render", false);
116  }
117 
118  assert(rlolPlugin != NULL);
119 
120  for (i = 0; i < imax; ++i)
121  {
122  //colorKeyToIdMap.clear();
123  //gradientKeyToIdMap.clear();
124  //lineEndingKeyToIdMap.clear();
125  //pGRI=this->mvGlobalRenderInformationObjects[i]->toSBML(colorKeyToIdMap,gradientKeyToIdMap,lineEndingKeyToIdMap);
126  pGRI = rlolPlugin->createGlobalRenderInformation();
127  this->mvGlobalRenderInformationObjects[i]->toSBML(pGRI, pLoL->getLevel(), pLoL->getVersion());
128  // add the id and key to the map
129  assert(pGRI != NULL);
130  keyToIdMap.insert(std::pair<std::string, std::string>(this->mvGlobalRenderInformationObjects[i]->getKey(), pGRI->getId()));
131  //colorKeyToIdMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getId(),colorKeyToIdMap));
132  //gradientKeyToIdMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getId(),gradientKeyToIdMap));
133  //lineEndingKeyToIdMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pGRI->getId(),lineEndingKeyToIdMap));
134  }
135 
136  // fix the references
137  // we need to pass the ListOfGlobalRenderInformation objects as the first argument
138  SBMLDocumentLoader::convertRenderInformationReferencesKeys<GlobalRenderInformation>(*(rlolPlugin->getListOfGlobalRenderInformation()), keyToIdMap);
139  // fix the color ids, gradient ids and line ending ids.
140 
141  // we will generate sbml ids that are unique within the sbml file (although
142  // this may not be strictly necessary for the layouts). Therefore we will keep only
143  // one set of IDs:
144  std::map<std::string, const SBase*> sbmlIDs = idMap;
145 
146  //this will contain the SBML objects that were touched by this method.
147  std::set<SBase*> writtenToSBML;
148 
149  //some of the following code is currently useless: Layouts are never part of
150  //the copasimodelmap.
151 
152  //write all COPASI object to corresponding libsbml objects
153  imax = this->size();
154 
155  for (i = 0; i < imax; ++i)
156  {
157  CLayout * tmp = (*this)[i];
158 
159  //check if the layout exists in the libsbml data
160  std::map<const CCopasiObject*, SBase*>::const_iterator it;
161  it = copasimodelmap.find(tmp);
162 
163  Layout * pLayout;
164 
165  if (it == copasimodelmap.end()) //not found
166  {
167  //create new object and add to libsbml data structures
168  // the layout needs to be created with the correct level and version
169  // otherwise the render infromation is not correctly exported
170  // because newer version is libsbml set the level to 3 per default
171  //pLayout = new Layout(level, version);
172 
173  // the issue with the above is that the render package is not automatically
174  // instantiated (we really ought to simply call ->createLayout on the plugin object)
175  // until then we simply take all the namespaces from the parent element with us
176  LAYOUT_CREATE_NS(layoutns, lol->getSBMLNamespaces());
177  pLayout = new Layout(layoutns);
178 
179  lol->appendAndOwn(pLayout);
180 
181  //add object to map
182  //copasimodelmap[tmp] = pLayout; should not really be done in export
183  }
184  else
185  {
186  pLayout = dynamic_cast<Layout*>(it->second);
187  }
188 
189  //tmp->exportToSBML(pLayout, copasimodelmap, sbmlIDs,keyToIdMap,colorKeyToIdMapMap,gradientKeyToIdMapMap,lineEndingKeyToIdMapMap);
190  tmp->exportToSBML(pLayout, copasimodelmap, sbmlIDs, keyToIdMap);
191  writtenToSBML.insert(pLayout);
192  }
193 
194  //check if a something needs to be deleted from the SBML data structures
195  for (i = lol->size(); i > 0; --i)
196  {
197  SBase* object = lol->get((unsigned int) i - 1);
198 
199  if (writtenToSBML.find(object) == writtenToSBML.end())
200  {
201  lol->remove((unsigned int) i - 1);
202  pdelete(object);
203 
204  //TODO: delete from map
205  //the object and every object it contains need to be removed from the
206  //map.
207  //For now I do not implement this since layout object are not added to the
208  //map in the first place.
209  }
210  }
211 }
#define pdelete(p)
Definition: copasi.h:215
virtual size_t size() const
CCopasiVector< CLGlobalRenderInformation > mvGlobalRenderInformationObjects
#define LAYOUT_CREATE_NS(variable, sbmlns)
const std::string & getKey()
void exportToSBML(Layout *layout, const std::map< const CCopasiObject *, SBase * > &copasimodelmap, std::map< std::string, const SBase * > &sbmlIDs, const std::map< std::string, std::string > &globalKeyToIdMap) const
Definition: CLayout.cpp:392
const std::string & CListOfLayouts::getKey ( )

Definition at line 69 of file CListOfLayouts.cpp.

References mKey.

Referenced by exportToSBML().

70 {
71  return mKey;
72 }
std::string mKey
const CCopasiVector< CLGlobalRenderInformation >& CListOfLayouts::getListOfGlobalRenderInformationObjects ( ) const
inline
CCopasiVector< CLGlobalRenderInformation >& CListOfLayouts::getListOfGlobalRenderInformationObjects ( )
inline

Definition at line 66 of file CListOfLayouts.h.

References mvGlobalRenderInformationObjects.

67  {return this->mvGlobalRenderInformationObjects;};
CCopasiVector< CLGlobalRenderInformation > mvGlobalRenderInformationObjects
CLGlobalRenderInformation * CListOfLayouts::getRenderInformation ( size_t  index)

Returns a pointer to the global render information object with the given index. If the index is invalid, NULL is returned.

Definition at line 225 of file CListOfLayouts.cpp.

References mvGlobalRenderInformationObjects, and CCopasiVector< T >::size().

Referenced by CQNewMainWindow::addGlobalRenderInfoItemsToList(), CQNewMainWindow::slotRenderInfoChanged(), and CQNewMainWindow::updateRenderInformationList().

226 {
227  if (index < this->mvGlobalRenderInformationObjects.size())
228  {
229  return this->mvGlobalRenderInformationObjects[index];
230  }
231 
232  return NULL;
233 }
virtual size_t size() const
CCopasiVector< CLGlobalRenderInformation > mvGlobalRenderInformationObjects
const CLGlobalRenderInformation * CListOfLayouts::getRenderInformation ( size_t  index) const

Returns a const pointer to the global render information object with the given index. If the index is invalid, NULL is returned.

Definition at line 239 of file CListOfLayouts.cpp.

References mvGlobalRenderInformationObjects, and CCopasiVector< T >::size().

240 {
241  if (index < this->mvGlobalRenderInformationObjects.size())
242  {
243  return this->mvGlobalRenderInformationObjects[index];
244  }
245 
246  return NULL;
247 }
virtual size_t size() const
CCopasiVector< CLGlobalRenderInformation > mvGlobalRenderInformationObjects

Member Data Documentation

std::string CListOfLayouts::mKey
private

Definition at line 32 of file CListOfLayouts.h.

Referenced by getKey(), and ~CListOfLayouts().

CCopasiVector<CLGlobalRenderInformation> CListOfLayouts::mvGlobalRenderInformationObjects
private

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