当前位置: 首页>>代码示例>>C++>>正文


C++ CLayout::addMetaboliteGlyph方法代码示例

本文整理汇总了C++中CLayout::addMetaboliteGlyph方法的典型用法代码示例。如果您正苦于以下问题:C++ CLayout::addMetaboliteGlyph方法的具体用法?C++ CLayout::addMetaboliteGlyph怎么用?C++ CLayout::addMetaboliteGlyph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLayout的用法示例。


在下文中一共展示了CLayout::addMetaboliteGlyph方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CLayout

//static
CLayout * SBMLDocumentLoader::createLayout(const Layout & sbmlLayout,
    const std::map<std::string, std::string> & modelmap,
    std::map<std::string, std::string> & layoutmap
#ifdef USE_CRENDER_EXTENSION
    , const std::map<std::string, std::string>& globalIdToKeyMap
    //,const std::map<std::string,std::map<std::string,std::string> >& globalColorIdToKeyMapMap
    //,const std::map<std::string,std::map<std::string,std::string> >& globalGradientIdToKeyMapMap
    //,const std::map<std::string,std::map<std::string,std::string> >& globalLineEndingIdToKeyMapMap
#endif /* USE_CRENDER_EXTENSION */
    , const CCopasiContainer * pParent
                                          )
{
  CLayout* layout = new CLayout(sbmlLayout, layoutmap, pParent);

  //compartments
  unsigned C_INT32 i, iMax = sbmlLayout.getListOfCompartmentGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const CompartmentGlyph* tmp
        = dynamic_cast<const CompartmentGlyph*>(sbmlLayout.getListOfCompartmentGlyphs()->get(i));

      if (tmp)
        layout->addCompartmentGlyph(new CLCompartmentGlyph(*tmp, modelmap, layoutmap));
    }

  //species
  iMax = sbmlLayout.getListOfSpeciesGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const SpeciesGlyph* tmp
        = dynamic_cast<const SpeciesGlyph*>(sbmlLayout.getListOfSpeciesGlyphs()->get(i));

      if (tmp)
        layout->addMetaboliteGlyph(new CLMetabGlyph(*tmp, modelmap, layoutmap));
    }

  //reactions
  iMax = sbmlLayout.getListOfReactionGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const ReactionGlyph* tmp
        = dynamic_cast<const ReactionGlyph*>(sbmlLayout.getListOfReactionGlyphs()->get(i));

      if (tmp)
        layout->addReactionGlyph(new CLReactionGlyph(*tmp, modelmap, layoutmap));
    }

  //text
  iMax = sbmlLayout.getListOfTextGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const TextGlyph* tmp
        = dynamic_cast<const TextGlyph*>(sbmlLayout.getListOfTextGlyphs()->get(i));

      if (tmp)
        layout->addTextGlyph(new CLTextGlyph(*tmp, modelmap, layoutmap));
    }

  //additional
  iMax = sbmlLayout.getListOfAdditionalGraphicalObjects()->size();

  for (i = 0; i < iMax; ++i)
    {
      const GraphicalObject* graphical
        = dynamic_cast<const GraphicalObject*>(sbmlLayout.getListOfAdditionalGraphicalObjects()->get(i));

      if (graphical)
        layout->addGeneralGlyph(new CLGeneralGlyph(*graphical, modelmap, layoutmap));
    }

  //second pass text (the text glyph can refer to other glyphs. These references can)
  //only be resolved after all glyphs are created).
  iMax = sbmlLayout.getListOfTextGlyphs()->size();

  for (i = 0; i < iMax; ++i)
    {
      const TextGlyph* tmp
        = dynamic_cast<const TextGlyph*>(sbmlLayout.getListOfTextGlyphs()->get(i));

      if (tmp)
        postprocessTextGlyph(*tmp, layoutmap);
    }

#ifdef USE_CRENDER_EXTENSION
  RenderLayoutPlugin* rlPlugin = (RenderLayoutPlugin*) sbmlLayout.getPlugin("render");
  assert(rlPlugin != NULL);

  // import the local render information
  iMax = rlPlugin->getNumLocalRenderInformationObjects();
  std::map<std::string, std::string> idToKeyMap;
  CLLocalRenderInformation* pLRI = NULL;

  //std::map<std::string,std::string> colorIdToKeyMap;
  //std::map<std::string,std::string> gradientIdToKeyMap;
  //std::map<std::string,std::string> lineEndingIdToKeyMap;
//.........这里部分代码省略.........
开发者ID:sachiinb,项目名称:COPASI,代码行数:101,代码来源:SBMLDocumentLoader.cpp

示例2: createLayout

CLayout* CCopasiSpringLayout::createLayout(
  CDataContainer *parent,
  const std::set<const CCompartment*>& compartments,
  const std::set<const CReaction*>& reactions,
  const std::set<const CMetab*>& metabs,
  const std::set<const CMetab*>& sideMetabs,
  Parameters* mParams
)
{
  CLayout *pResult = new CLayout("Layout", parent);

  double fontSize = 16.0;
  double fontHeight = fontSize * 1.5;

  // create a species glyph for each species in metabs

  std::map<const CCompartment*, CompartmentInfo> compInfo;
  std::map<const CMetab*, CLMetabGlyph*> metabMap;

  std::set<const CMetab*>::const_iterator metabIt;

  for (metabIt = metabs.begin(); metabIt != metabs.end(); ++metabIt)
    {
      if (sideMetabs.find(*metabIt) != sideMetabs.end())
        continue;

      //estimate the size of the glyph
      double width = (double)((*metabIt)->getObjectName().length() * fontSize);
      double height = (double)fontHeight;

      if (width < height)
        {
          width = height;
        }

      //create the glyph
      CLMetabGlyph* pMetabGlyph = new CLMetabGlyph;
      pMetabGlyph->setDimensions(CLDimensions(width + 4, height + 4));
      pMetabGlyph->setModelObjectKey((*metabIt)->getKey());

      pResult->addMetaboliteGlyph(pMetabGlyph);
      metabMap[*metabIt] = pMetabGlyph;

      //create the text glyph for the label
      CLTextGlyph* pTextGlyph = new CLTextGlyph;
      pTextGlyph->setDimensions(CLDimensions(width, height));
      pTextGlyph->setGraphicalObjectKey(pMetabGlyph->getKey());
      pTextGlyph->setModelObjectKey((*metabIt)->getKey());

      pResult->addTextGlyph(pTextGlyph);

      //add up the sizes for the compartment
      const CCompartment* pComp = NULL;

      if (compartments.find((*metabIt)->getCompartment()) != compartments.end())
        pComp = (*metabIt)->getCompartment();

      compInfo[pComp].add((width + 4) * (height + 4));
    }

  //now the reaction glyphs
  std::set<const CReaction*>::const_iterator reactIt;

  for (reactIt = reactions.begin(); reactIt != reactions.end(); ++reactIt)
    {
      CLReactionGlyph* pReactionGlyph = new CLReactionGlyph;
      //pResult->setDimensions(CLDimensions(width, height));
      pReactionGlyph->setModelObjectKey((*reactIt)->getKey());
      //pReactionGlyph->getCurve().addCurveSegment(CLLineSegment(CLPoint(x, y),
      //                                             CLPoint(x + length, y)));
      bool isReversible = (*reactIt)->isReversible();
      pResult->addReactionGlyph(pReactionGlyph);

      //now add the species reference glyphs.

      //substrates
      const CDataVector < CChemEqElement >& substrates = (*reactIt)->getChemEq().getSubstrates();
      bool substrateExists = false;
      CDataVector<CChemEqElement>::const_iterator elIt;

      for (elIt = substrates.begin(); elIt != substrates.end(); ++elIt)
        {
          const CMetab* pMetab = elIt->getMetabolite();

          if (!pMetab)
            continue;

          CLMetabGlyph* pMetabGlyph = NULL;
          CLMetabReferenceGlyph::Role role; // = CLMetabReferenceGlyph::SUBSTRATE;
          CLMetabReferenceGlyph::Role functionalRole;

          //is it a side reactant? If yes, create a new metab glyph
          if (sideMetabs.find(pMetab) != sideMetabs.end())
            {
              //estimate the size of the glyph
              double width = (double)((pMetab)->getObjectName().length() * fontSize);
              double height = (double)fontHeight;

              if (width < height)
                {
//.........这里部分代码省略.........
开发者ID:copasi,项目名称:COPASI,代码行数:101,代码来源:CCopasiSpringLayout.cpp


注:本文中的CLayout::addMetaboliteGlyph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。