std::string RectangleShape::asString() const
{
	std::ostringstream os;

	os << Shape::asString() << ", ";
	os << "centre: " << Shape2DUtils::asString(centre) << ", ";
	os << "size: " << Shape2DUtils::asString(size) << ", ";
	os << "title: " << title << ", ";
	os << "titleSize: " << Shape2DUtils::asString(titleSize) << ", ";
	os << "borderWidth: " << borderWidth << ", ";
	os << "spacing: " << spacing << ", ";
	os << "modelObject: " << (getModelObject() ? getModelObject()->asString() : "none");

	return os.str();
}
Ejemplo n.º 2
0
std::string CLGraphicalObject::getModelObjectName() const
{
  CCopasiObject * tmp = getModelObject();

  if (tmp)
    return tmp->getObjectName();
  else
    return "";
}
Ejemplo n.º 3
0
void CLReactionGlyph::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
{
  if (!g) return;

  //call the coresponding method of the base class
  CLGraphicalObject::exportToSBML(g, copasimodelmap, sbmlIDs);

  //reference to model objects
  CCopasiObject* tmp = getModelObject();

  if (tmp)
    {
      std::map<const CCopasiObject*, SBase*>::const_iterator it = copasimodelmap.find(tmp);

      if (it != copasimodelmap.end())
        {
          if (it->second)
            g->setReactionId(it->second->getId());
        }
    }

  //curve
  mCurve.exportToSBML(g->getCurve(), copasimodelmap);

  //Metab reference  glyphs
  size_t i, imax = mvMetabReferences.size();

  for (i = 0; i < imax; ++i)
    {
      CLMetabReferenceGlyph * tmp = mvMetabReferences[i];

      //check if the glyph exists in the libsbml data
      std::map<const CCopasiObject*, SBase*>::const_iterator it;
      it = copasimodelmap.find(tmp);

      SpeciesReferenceGlyph * pG;

      if (it == copasimodelmap.end()) //not found
        {
          pG = new SpeciesReferenceGlyph;
          g->getListOfSpeciesReferenceGlyphs()->appendAndOwn(pG);
        }
      else
        {
          pG = dynamic_cast<SpeciesReferenceGlyph*>(it->second);
        }

      layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
      tmp->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
    }
}
Ejemplo n.º 4
0
std::string CLGraphicalObject::getModelObjectDisplayName(bool /* regular */, bool /* richtext */) const
{
  CCopasiObject * tmp = getModelObject();

  if (tmp)
    {
      return tmp->getObjectName();
    }
  else
    {
      return "";
    }
}
Ejemplo n.º 5
0
boost::optional<IddObjectType> OSDocument::getIddObjectType(const OSItemId& itemId) const
{
  if (fromBCL(itemId)){
    boost::optional<BCLComponent> component = LocalBCL::instance().getComponent(itemId.itemId().toStdString());
    if (component){
      BOOST_FOREACH(const Attribute& attribute, component->attributes()){
        if (istringEqual("OpenStudio Type", attribute.name())){
          try{
            IddObjectType iddObjectType(attribute.valueAsString());
            return iddObjectType;
          }catch(...){
          }
        }
      }
    }
  }

  boost::optional<model::ModelObject> modelObject = getModelObject(itemId);
  if (modelObject){
    return modelObject->iddObjectType();
  }

  return boost::none;
}
Ejemplo n.º 6
0
WayPointPtr WayPointShape::getWayPoint() const
{
	return std::dynamic_pointer_cast<WayPoint>(getModelObject());
}
Ejemplo n.º 7
0
void CLGeneralGlyph::exportToSBML(GraphicalObject * g, //TODO
                                  const std::map<const CCopasiObject*, SBase*> & copasimodelmap,
                                  std::map<std::string, const SBase*>& sbmlIDs,
                                  std::map<const CLBase*, const SBase*> & layoutmap) const
{
  if (!g) return;

  //call the coresponding method of the base class
  CLGraphicalObject::exportToSBML(g, copasimodelmap, sbmlIDs);

#if LIBSBML_VERSION >= 50800

  GeneralGlyph *general = dynamic_cast<GeneralGlyph *>(g);

  if (!general) return;

  //reference to model objects
  CCopasiObject* tmp = getModelObject();

  if (tmp)
    {
      std::map<const CCopasiObject*, SBase*>::const_iterator it = copasimodelmap.find(tmp);

      if (it != copasimodelmap.end())
        {
          if (it->second)
            general->setReferenceId(it->second->getId());
        }

      const CLBase* base = dynamic_cast<const CLBase*>(tmp);

      if (base)
        {
          std::map<const CLBase*, const SBase*>::const_iterator it2 = layoutmap.find(base);

          if (it2 != layoutmap.end())
            {
              if (it2->second)
                general->setReferenceId(it2->second->getId());
            }
        }
    }

  //curve
  mCurve.exportToSBML(general->getCurve(), copasimodelmap);

  //reference  glyphs
  size_t i, imax = mvReferences.size();

  for (i = 0; i < imax; ++i)
    {
      CLReferenceGlyph * tmp = mvReferences[i];

      //check if the glyph exists in the libsbml data
      std::map<const CCopasiObject*, SBase*>::const_iterator it;
      it = copasimodelmap.find(tmp);

      ReferenceGlyph * pG;

      if (it == copasimodelmap.end()) //not found
        {
          pG = general->createReferenceGlyph();
        }
      else
        {
          pG = dynamic_cast<ReferenceGlyph*>(it->second);
        }

      layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));
      tmp->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
    }

  imax = mvSubglyphs.size();

  for (i = 0; i < imax; ++i)
    {
      CLGraphicalObject * tmp = mvSubglyphs[i];
      CLMetabGlyph * metab =  dynamic_cast<CLMetabGlyph*>(tmp);
      CLCompartmentGlyph* comp =  dynamic_cast<CLCompartmentGlyph*>(tmp);
      CLGeneralGlyph* gg =  dynamic_cast<CLGeneralGlyph*>(tmp);
      CLTextGlyph* text =  dynamic_cast<CLTextGlyph*>(tmp);

      //check if the glyph exists in the libsbml data
      std::map<const CCopasiObject*, SBase*>::const_iterator it;
      it = copasimodelmap.find(tmp);

      GraphicalObject * pG;

      if (it == copasimodelmap.end()) //not found
        {
          if (metab)
            pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createSpeciesGlyph();
          else if (comp)
            pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createCompartmentGlyph();
          else if (gg)
            pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createGeneralGlyph();
          else if (text)
            pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createTextGlyph();
          else
            pG = ((Layout*)g->getParentSBMLObject()->getParentSBMLObject())->createAdditionalGraphicalObject();
        }
      else
        {
          pG = dynamic_cast<GraphicalObject*>(it->second);
        }

      layoutmap.insert(std::pair<const CLBase*, const SBase*>(tmp, pG));

      if (metab)
        metab->exportToSBML(static_cast<SpeciesGlyph*>(pG), copasimodelmap, sbmlIDs);
      else if (comp)
        comp->exportToSBML(static_cast<CompartmentGlyph*>(pG), copasimodelmap, sbmlIDs);
      else if (text)
        text->exportToSBML(static_cast<TextGlyph*>(pG), copasimodelmap, sbmlIDs);
      else if (gg)
        gg->exportToSBML(pG, copasimodelmap, sbmlIDs, layoutmap);
      else
        tmp->exportToSBML(pG, copasimodelmap, sbmlIDs);
    }

#endif // LIBSBML_VERSION >= 50800
}