bool RenderExtension::isInUse(SBMLDocument *doc) const { if (doc == NULL || doc->getModel() == NULL) return false; LayoutModelPlugin* plugin = (LayoutModelPlugin*)doc->getModel()->getPlugin("layout"); if (plugin == NULL || plugin->getNumLayouts() == 0) return false; RenderListOfLayoutsPlugin* lolPlugin = (RenderListOfLayoutsPlugin*) plugin->getListOfLayouts()->getPlugin("render"); if (lolPlugin != NULL && lolPlugin->getNumGlobalRenderInformationObjects() > 0) return true; for(int i = 0; i < plugin->getNumLayouts(); i++) { Layout* layout = plugin->getLayout(i); RenderLayoutPlugin* rPlugin = (RenderLayoutPlugin*)layout->getPlugin("render"); if (rPlugin != NULL && rPlugin->getNumLocalRenderInformationObjects() > 0) return true; } return false; }
//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; //std::map<std::string,std::map<std::string,std::string> > colorIdToKeyMapMap; //std::map<std::string,std::map<std::string,std::string> > gradientIdToKeyMapMap; //std::map<std::string,std::map<std::string,std::string> > lineEndingIdToKeyMapMap; for (i = 0; i < iMax; ++i) { //colorIdToKeyMap.clear(); //gradientIdToKeyMap.clear(); //lineEndingIdToKeyMap.clear(); //pLRI=new CLLocalRenderInformation(*sbmlLayout.getRenderInformation(i),colorIdToKeyMap,gradientIdToKeyMap,lineEndingIdToKeyMap,layout); pLRI = new CLLocalRenderInformation(*rlPlugin->getRenderInformation(i), layout); if (rlPlugin->getRenderInformation(i)->isSetId()) idToKeyMap.insert(std::pair<std::string, std::string>(rlPlugin->getRenderInformation(i)->getId(), pLRI->getKey())); else idToKeyMap.insert(std::pair<std::string, std::string>(pLRI->getKey(), pLRI->getKey())); //colorIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),colorIdToKeyMap)); //gradientIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),gradientIdToKeyMap)); //lineEndingIdToKeyMapMap.insert(std::pair<std::string,std::map<std::string,std::string> >(pLRI->getKey(),lineEndingIdToKeyMap)); // fix the references to layout objects in id lists size_t j, jMax = pLRI->getNumStyles(); for (j = 0; j < jMax; j++) { SBMLDocumentLoader::convertLayoutObjectIds(*(pLRI->getStyle(j)), layoutmap); } layout->addLocalRenderInformation(pLRI); } // fix the references // we have to consider the global ids as well // since all ids in these two map should be unique, we can just combine them size_t count = idToKeyMap.size() + globalIdToKeyMap.size(); idToKeyMap.insert(globalIdToKeyMap.begin(), globalIdToKeyMap.end()); // make sure the ids were really unique assert(idToKeyMap.size() == count); SBMLDocumentLoader::convertRenderInformationReferencesIds<CLLocalRenderInformation>(layout->getListOfLocalRenderInformationObjects(), idToKeyMap); // fix the color ids, gradient ids and line ending ids. /* std::map<std::string,std::map<std::string,std::string> >::const_iterator mapPos; std::map<std::string,std::map<std::string,std::string> > expandedColorIdToKeyMapMap, expandedGradientIdToKeyMapMap, expandedLineEndingIdToKeyMapMap; for(i=0;i < iMax; ++i) { pLRI=dynamic_cast<CLLocalRenderInformation*>(layout->getRenderInformation(i)); assert(pLRI != NULL); std::set<std::string> chain; SBMLDocumentLoader::expandIdToKeyMaps<CLLocalRenderInformation>(pLRI, layout->getListOfLocalRenderInformationObjects(), expandedColorIdToKeyMapMap, expandedGradientIdToKeyMapMap, expandedLineEndingIdToKeyMapMap, colorIdToKeyMapMap, gradientIdToKeyMapMap, lineEndingIdToKeyMapMap, chain, globalColorIdToKeyMapMap, globalGradientIdToKeyMapMap, globalLineEndingIdToKeyMapMap ); SBMLDocumentLoader::convertPropertyKeys<CLLocalRenderInformation>(pLRI,expandedColorIdToKeyMapMap[pLRI->getKey()],expandedGradientIdToKeyMapMap[pLRI->getKey()],expandedLineEndingIdToKeyMapMap[pLRI->getKey()]); } */ #endif /* USE_CRENDER_EXTENSION */ return layout; }