bool 
LayoutExtension::isInUse(SBMLDocument *doc) const
{
  if (doc == NULL || doc->getModel() == NULL) return false;
  LayoutModelPlugin* plugin = (LayoutModelPlugin*)doc->getModel()->getPlugin("layout");
  if (plugin == NULL) return false;

  return (plugin->getNumLayouts() > 0);
}
示例#2
0
  void convertLayoutToL2()
  {    
    if (_doc == NULL || _doc->getModel() == NULL)
      return;

    layoutNsUri = "http://projects.eml.org/bcb/sbml/level2";
    layoutNs = new LayoutPkgNamespaces(2, 1);

#ifdef LIBSBML_HAS_PACKAGE_RENDER
    foundRenderElements = false;
    renderNsUri = "http://projects.eml.org/bcb/sbml/render/level2";
    renderNs = new RenderPkgNamespaces(2, 1);
#endif

    LayoutModelPlugin* plugin
      = (LayoutModelPlugin*)_doc->getModel()->getPlugin("layout");
    if (plugin == NULL) 
      return;


    ConversionProperties prop(new SBMLNamespaces(2, 4));
    prop.addOption("strict", false);
    prop.addOption("setLevelAndVersion", true);
    prop.addOption("ignorePackages", true);

    if (_doc->convert(prop) != LIBSBML_OPERATION_SUCCESS)
    {
      cout << "Conversion failed!" << endl;
      _doc->printErrors();
      exit(2);  
    }


    plugin->setElementNamespace(layoutNsUri);

    SBMLDocumentPlugin *docPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("layout");
    if (docPlugin != NULL)
      docPlugin->setElementNamespace(layoutNsUri);


    updateNs(plugin->getListOfLayouts());

    _doc->getSBMLNamespaces()->removePackageNamespace(3, 1, "layout", 1);        

#ifdef LIBSBML_HAS_PACKAGE_RENDER
    SBMLDocumentPlugin *rdocPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("render");
    if (rdocPlugin!= NULL)
      rdocPlugin->setElementNamespace(renderNsUri);
    _doc->getSBMLNamespaces()->removePackageNamespace(3, 1, "render", 1);        
#endif
  }
示例#3
0
LIBSBML_CPP_NAMESPACE_USE

int main(int argc, char** argv){

  if (argc != 2)
  {
    cout << endl << "Usage: addLayout input-filename"
         << endl << endl;
    return 2;
  }

  SBMLDocument *d = readSBML(argv[1]);
  if ( d->getNumErrors() > 0)
  {
    d->printErrors();
  }
  else
  {
    // enable the layout package
    // note layout in L2 uses a different namespace than L3
    if (d->getLevel() == 2)
    {
      d->enablePackage(LayoutExtension::getXmlnsL2(), "layout",  true);
    }
    else if (d->getLevel() == 3)
    {
      d->enablePackage(LayoutExtension::getXmlnsL3V1V1(), "layout",  true);
    }

    // get the model plugin
    Model * model = d->getModel();

    LayoutModelPlugin* mplugin
      = static_cast<LayoutModelPlugin*>(model->getPlugin("layout"));
    
    // create the Layout
    LayoutPkgNamespaces layoutns(d->getLevel(), d->getVersion());
    Layout* layout = mplugin->createLayout();

    layout->setId("Layout_1");
    Dimensions dim(&layoutns, 400.0, 220.0);
    layout->setDimensions(&dim);

    // write out the model
    writeSBML(d, "added-layout.xml");
  }
}
  void convertLayoutToL3()
  {
    if (_doc == NULL || _doc->getModel() == NULL)
      return;


    layoutNsUri = "http://www.sbml.org/sbml/level3/version1/layout/version1";
    layoutNs = new LayoutPkgNamespaces(3, 1, 1);

#ifdef CONVERT_RENDER
    renderNsUri = "http://www.sbml.org/sbml/level3/version1/render/version1";
    renderNs = new RenderPkgNamespaces(3, 1, 1);
#endif

    LayoutModelPlugin* plugin = (LayoutModelPlugin*)_doc->getModel()->getPlugin("layout");
    if (plugin == NULL) 
      return;


    ConversionProperties prop(new SBMLNamespaces(3, 1));
    prop.addOption("strict", false);
    prop.addOption("setLevelAndVersion", true);
    prop.addOption("ignorePackages", true);

    _doc->convert(prop);

    plugin->setElementNamespace(layoutNsUri);

    SBMLDocumentPlugin *docPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("layout");
    if (docPlugin != NULL)
      docPlugin->setElementNamespace(layoutNsUri);

    updateNs(plugin->getListOfLayouts());
    
    _doc->getSBMLNamespaces()->addPackageNamespace("layout", 1);
    _doc->setPackageRequired("layout", false);

#ifdef CONVERT_RENDER
    SBMLDocumentPlugin *rdocPlugin = (SBMLDocumentPlugin*)_doc->getPlugin("render");
    if (rdocPlugin != NULL)
      rdocPlugin->setElementNamespace(renderNsUri);
    _doc->getSBMLNamespaces()->addPackageNamespace("render", 1);
    _doc->setPackageRequired("render", false);
#endif

  }
END_TEST

START_TEST ( test_RenderExtension_writeL3Render )
{
    RenderPkgNamespaces renderns;
    LayoutPkgNamespaces layoutns;

    SBMLDocument doc(3,1);

    doc.enablePackage(layoutns.getURI(), "layout", true);
    doc.enablePackage(renderns.getURI(), "render", true);

    Model* model = doc.createModel();

    LayoutModelPlugin *lPlugin = (LayoutModelPlugin*)model->getPlugin("layout");
    fail_unless(lPlugin != NULL);

    Layout* layout = lPlugin->createLayout();
    Dimensions dim(&layoutns, 100,100 );
    layout->setDimensions(&dim);

    GraphicalObject* additional = layout->createAdditionalGraphicalObject();
    additional->setId("go1");
    BoundingBox bb(&layoutns, "bb1", 10, 10, 90, 90);
    additional->setBoundingBox(&bb);

    RenderLayoutPlugin *rPlugin = (RenderLayoutPlugin*)layout->getPlugin("render");
    fail_unless(rPlugin != NULL);

    LocalRenderInformation* local = rPlugin->createLocalRenderInformation();

    ColorDefinition *black = local->createColorDefinition();
    black->setId("black");
    black->setColorValue("#000000");

    LocalStyle *lStyle = local->createStyle("style_go1");
    lStyle->addId("go1");
    RenderGroup* group = lStyle->getGroup();
    group->setStroke("black");


    std::string sbml = writeSBMLToStdString(&doc);

    fail_unless (sbml.length() != 0);

}
示例#6
0
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;
}
示例#7
0
/**
 * This method tries to import CellDesigner annotations.
 */
void DataModelGUI::importCellDesigner()
{
  // add code to check for CellDesigner annotations
  // ask the user if the annotations should be imported
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  if (pDataModel != NULL)
    {
      SBMLDocument* pSBMLDocument = pDataModel->getCurrentSBMLDocument();

      if (pSBMLDocument != NULL &&
          pSBMLDocument->getModel() != NULL &&
          pSBMLDocument->getModel()->getAnnotation() != NULL)
        {
          // check for the CellDesigner namespace
          std::pair<bool, std::string> foundNamespace = CCellDesignerImporter::findCellDesignerNamespace(pSBMLDocument);

          if (foundNamespace.first == true)
            {
              const XMLNode* pAnno = CCellDesignerImporter::findCellDesignerAnnotation(pSBMLDocument, pSBMLDocument->getModel()->getAnnotation());

              // first we check if there are supported cell designer annotations
              if (pAnno != NULL)
                {
                  // check if the file contains the correct version
                  double version = CCellDesignerImporter::determineVersion(pAnno);

                  if (version < 4.0)
                    {
                      CCopasiMessage(CCopasiMessage::RAW, "CellDesigner annotation was found in the file, but the version is not supported.\nPlease open the file in the latest version of CellDesigner and save it again.");
                    }
                  else
                    {
                      bool importCD = false;
#if LIBSBML_VERSION >= 50400
                      // if we don't have a layout import it!
                      LayoutModelPlugin* mplugin = (LayoutModelPlugin*)pSBMLDocument->getModel()->getPlugin("layout");

                      if (mplugin == NULL || (mplugin != NULL && mplugin->getNumLayouts() == 0))
                        importCD = true;

#endif

                      // ask the user if the CellDesigner annotation should be imported
                      if (importCD || CQMessageBox::question(NULL, "CellDesigner import", "A CellDesigner diagram was found in this file.\nDo you want to import the diagram?" , QMessageBox::Yes | QMessageBox::No , QMessageBox::No) == QMessageBox::Yes)
                        {
                          // do the import
                          CCellDesignerImporter cd_importer(pSBMLDocument);

                          if (cd_importer.getLayout() == NULL)
                            {
                              CCopasiMessage(CCopasiMessage::WARNING, "Sorry, CellDesigner annotations could not be importet.");
                            }
                          else
                            {
                              // now we have to import the created layout
                              // create the model map
                              std::string s1, s2;
                              std::map<std::string, std::string> modelmap;
                              std::map<CCopasiObject*, SBase*>::const_iterator it;
                              std::map<CCopasiObject*, SBase*>::const_iterator itEnd = pDataModel->getCopasi2SBMLMap().end();

                              for (it = pDataModel->getCopasi2SBMLMap().begin(); it != itEnd; ++it)
                                {
                                  s1 = SBMLUtils::getIdFromSBase(it->second);

                                  if (it->first)
                                    {
                                      s2 = it->first->getKey();
                                    }
                                  else
                                    {
                                      s2 = "";
                                    }

                                  if ((s1 != "") && (s2 != ""))
                                    {
                                      modelmap[s1] = s2;
                                    }
                                }

                              // the layout map and the id to key map can be empty
                              std::map<std::string, std::string> layoutmap;
                              std::map<std::string, std::string> idToKeyMap;
#ifdef USE_CRENDER_EXTENSION
                              CLayout* pLayout = SBMLDocumentLoader::createLayout(*cd_importer.getLayout(), modelmap, layoutmap, idToKeyMap);
#else
                              CLayout* pLayout = SBMLDocumentLoader::createLayout(*cd_importer.getLayout(), modelmap, layoutmap);
#endif /* USE_CRENDER_EXTENSION */

                              // add the layout to the DataModel
                              if (pLayout != NULL && pDataModel->getListOfLayouts() != NULL)
                                {
                                  // the addLayout methods expects a map as the second argument which currently is
                                  // ignored, so we just pass an empty one
                                  // TODO maybe the methods actually expects one of the maps above (layoutmap or idToKeyMap), but
                                  // TODO this is not documented in CListOfLayouts
                                  std::map<std::string, std::string> tmp;
                                  pDataModel->getListOfLayouts()->addLayout(pLayout, tmp);
                                }
                              else
                                {
                                  CCopasiMessage(CCopasiMessage::WARNING, "Sorry, Layout from CellDesigner annotations could not be created.");
                                }
                            }
                        }
                    }
                }
              else
                {
                  CCopasiMessage(CCopasiMessage::RAW, "CellDesigner annotation was found in the file, but the version is not supported.\nPlease open the file in the latest version of CellDesigner and save it again.");
                }
            }
        }
    }
}
示例#8
0
LIBSBML_CPP_NAMESPACE_USE

int main(int argc, char** argv)
{
    //
    // Creates an SBMLNamespaces object with the given SBML level, version
    // package name.
    //

    SBMLNamespaces sbmlns(2, 3);
    sbmlns.addNamespace(LayoutExtension::getXmlnsL2(), "layout");

    // (NOTES) The above code creating an SBMLNamespaces object can be replaced
    //         with the following other style.
    //
    // (2) Creates a LayoutPkgNamespaces object (SBMLNamespace derived class
    //     for layout package. The class is basically used for createing an
    //     SBase derived objects belonging to the layout package) with the
    //     given SBML level, version.  (Package version is not required by
    //     Layout extension of SBML Level 2)
    //
    //        LayoutPkgNamespaces sbmlns(2, 3);
    //

    // create the document

    SBMLDocument *document = new SBMLDocument(&sbmlns);
    // create the Model

    Model* model = document->createModel();
    model->setId("TestModel_with_modifiers");
    document->setModel(model);

    // create the Layout

    LayoutPkgNamespaces layoutns(2, 3);

    LayoutModelPlugin* mplugin
        = static_cast<LayoutModelPlugin*>(model->getPlugin("layout"));
    Layout* layout = mplugin->createLayout();

    layout->setId("Layout_1");
    Dimensions dim(&layoutns, 400.0, 230.0);
    layout->setDimensions(&dim);


    // create the Compartment

    Compartment* compartment = model->createCompartment();
    compartment->setId("Yeast");

    // create the CompartmentGlyph

    CompartmentGlyph* compartmentGlyph = layout->createCompartmentGlyph();
    compartmentGlyph->setId("CompartmentGlyph_1");
    compartmentGlyph->setCompartmentId(compartment->getId());
    BoundingBox bb(&layoutns, "bb1", 5, 5, 390, 220);
    compartmentGlyph->setBoundingBox(&bb);

    // create the Species, SpeciesGlyphs and associated TextGlyphs

    // Glucose

    Species* species_Gluc = model->createSpecies();
    species_Gluc->setId("Glucose");
    species_Gluc->setCompartment(compartment->getId());

    SpeciesGlyph* glyph_Gluc = layout->createSpeciesGlyph();
    glyph_Gluc->setId("SpeciesGlyph_Glucose");
    glyph_Gluc->setSpeciesId(species_Gluc->getId());
    bb = BoundingBox(&layoutns, "bb2", 105, 20, 130, 20);
    glyph_Gluc->setBoundingBox(&bb);

    TextGlyph* tGlyph = layout->createTextGlyph();
    tGlyph->setId("TextGlyph_Glucose");
    bb = BoundingBox(&layoutns, "bbA", 115, 20, 110, 20);
    tGlyph->setBoundingBox(&bb);
    tGlyph->setOriginOfTextId(species_Gluc->getId());
    tGlyph->setGraphicalObjectId(glyph_Gluc->getId());

    // Glucose-6-phosphate

    Species* species_G6P = model->createSpecies();
    species_G6P->setId("Glucose_hyphen_6_hyphen_phosphate");
    species_G6P->setCompartment(compartment->getId());

    SpeciesGlyph* glyph_G6P = layout->createSpeciesGlyph();
    glyph_G6P->setId("SpeciesGlyph_G6P");
    glyph_G6P->setSpeciesId(species_G6P->getId());
    bb = BoundingBox(&layoutns, "bb5", 50, 190, 270, 20);
    glyph_G6P->setBoundingBox(&bb);

    tGlyph = layout->createTextGlyph();
    tGlyph->setId("TextGlyph_G6P");
    bb = BoundingBox(&layoutns, "bbD", 60, 190, 250, 20);
    tGlyph->setBoundingBox(&bb);
    tGlyph->setOriginOfTextId(species_G6P->getId());
    tGlyph->setGraphicalObjectId(glyph_G6P->getId());

    // ATP

    Species* species_ATP = model->createSpecies();
    species_ATP->setId("ATP");
    species_ATP->setCompartment(compartment->getId());

    SpeciesGlyph* glyph_ATP = layout->createSpeciesGlyph();
    glyph_ATP->setId("SpeciesGlyph_ATP");
    glyph_ATP->setSpeciesId(species_ATP->getId());
    bb = BoundingBox(&layoutns, "bb3", 270, 70, 80, 20);
    glyph_ATP->setBoundingBox(&bb);

    tGlyph = layout->createTextGlyph();
    tGlyph->setId("TextGlyph_ATP");
    bb = BoundingBox(&layoutns, "bbB", 280, 70, 60, 20);
    tGlyph->setBoundingBox(&bb);
    tGlyph->setOriginOfTextId(species_ATP->getId());
    tGlyph->setGraphicalObjectId(glyph_ATP->getId());

    // ADP

    Species* species_ADP = model->createSpecies();
    species_ADP->setId("ADP");
    species_ADP->setCompartment(compartment->getId());

    SpeciesGlyph* glyph_ADP = layout->createSpeciesGlyph();
    glyph_ADP->setId("glyph_ADP");
    glyph_ADP->setSpeciesId(species_ADP->getId());
    bb = BoundingBox(&layoutns, "bb4", 270, 140, 80, 20);
    glyph_ADP->setBoundingBox(&bb);

    tGlyph = layout->createTextGlyph();
    tGlyph->setId("TextGlyph_ADP");
    bb = BoundingBox(&layoutns, "bbC", 280, 140, 60, 20);
    tGlyph->setBoundingBox(&bb);
    tGlyph->setOriginOfTextId(species_ADP->getId());
    tGlyph->setGraphicalObjectId(glyph_ADP->getId());

    // Phosphate

    Species* species_Pi = model->createSpecies();
    species_Pi->setId("Pi");
    species_Pi->setCompartment(compartment->getId());

    SpeciesGlyph* glyph_Pi = layout->createSpeciesGlyph();
    glyph_Pi->setId("SpeciesGlyph_Pi");
    glyph_Pi->setSpeciesId(species_Pi->getId());
    bb = BoundingBox(&layoutns, "bb6", 50, 100, 60, 20);
    glyph_Pi->setBoundingBox(&bb);

    tGlyph = layout->createTextGlyph();
    tGlyph->setId("TextGlyph_PI");
    bb = BoundingBox(&layoutns, "bbE", 60, 100, 40, 20);
    tGlyph->setBoundingBox(&bb);
    tGlyph->setOriginOfTextId(species_Pi->getId());
    tGlyph->setGraphicalObjectId(glyph_Pi->getId());

    // create the Reaction

    Reaction* reaction_Hexokinase = model->createReaction();
    reaction_Hexokinase->setId("Hexokinase");
    reaction_Hexokinase->setReversible(false);

    ReactionGlyph* glyph_Hexokinase = layout->createReactionGlyph();
    glyph_Hexokinase->setId("glyph_Hexokinase");
    glyph_Hexokinase->setReactionId(reaction_Hexokinase->getId());

    Curve* curve_Hexokinase = glyph_Hexokinase->getCurve();
    LineSegment* ls = curve_Hexokinase->createLineSegment();
    Point p(&layoutns, 170, 100);
    ls->setStart(&p);
    p = Point(&layoutns, 170, 130);
    ls->setEnd(&p);

    // create the species reference for glucose

    SpeciesReference* reference_Gluc = reaction_Hexokinase->createReactant();
    reference_Gluc->setSpecies(species_Gluc->getId());
    reference_Gluc->setId("SpeciesReference_Glucose");

    // create species reference glyph for glucose

    SpeciesReferenceGlyph* speciesReferenceGlyph
        = glyph_Hexokinase->createSpeciesReferenceGlyph();
    speciesReferenceGlyph->setId("SpeciesReferenceGlyph_Glucose");
    speciesReferenceGlyph->setSpeciesGlyphId(glyph_Gluc->getId());
    speciesReferenceGlyph->setSpeciesReferenceId(reference_Gluc->getId());
    speciesReferenceGlyph->setRole(SPECIES_ROLE_SUBSTRATE);

    ls = speciesReferenceGlyph->createLineSegment();
    p = Point(&layoutns, 170, 100);
    ls->setStart(&p);
    p = Point(&layoutns, 170, 50);
    ls->setEnd(&p);

    // create species reference for ATP

    SpeciesReference* reference_ATP
        = reaction_Hexokinase->createReactant();
    reference_ATP->setSpecies(species_ATP->getId());
    reference_ATP->setId("SpeciesReference_ATP");

    // create the species reference glyph for ATP

    speciesReferenceGlyph = glyph_Hexokinase->createSpeciesReferenceGlyph();
    speciesReferenceGlyph->setId("SpeciesReferenceGlyph_ATP");
    speciesReferenceGlyph->setSpeciesGlyphId(glyph_ATP->getId());
    speciesReferenceGlyph->setSpeciesReferenceId(reference_ATP->getId());
    speciesReferenceGlyph->setRole(SPECIES_ROLE_SIDESUBSTRATE);

    CubicBezier* cb = speciesReferenceGlyph->createCubicBezier();
    p = Point(&layoutns, 170, 100);
    cb->setStart(&p);
    p = Point(&layoutns, 170, 80);
    cb->setBasePoint1(&p);
    p = Point(&layoutns, 170, 80);
    cb->setBasePoint2(&p);
    p = Point(&layoutns, 260, 80);
    cb->setEnd(&p);

    // create species reference for G6P

    SpeciesReference* reference_G6P = reaction_Hexokinase->createProduct();
    reference_G6P->setSpecies(species_G6P->getId());
    reference_G6P->setId("SpeciesReference_G6P");

    // create species reference for G6P as product

    speciesReferenceGlyph = glyph_Hexokinase->createSpeciesReferenceGlyph();
    speciesReferenceGlyph->setId("SpeciesReferenceGlyph_G6P_1");
    speciesReferenceGlyph->setSpeciesGlyphId(glyph_G6P->getId());
    speciesReferenceGlyph->setSpeciesReferenceId(reference_G6P->getId());
    speciesReferenceGlyph->setRole(SPECIES_ROLE_PRODUCT);

    ls = speciesReferenceGlyph->createLineSegment();
    p = Point(&layoutns, 170, 130);
    ls->setStart(&p);
    p = Point(&layoutns, 170, 180);
    ls->setEnd(&p);

    // create species reference for ADP

    SpeciesReference* reference_ADP = reaction_Hexokinase->createProduct();
    reference_ADP->setSpecies(species_ADP->getId());
    reference_ADP->setId("SpeciesReference_ADP");

    // create the species reference glyph for ADP

    speciesReferenceGlyph = glyph_Hexokinase->createSpeciesReferenceGlyph();
    speciesReferenceGlyph->setId("SpeciesReferenceGlyph_ADP");
    speciesReferenceGlyph->setSpeciesGlyphId(glyph_ADP->getId());
    speciesReferenceGlyph->setSpeciesReferenceId(reference_ADP->getId());
    speciesReferenceGlyph->setRole(SPECIES_ROLE_SIDEPRODUCT);

    cb = speciesReferenceGlyph->createCubicBezier();
    p = Point(&layoutns, 170, 130);
    cb->setStart(&p);
    p = Point(&layoutns, 170, 150);
    cb->setBasePoint1(&p);
    p = Point(&layoutns, 170, 150);
    cb->setBasePoint2(&p);
    p = Point(&layoutns, 260, 150);
    cb->setEnd(&p);

    // create modifier species reference for glucose-6-phosphate

    ModifierSpeciesReference* reference_G6P_2
        = reaction_Hexokinase->createModifier();
    reference_G6P_2->setSpecies(species_G6P->getId());
    reference_G6P_2->setId("ModifierSpeciesReference_G6P");

    reaction_Hexokinase->addModifier(reference_G6P_2);

    // create species reference glyph for G6P as a modifier

    speciesReferenceGlyph = glyph_Hexokinase->createSpeciesReferenceGlyph();
    speciesReferenceGlyph->setId("SpeciesReferenceGlyph_G6P_2");
    speciesReferenceGlyph->setSpeciesReferenceId(reference_G6P_2->getId());
    speciesReferenceGlyph->setSpeciesGlyphId(glyph_G6P->getId());
    speciesReferenceGlyph->setRole(SPECIES_ROLE_INHIBITOR);

    cb = speciesReferenceGlyph->createCubicBezier();
    p = Point(&layoutns, 45, 200);
    cb->setStart(&p);
    p = Point(&layoutns, 0, 200);
    cb->setBasePoint1(&p);
    p = Point(&layoutns, 0, 120);
    cb->setBasePoint2(&p);
    p = Point(&layoutns, 165, 120);
    cb->setEnd(&p);

    // create modifier species reference for phosphate

    ModifierSpeciesReference* reference_Pi = reaction_Hexokinase->createModifier();
    reference_Pi->setSpecies(species_Pi->getId());
    reference_Pi->setId("ModifierSpeciesReference_Pi");

    reaction_Hexokinase->addModifier(reference_Pi);

    // create the species reference glyph for Phosphate

    speciesReferenceGlyph = glyph_Hexokinase->createSpeciesReferenceGlyph();
    speciesReferenceGlyph->setId("SpeciesReferenceGlyph_PI");
    speciesReferenceGlyph->setSpeciesReferenceId(reference_Pi->getId());
    speciesReferenceGlyph->setSpeciesGlyphId(glyph_Pi->getId());
    speciesReferenceGlyph->setRole(SPECIES_ROLE_ACTIVATOR);

    cb = speciesReferenceGlyph->createCubicBezier();
    p = Point(&layoutns, 115, 110);
    cb->setStart(&p);
    p = Point(&layoutns, 140, 110);
    cb->setBasePoint1(&p);
    p = Point(&layoutns, 140, 110);
    cb->setBasePoint2(&p);
    p = Point(&layoutns, 165, 110);
    cb->setEnd(&p);

    // write model to file

    writeSBML(document, "layout_example3_L2.xml");
    delete document;

}
END_TEST


START_TEST ( test_RenderExtension_gradient )
{
    RenderPkgNamespaces renderns;
    LayoutPkgNamespaces layoutns;

    SBMLDocument doc(3,1);

    doc.enablePackage(layoutns.getURI(), "layout", true);
    doc.enablePackage(renderns.getURI(), "render", true);

    Model* model = doc.createModel();

    LayoutModelPlugin *lPlugin = (LayoutModelPlugin*)model->getPlugin("layout");
    fail_unless(lPlugin != NULL);

    Layout* layout = lPlugin->createLayout();
    Dimensions dim(&layoutns, 100,100 );
    layout->setDimensions(&dim);

    GraphicalObject* additional = layout->createAdditionalGraphicalObject();
    additional->setId("go1");
    BoundingBox bb(&layoutns, "bb1", 10, 10, 90, 90);
    additional->setBoundingBox(&bb);
    RenderGraphicalObjectPlugin* goPlugin = (RenderGraphicalObjectPlugin*)additional->getPlugin("render");
    fail_unless(goPlugin != NULL);
    goPlugin->setObjectRole("myRole");


    RenderLayoutPlugin *rPlugin = (RenderLayoutPlugin*)layout->getPlugin("render");
    fail_unless(rPlugin != NULL);

    LocalRenderInformation* local = rPlugin->createLocalRenderInformation();

    ColorDefinition *black = local->createColorDefinition();
    black->setId("black");
    black->setColorValue("#000000");

    ColorDefinition *grey = local->createColorDefinition();
    grey->setId("grey");
    grey->setColorValue("#F0F0F0");

    LinearGradient* gradient = local->createLinearGradientDefinition();
    gradient->setId("test");
    gradient->setPoint1(RelAbsVector(), RelAbsVector());
    gradient->setPoint2(RelAbsVector(0,100), RelAbsVector(0,100));

    GradientStop *stop = gradient->createGradientStop();
    stop->setOffset(RelAbsVector());
    stop->setStopColor("white");

    stop = gradient->createGradientStop();
    stop->setOffset(RelAbsVector(0, 100));
    stop->setStopColor("silver");

    std::string smodel = writeSBMLToStdString(&doc);

    fail_unless( stop->getStopColor() == "silver" );
}