COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CCellDesignerImporter Class Reference

#include <CCellDesignerImporter.h>

Collaboration diagram for CCellDesignerImporter:
Collaboration graph
[legend]

Public Member Functions

 CCellDesignerImporter (SBMLDocument *pDocument=0)
 
const Layout * getLayout () const
 
const SBMLDocument * getSBMLDocument () const
 
void setSBMLDocument (SBMLDocument *pDocument)
 

Static Public Member Functions

static double determineVersion (const XMLNode *pNode)
 
static const XMLNode * findCellDesignerAnnotation (SBMLDocument *pDocument, const XMLNode *pAnnotation)
 
static std::pair< bool,
std::string > 
findCellDesignerNamespace (const SBMLDocument *pDocument)
 

Protected Member Functions

void addDependency (const std::string &parent, const std::string &child)
 
void checkLinkAnchor (LinkTarget &link, const Point &p)
 
void checkLinkAnchors (LinkTarget &substrate, LinkTarget &product)
 
bool convertCellDesignerLayout (const XMLNode *pCellDesignerAnnotation)
 
bool convertCompartmentAnnotations ()
 
bool convertReactionAnnotation (Reaction *pReaction, const Model *pModel)
 
bool convertReactionAnnotations ()
 
bool convertSpeciesAnnotations ()
 
bool createCatalysisStyles ()
 
bool createCompartmentGlyph (const CompartmentAlias &ca)
 
bool createCompartmentGlyphs (const XMLNode *pLoCA)
 
bool createCompartmentStyle (const CompartmentAlias &ca, const CompartmentGlyph *pCGlyph)
 
bool createDefaultActivatorStyle ()
 
bool createDefaultInhibitorStyle ()
 
bool createDefaultModifierStyle ()
 
bool createDefaultProductStyle ()
 
bool createDefaultReactionGlyphStyle ()
 
bool createDefaultStyles ()
 
bool createDefaultSubstrateStyle ()
 
bool createPrimitive (RenderGroup *pGroup, const SpeciesIdentity &si, const BoundingBox &bounds, const Point &offset, double stroke_width, const std::string &stroke_color, const std::string &fill_color, const std::string &text="")
 
bool createProteinModification (RenderGroup *pGroup, const SpeciesModification &smod, const BoundingBox &bounds, const std::string &stroke_color)
 
bool createSpeciesGlyph (const SpeciesAlias &sa)
 
bool createSpeciesGlyphs (const XMLNode *pLoSA)
 
bool createSpeciesReferenceGlyphs (ReactionGlyph *pRGlyph, const std::vector< LinkTarget > &link, std::map< SpeciesReferenceGlyph *, Point > &startsMap, bool reactants)
 
bool createSpeciesStyles ()
 
bool createTextGlyphStyle (double size, Text::TEXT_ANCHOR hAlign, Text::TEXT_ANCHOR vAlign, const std::string &objectReference)
 
std::string createUniqueId (const std::string &prefix)
 
bool findOrCreateColorDefinition (const std::string &color_string, std::string &id)
 
std::string findRootElementId (const std::string &id) const
 
std::string getColorString (const std::string &color_id) const
 
bool handleExtraReactionElements (ReactionGlyph *pRGlyph, ReactionAnnotation &ranno, bool substrate)
 
bool handleIncludedSpecies (const XMLNode *pNode)
 
bool handleModificationLinks (ReactionGlyph *pRGlyph, ReactionAnnotation &ranno)
 
bool parseProteins (const XMLNode *pNode)
 
bool setSpeciesGlyphId (SpeciesReferenceGlyph *pGlyph, const LinkTarget &link)
 
bool setSpeciesReferenceId (SpeciesReferenceGlyph *pGlyph, const LinkTarget &link, const std::string &reactionId)
 

Static Protected Member Functions

static void addAllPositions (std::vector< POSITION > &v)
 
static double angle (const Point &v)
 
static Point calculateAbsoluteValue (const Point &p, const Point &p1, const Point &p2, const Point &p3)
 
static SPECIES_CLASS classToEnum (std::string cl)
 
static CONNECTION_POLICY connectionPolicyToEnum (std::string s)
 
template<typename ITERATOR >
static bool createLineSegments (Curve *pCurve, ITERATOR start, ITERATOR end)
 
static bool createOrthogonal (const Point &v1, Point &v2)
 
static DIRECTION_VALUE directionToEnum (std::string s)
 
static double distance (const Point &p1, const Point &p2)
 
static const XMLNode * findChildNode (const XMLNode *pNode, const std::string &prefix, const std::string &name, bool recursive=false)
 
static bool findShortestConnection (std::vector< POSITION > &pos1, std::vector< POSITION > &pos2, const BoundingBox &box1, const BoundingBox &box2)
 
static POSITION findShortestConnection (const Point &p, std::vector< POSITION > &pos, const BoundingBox &box)
 
static Point getPositionPoint (const BoundingBox &box, POSITION position)
 
static MODIFICATION_LINK_TYPE modificationLinkTypeToEnum (std::string s)
 
static MODIFICATION_TYPE modificationTypeToEnum (std::string s)
 
static PAINT_SCHEME paintSchemeToEnum (std::string s)
 
static bool parseBounds (const XMLNode *pNode, BoundingBox &box)
 
static bool parseBoxSize (const XMLNode *pNode, Dimensions &d)
 
static bool parseCompartmentAlias (const XMLNode *pNode, CompartmentAlias &ca, const Dimensions &layout_dimensions)
 
static bool parseCompartmentAnnotation (const XMLNode *pNode, CompartmentAnnotation &anno)
 
static bool parseConnectScheme (const XMLNode *pNode, ConnectScheme &scheme)
 
static bool parseDoubleLine (const XMLNode *pNode, DoubleLine &dl)
 
static bool parseEditPoints (const XMLNode *pNode, EditPoints &editpoints)
 
static bool parseExtraLink (const XMLNode *pNode, ReactantLink &l)
 
static bool parseExtraLinks (const XMLNode *pNode, std::vector< ReactantLink > &rlinks)
 
static bool parseLine (const XMLNode *pNode, Line &line)
 
static bool parseLineDirection (const XMLNode *pNode, LineDirection &d)
 
static bool parseLinkTarget (const XMLNode *pNode, LinkTarget &l)
 
static bool parseModelDisplay (const XMLNode *pNode, Dimensions &d)
 
static bool parsePaint (const XMLNode *pNode, Paint &p)
 
static bool parsePoint (const XMLNode *pNode, Point &p)
 
static bool parsePointsString (const std::string &s, std::vector< Point > &points)
 
static bool parseProteinModification (const XMLNode *pNode, ProteinModification &mod)
 
static bool parseReactionAnnotation (const XMLNode *pNode, ReactionAnnotation &ranno)
 
static bool parseReactionElements (const XMLNode *pNode, std::vector< LinkTarget > &elements)
 
static bool parseReactionModification (const XMLNode *pNode, ReactionModification &mod)
 
static bool parseReactionModifications (const XMLNode *pNode, std::vector< ReactionModification > &rmods)
 
static bool parseSpeciesAlias (const XMLNode *pNode, SpeciesAlias &sa)
 
static bool parseSpeciesAnnotation (const XMLNode *pNode, SpeciesAnnotation &anno)
 
static bool parseSpeciesIdentity (const XMLNode *pNode, SpeciesIdentity &identity)
 
static bool parseSpeciesModification (const XMLNode *pNode, SpeciesModification &mod)
 
static bool parseSpeciesState (const XMLNode *pNode, SpeciesState &state)
 
static bool parseUsualView (const XMLNode *pNode, UsualView &view)
 
static POSITION_TO_COMPARTMENT positionToCompartmentToEnum (std::string s)
 
static POSITION positionToEnum (std::string pos)
 
static REACTION_TYPE reactionTypeToEnum (std::string s)
 
static void rotate (const Point &p, double a, Point &r)
 
static SPECIES_MODIFICATION_TYPE speciesModificationTypeToEnum (std::string cl)
 
static bool splitString (const std::string &s, std::vector< std::string > &parts, const std::string &splitChars)
 

Protected Attributes

std::map< std::string,
BoundingBox > 
mCDBounds
 
std::map< std::string,
GraphicalObject * > 
mCDIdToLayoutElement
 
std::map< std::string,
std::string > 
mColorStringMap
 
std::map< const
CompartmentGlyph
*, CompartmentAlias
mCompartmentAliasMap
 
std::map< std::string,
CompartmentAnnotation
mCompartmentAnnotationMap
 
std::map< const
CompartmentGlyph *, Point > 
mCompartmentNamePointMap
 
std::list< CCopasiNode
< std::string > * > 
mComplexDependencies
 
std::map< std::string, const
SBase * > 
mIdMap
 
std::map< std::string,
std::pair< std::string,
SpeciesIdentity > > 
mIncludedSpeciesNameMap
 
std::multimap< std::string,
GraphicalObject * > 
mModelIdToLayoutElement
 
std::map
< MODIFICATION_LINK_TYPE,
LocalStyle * > 
mModificationLinkStyleMap
 
SBMLDocument * mpDocument
 
Layout * mpLayout
 
LocalRenderInformation * mpLocalRenderInfo
 
std::map< std::string, ProteinmProteinInformationMap
 
std::map< std::string,
SpeciesAlias
mSpeciesAliases
 
std::map< const SpeciesGlyph
*, SpeciesAlias
mSpeciesAliasMap
 
std::map< std::string,
SpeciesAnnotation
mSpeciesAnnotationMap
 

Detailed Description

This class converts CellDesigner layout information into SBML layout. Maybe later versions will also be able to handle the render information part.

Definition at line 510 of file CCellDesignerImporter.h.

Constructor & Destructor Documentation

CCellDesignerImporter::CCellDesignerImporter ( SBMLDocument *  pDocument = 0)

Constructor that takes a pointer to an SBMLDocument. The SBMLDocument will not be copied and it will not be owned by the importer. If the pointer is not NULL, the class will try to directly convert the CellDesigner layout if there is one.

Definition at line 85 of file CCellDesignerImporter.cpp.

References convertCellDesignerLayout(), findCellDesignerAnnotation(), and mpDocument.

85  :
86  mpDocument(pDocument),
87  mpLayout(NULL),
88  mpLocalRenderInfo(NULL)
89 {
90  setlocale(LC_ALL, "C");
91  if (this->mpDocument != NULL &&
92  this->mpDocument->getModel() != NULL &&
93  this->mpDocument->getModel()->getAnnotation() != NULL)
94  {
95  const XMLNode* pAnnotation = this->findCellDesignerAnnotation(this->mpDocument, this->mpDocument->getModel()->getAnnotation());
96 
97  if (pAnnotation != NULL)
98  {
99  this->convertCellDesignerLayout(pAnnotation);
100  }
101  }
102 }
static const XMLNode * findCellDesignerAnnotation(SBMLDocument *pDocument, const XMLNode *pAnnotation)
LocalRenderInformation * mpLocalRenderInfo
bool convertCellDesignerLayout(const XMLNode *pCellDesignerAnnotation)

Member Function Documentation

void CCellDesignerImporter::addAllPositions ( std::vector< POSITION > &  v)
staticprotected

Adds all possible POSITION enums to the given vector. The vector is cleared first.

Definition at line 9068 of file CCellDesignerImporter.cpp.

References POSITION_N, and POSITION_NNW.

Referenced by checkLinkAnchor(), checkLinkAnchors(), handleExtraReactionElements(), and handleModificationLinks().

9069 {
9070  // we make the assumption that POSITION_N
9071  // is the first valid element and that
9072  // POSITION_NNW the last
9073  POSITION pos = POSITION_N;
9074 
9075  while (pos <= POSITION_NNW)
9076  {
9077  v.push_back(pos);
9078  pos = (POSITION)((int)pos + 1);
9079  }
9080 }
void CCellDesignerImporter::addDependency ( const std::string &  parent,
const std::string &  child 
)
protected

Adds a new entry to the dependency tree for complex species aliases.

Definition at line 3594 of file CCellDesignerImporter.cpp.

References CCopasiNode< _Data >::addChild(), CCopasiNode< _Data >::getChild(), CCopasiNode< _Data >::getData(), CCopasiNode< _Data >::getNext(), CCopasiNode< _Data >::getSibling(), mComplexDependencies, and CCopasiNode< _Data >::setData().

Referenced by createSpeciesGlyph().

3595 {
3596  // check if the parent is already part of one of the trees
3597  CCopasiNode<std::string>* pChildNode = new CCopasiNode<std::string>(child);
3598  std::list<CCopasiNode<std::string>* >::iterator it = this->mComplexDependencies.begin(), endit = this->mComplexDependencies.end(), tree;
3599  CCopasiNode<std::string>* pCurrent;
3600 
3601  while (it != endit)
3602  {
3603  // iterate over the nodes in the tree
3604  // and try to find the parent
3605  pCurrent = *it;
3606 
3607  while (pCurrent != NULL)
3608  {
3609  if (pCurrent->getData() == parent)
3610  {
3611  pCurrent->addChild(pChildNode);
3612  break;
3613  }
3614 
3615  pCurrent = pCurrent->getNext();
3616  }
3617 
3618  if (pCurrent != NULL)
3619  {
3620  break;
3621  }
3622 
3623  ++it;
3624  }
3625 
3626  // if so add the child to that tree node
3627  // else create a new tree with parent as the root and child as the only child
3628  if (it == endit)
3629  {
3631  pRoot->setData(parent);
3632  pRoot->addChild(pChildNode);
3633  this->mComplexDependencies.push_back(pRoot);
3634  // update the iterator to the end
3635  endit = this->mComplexDependencies.end();
3636  }
3637 
3638  tree = this->mComplexDependencies.begin();
3639 
3640  // check if the child is already root to another tree, if so, we combine the two trees
3641  while (tree != endit)
3642  {
3643  // check if the root node is child
3644  if (tree != it && (*tree)->getData() == child)
3645  {
3646  // combine tree and it by adding all children from tree to it
3647  CCopasiNode<std::string>* pChild = (*tree)->getChild(), *pSibling = NULL;
3648 
3649  while (pChild != NULL)
3650  {
3651  // store the next node before we change the tree
3652  pSibling = pChild->getSibling();
3653  (*tree)->removeChild(pChild);
3654  pChildNode->addChild(pChild);
3655  pChild = pSibling;
3656  }
3657 
3658  // there can be only one I think, so we can stop here
3659  break;
3660  }
3661 
3662  ++tree;
3663  }
3664 }
CCopasiNode< Data > * getSibling()
Definition: CCopasiNode.h:353
std::list< CCopasiNode< std::string > * > mComplexDependencies
virtual bool setData(const Data &data)
Definition: CCopasiNode.h:128
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
Definition: CCopasiNode.h:156
CCopasiNode< Data > * getNext()
Definition: CCopasiNode.h:368
virtual const Data & getData() const
Definition: CCopasiNode.h:118
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
double CCellDesignerImporter::angle ( const Point &  v)
staticprotected

Calculates the angle between the given vector and the positive x axis. The result is returned in radians.

Definition at line 10324 of file CCellDesignerImporter.cpp.

Referenced by handleModificationLinks().

10325 {
10326  double result = std::numeric_limits<double>::quiet_NaN();
10327 
10328  if (!(v.x() == 0.0 && v.y() == 0.0))
10329  {
10330  result = acos(v.x() / sqrt(v.x() * v.x() + v.y() * v.y()));
10331 
10332  if (v.y() < 0.0)
10333  {
10334  result = 2.0 * M_PI - result;
10335  }
10336  else if (v.y() == 0.0 && v.x() < 0.0)
10337  {
10338  result = M_PI;
10339  }
10340  }
10341 
10342  return result;
10343 }
Point CCellDesignerImporter::calculateAbsoluteValue ( const Point &  p,
const Point &  p1,
const Point &  p2,
const Point &  p3 
)
staticprotected

Calculates the absolute position for point p based on the three other points (p1,p2,p3) given. The formula for that is: p1 + p.x * (p2 - p1) + p.y * (p3 - p1)

Definition at line 9270 of file CCellDesignerImporter.cpp.

Referenced by convertReactionAnnotation(), and handleModificationLinks().

9271 {
9272  Point v1(new LayoutPkgNamespaces(), p2.x() - p1.x(), p2.y() - p1.y());
9273  Point v2(new LayoutPkgNamespaces(), p3.x() - p1.x(), p3.y() - p1.y());
9274  Point result(new LayoutPkgNamespaces(), p1.x() + p.x()*v1.x() + p.y()*v2.x(), p1.y() + p.x()*v1.y() + p.y()*v2.y());
9275  return result;
9276 }
void CCellDesignerImporter::checkLinkAnchor ( LinkTarget link,
const Point &  p 
)
protected

Checks if the given ReactantLink object has a valid linkAnchor If not, we try to determine the best anchor be finding the one that is closest to the given point.

Definition at line 9283 of file CCellDesignerImporter.cpp.

References addAllPositions(), findShortestConnection(), LinkTarget::mAlias, mCDBounds, LinkTarget::mPosition, and POSITION_UNDEFINED.

Referenced by convertReactionAnnotation().

9284 {
9285  if (link.mPosition == POSITION_UNDEFINED)
9286  {
9287  // find the bounding box for the alias
9288  if (!link.mAlias.empty())
9289  {
9290  std::map<std::string, BoundingBox>::const_iterator pos = this->mCDBounds.find(link.mAlias);
9291  assert(pos != this->mCDBounds.end());
9292 
9293  if (pos != this->mCDBounds.end())
9294  {
9295  std::vector<POSITION> tmp;
9297  link.mPosition = CCellDesignerImporter::findShortestConnection(p, tmp, pos->second);
9298  }
9299  }
9300  }
9301 }
static void addAllPositions(std::vector< POSITION > &v)
std::string mAlias
std::map< std::string, BoundingBox > mCDBounds
static bool findShortestConnection(std::vector< POSITION > &pos1, std::vector< POSITION > &pos2, const BoundingBox &box1, const BoundingBox &box2)
void CCellDesignerImporter::checkLinkAnchors ( LinkTarget substrate,
LinkTarget product 
)
protected

Checks if the given ReactantLink objects have valid linkAnchors If not, we try to determine the best anchor be finding the ones that give the shortest connection between the two objects

Definition at line 9308 of file CCellDesignerImporter.cpp.

References addAllPositions(), findShortestConnection(), LinkTarget::mAlias, mCDBounds, LinkTarget::mPosition, and POSITION_UNDEFINED.

Referenced by convertReactionAnnotation().

9309 {
9310  if (substrate.mPosition == POSITION_UNDEFINED ||
9311  product.mPosition == POSITION_UNDEFINED)
9312  {
9313  // find the bounding box for the alias
9314  if (!substrate.mAlias.empty() && !product.mAlias.empty())
9315  {
9316  std::map<std::string, BoundingBox>::const_iterator pos1 = this->mCDBounds.find(substrate.mAlias);
9317  std::map<std::string, BoundingBox>::const_iterator pos2 = this->mCDBounds.find(product.mAlias);
9318  assert(pos1 != this->mCDBounds.end());
9319  assert(pos2 != this->mCDBounds.end());
9320 
9321  if (pos1 != this->mCDBounds.end() && pos2 != this->mCDBounds.end())
9322  {
9323  std::vector<POSITION> tmp1;
9324  std::vector<POSITION> tmp2;
9325 
9326  if (substrate.mPosition == POSITION_UNDEFINED)
9327  {
9329  }
9330  else
9331  {
9332  tmp1.push_back(substrate.mPosition);
9333  }
9334 
9335  if (product.mPosition == POSITION_UNDEFINED)
9336  {
9338  }
9339  else
9340  {
9341  tmp2.push_back(product.mPosition);
9342  }
9343 
9344  if (CCellDesignerImporter::findShortestConnection(tmp1, tmp2, pos1->second, pos2->second) == true)
9345  {
9346  assert(tmp1.size() == 1);
9347  assert(tmp2.size() == 1);
9348  substrate.mPosition = tmp1[0];
9349  product.mPosition = tmp2[0];
9350  }
9351  }
9352  }
9353  }
9354 }
static void addAllPositions(std::vector< POSITION > &v)
std::string mAlias
std::map< std::string, BoundingBox > mCDBounds
static bool findShortestConnection(std::vector< POSITION > &pos1, std::vector< POSITION > &pos2, const BoundingBox &box1, const BoundingBox &box2)
SPECIES_CLASS CCellDesignerImporter::classToEnum ( std::string  cl)
staticprotected

Converts the given class string to the correspnding SPECIES_CLASS enum value. If no enum is found, UNDEFINED is returned.

Definition at line 4805 of file CCellDesignerImporter.cpp.

References ANTISENSE_RNA_CLASS, CHANNEL_CLASS, COMPLEX_CLASS, DEGRADED_CLASS, DRUG_CLASS, GENE_CLASS, ION_CLASS, OVAL_CLASS, PHENOTYPE_CLASS, PROTEIN_CLASS, RECEPTOR_CLASS, RNA_CLASS, SIMPLE_MOLECULE_CLASS, SQUARE_CLASS, SQUARE_E_CLASS, SQUARE_N_CLASS, SQUARE_NE_CLASS, SQUARE_NW_CLASS, SQUARE_S_CLASS, SQUARE_SE_CLASS, SQUARE_SW_CLASS, SQUARE_W_CLASS, transform(), TRUNCATED_CLASS, UNDEFINED_CLASS, and UNKNOWN_CLASS.

Referenced by parseCompartmentAlias(), parseProteins(), and parseSpeciesIdentity().

4806 {
4807  std::transform(cl.begin(), cl.end(), cl.begin(), ::toupper);
4808  SPECIES_CLASS result = UNDEFINED_CLASS;
4809 
4810  if (cl == "ION")
4811  {
4812  result = ION_CLASS;
4813  }
4814  else if (cl == "SIMPLE_MOLECULE")
4815  {
4816  result = SIMPLE_MOLECULE_CLASS;
4817  }
4818  else if (cl == "PROTEIN")
4819  {
4820  result = PROTEIN_CLASS;
4821  }
4822  else if (cl == "GENE")
4823  {
4824  result = GENE_CLASS;
4825  }
4826  else if (cl == "RNA")
4827  {
4828  result = RNA_CLASS;
4829  }
4830  else if (cl == "ANTISENSE_RNA")
4831  {
4832  result = ANTISENSE_RNA_CLASS;
4833  }
4834  else if (cl == "PHENOTYPE")
4835  {
4836  result = PHENOTYPE_CLASS;
4837  }
4838  else if (cl == "DRUG")
4839  {
4840  result = DRUG_CLASS;
4841  }
4842  else if (cl == "UNKNOWN")
4843  {
4844  result = UNKNOWN_CLASS;
4845  }
4846  else if (cl == "COMPLEX")
4847  {
4848  result = COMPLEX_CLASS;
4849  }
4850  else if (cl == "SQUARE")
4851  {
4852  result = SQUARE_CLASS;
4853  }
4854  else if (cl == "OVAL")
4855  {
4856  result = OVAL_CLASS;
4857  }
4858  else if (cl == "SQUARE_CLOSEUP_NORTHWEST")
4859  {
4860  result = SQUARE_NW_CLASS;
4861  }
4862  else if (cl == "SQUARE_CLOSEUP_NORTHEAST")
4863  {
4864  result = SQUARE_NE_CLASS;
4865  }
4866  else if (cl == "SQUARE_CLOSEUP_SOUTHWEST")
4867  {
4868  result = SQUARE_SW_CLASS;
4869  }
4870  else if (cl == "SQUARE_CLOSEUP_SOUTHEAST")
4871  {
4872  result = SQUARE_SE_CLASS;
4873  }
4874  else if (cl == "SQUARE_CLOSEUP_NORTH")
4875  {
4876  result = SQUARE_N_CLASS;
4877  }
4878  else if (cl == "SQUARE_CLOSEUP_EAST")
4879  {
4880  result = SQUARE_E_CLASS;
4881  }
4882  else if (cl == "SQUARE_CLOSEUP_WEST")
4883  {
4884  result = SQUARE_W_CLASS;
4885  }
4886  else if (cl == "SQUARE_CLOSEUP_SOUTH")
4887  {
4888  result = SQUARE_S_CLASS;
4889  }
4890  else if (cl == "DEGRADED")
4891  {
4892  result = DEGRADED_CLASS;
4893  }
4894  else if (cl == "RECEPTOR")
4895  {
4896  result = RECEPTOR_CLASS;
4897  }
4898  else if (cl == "TRUNCATED")
4899  {
4900  result = TRUNCATED_CLASS;
4901  }
4902  else if (cl == "ION_CHANNEL")
4903  {
4904  result = CHANNEL_CLASS;
4905  }
4906 
4907  return result;
4908 }
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
CONNECTION_POLICY CCellDesignerImporter::connectionPolicyToEnum ( std::string  s)
staticprotected

Converts the given connection policy string to the corresponding enum. If there is no enum that corresponds to the string, POLICY_UNDEFINED is returned.

Definition at line 4662 of file CCellDesignerImporter.cpp.

References POLICY_DIRECT, POLICY_SQUARE, POLICY_UNDEFINED, and transform().

Referenced by parseConnectScheme().

4663 {
4664  std::transform(s.begin(), s.end(), s.begin(), ::toupper);
4666 
4667  if (s == "DIRECT")
4668  {
4669  result = POLICY_DIRECT;
4670  }
4671  else if (s == "SQUARE")
4672  {
4673  result = POLICY_SQUARE;
4674  }
4675 
4676  return result;
4677 }
void transform(QGraphicsItem *item, const CLTransformation2D *trans, const CLGroup *group)
bool CCellDesignerImporter::convertCellDesignerLayout ( const XMLNode *  pCellDesignerAnnotation)
protected

This method tries to convert the CellDesigner annotation to an SBML Layout. On success the method will return true and false otherwise.

Definition at line 331 of file CCellDesignerImporter.cpp.

References SBMLUtils::collectIds(), convertCompartmentAnnotations(), convertReactionAnnotations(), convertSpeciesAnnotations(), createCompartmentGlyphs(), createDefaultStyles(), createSpeciesGlyphs(), createSpeciesStyles(), createUniqueId(), determineVersion(), findChildNode(), handleIncludedSpecies(), mCDBounds, mCDIdToLayoutElement, mColorStringMap, mCompartmentAliasMap, mCompartmentAnnotationMap, mCompartmentNamePointMap, mComplexDependencies, mIdMap, mModelIdToLayoutElement, mpDocument, mpLayout, mpLocalRenderInfo, mProteinInformationMap, mSpeciesAliases, mSpeciesAliasMap, mSpeciesAnnotationMap, parseModelDisplay(), and parseProteins().

Referenced by CCellDesignerImporter(), and setSBMLDocument().

332 {
333  bool result = true;
334 
335  // before we start, we make sure that all data structures
336  // are cleared
337  this->mCompartmentAliasMap.clear();
338  this->mSpeciesAliasMap.clear();
339  this->mColorStringMap.clear();
340  this->mIdMap.clear();
341  this->mCDIdToLayoutElement.clear();
342  this->mCDBounds.clear();
343  this->mSpeciesAnnotationMap.clear();
344  this->mCompartmentAnnotationMap.clear();
345  this->mSpeciesAliases.clear();
346  // actually we need to delete all nodes in the list
347  std::list<CCopasiNode<std::string>*>::iterator nit = this->mComplexDependencies.begin(), nendit = this->mComplexDependencies.end();
348 
349  while (nit != nendit)
350  {
351  delete *nit;
352  ++nit;
353  }
354 
355  this->mComplexDependencies.clear();
356  this->mModelIdToLayoutElement.clear();
357  this->mCompartmentNamePointMap.clear();
358  this->mProteinInformationMap.clear();
359  //this->mGeneNameMap.clear();
360  //this->mRNANameMap.clear();
361  //this->mASRNANameMap.clear();
362 
363  // check if we are in the top level cell designer element
364  if (pCellDesignerAnnotation != NULL &&
365  pCellDesignerAnnotation->getName() == "extension" &&
366  this->mpDocument != NULL &&
367  this->mpDocument->getModel() != NULL)
368  {
369  // we don't need the meta ids
370  std::map<std::string, const SBase*> metaids;
371  // delete all existing ids
372  SBMLUtils::collectIds(this->mpDocument->getModel(), this->mIdMap, metaids);
373 
374  LayoutModelPlugin* lmPlugin = (LayoutModelPlugin*)this->mpDocument->getModel()->getPlugin("layout");
375  assert(lmPlugin != NULL);
376  // create the layout
377  this->mpLayout = lmPlugin->createLayout();
378 
379  if (this->mpLayout != NULL)
380  {
381  // we need to find a unique id for the layout
382  std::string id = this->createUniqueId("Layout");
383  this->mpLayout->setId(id);
384  this->mpLayout->setName(id);
385  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, this->mpLayout));
386 
387  // create the LocalRenderInformation
388  RenderLayoutPlugin* rlPlugin = (RenderLayoutPlugin*) this->mpLayout->getPlugin("render");
389  this->mpLocalRenderInfo = rlPlugin->createLocalRenderInformation();
390 
391  if (this->mpLocalRenderInfo != NULL)
392  {
393  // set the id of the render information
394  // set a name
395  // set a program name
396  // set the background color to white
397  this->mpLocalRenderInfo->setBackgroundColor("#FFFFFFFF");
398  this->mpLocalRenderInfo->setName("render info from celldesigner");
399  this->mpLocalRenderInfo->setProgramName("CellDesignerImporter");
400  this->mpLocalRenderInfo->setProgramVersion("0.0.1");
401  std::string render_id = this->createUniqueId("RenderInformation");
402  this->mpLocalRenderInfo->setId(id);
403  this->mIdMap.insert(std::pair<std::string, const SBase*>(render_id, this->mpLocalRenderInfo));
404  // since we use black for the edge of all objects, we create a color definition for that
405  std::string color_id = this->createUniqueId("black");
406  ColorDefinition* pBlack = this->mpLocalRenderInfo->createColorDefinition();
407 
408  if (pBlack != NULL)
409  {
410  pBlack->setId(color_id);
411  this->mIdMap.insert(std::pair<std::string, const SBase*>(color_id, pBlack));
412  pBlack->setRGBA(0, 0, 0, 255);
413  this->mColorStringMap.insert(std::pair<std::string, std::string>("#000000FF", color_id));
414  }
415  else
416  {
417  result = false;
418  }
419 
420  if (result == true)
421  {
422  // ReactionGlyphs and SpeciesReferenceGlyphs
423  result = this->createDefaultStyles();
424  }
425  }
426 
427  const XMLNode* pChild = NULL;
428 
429  double version = CCellDesignerImporter::determineVersion(pCellDesignerAnnotation);
430 
431  if (version < 4.0)
432  {
433  result = false;
434  }
435 
436  if (result == true)
437  {
438  // handle the modelDisplay element
439  pChild = CCellDesignerImporter::findChildNode(pCellDesignerAnnotation, pCellDesignerAnnotation->getPrefix(), "modelDisplay", false);
440  result = (pChild != NULL && CCellDesignerImporter::parseModelDisplay(pChild, *this->mpLayout->getDimensions()));
441  }
442 
443  if (result == true)
444  {
445  pChild = CCellDesignerImporter::findChildNode(pCellDesignerAnnotation, pCellDesignerAnnotation->getPrefix(), "listOfIncludedSpecies", false);
446 
447  if (pChild != NULL)
448  {
449  result = this->handleIncludedSpecies(pChild);
450  }
451  }
452 
453  if (result == true)
454  {
455  pChild = CCellDesignerImporter::findChildNode(pCellDesignerAnnotation, pCellDesignerAnnotation->getPrefix(), "listOfCompartmentAliases", false);
456 
457  if (pChild != NULL)
458  {
459  result = this->createCompartmentGlyphs(pChild);
460  }
461  }
462 
463  if (result == true)
464  {
465  pChild = CCellDesignerImporter::findChildNode(pCellDesignerAnnotation, pCellDesignerAnnotation->getPrefix(), "listOfSpeciesAliases", false);
466 
467  if (pChild != NULL)
468  {
469  result = this->createSpeciesGlyphs(pChild);
470  }
471  }
472 
473  if (result == true)
474  {
475  pChild = CCellDesignerImporter::findChildNode(pCellDesignerAnnotation, pCellDesignerAnnotation->getPrefix(), "listOfComplexSpeciesAliases", false);
476 
477  if (pChild != NULL)
478  {
479  result = this->createSpeciesGlyphs(pChild);
480  }
481  }
482 
483  /*
484  if(result == true)
485  {
486  pChild=CCellDesignerImporter::findChildNode(pCellDesignerAnnotation,pCellDesignerAnnotation->getPrefix(),"listOfGenes",false);
487  result = (pChild!=NULL && this->parseGeneNames(pChild));
488  }
489  if(result == true)
490  {
491  pChild=CCellDesignerImporter::findChildNode(pCellDesignerAnnotation,pCellDesignerAnnotation->getPrefix(),"listOfRNAs",false);
492  result = (pChild!=NULL && this->parseRNANames(pChild));
493  }
494  if(result == true)
495  {
496  pChild=CCellDesignerImporter::findChildNode(pCellDesignerAnnotation,pCellDesignerAnnotation->getPrefix(),"listOfAntisenseRNAs",false);
497  result = (pChild!=NULL && this->parseASRNANames(pChild));
498  }
499  */
500 
501  // go through the models reactions and find the cell designer annotations there
502  // so that we can create the edges of the graph
503  if (result)
504  {
505  result = this->convertReactionAnnotations();
506  }
507 
508  // go through the compartment annotations and create the text glyph for the names
509  if (result)
510  {
511  result = this->convertCompartmentAnnotations();
512  }
513 
514  // go through the species annotations and create the text glyph for the names
515  if (result)
516  {
517  result = this->convertSpeciesAnnotations();
518  }
519 
520  // now we need to find the correct way of drawing protein nodes
521  // for this we need the type on the protein elements
522  // this information is used when we create the styles for the species glyphs
523  // TODO the code below will only work if we know the mapping from protein reference id
524  // TODO to the corresponding species or CellDesigner species id
525  // TODO this information is stored in a proteinReference element of either the annotation
526  // TODO of the species or directly with the CellDesignerSpecies
527  if (result == true)
528  {
529  pChild = CCellDesignerImporter::findChildNode(pCellDesignerAnnotation, pCellDesignerAnnotation->getPrefix(), "listOfProteins", false);
530  result = (pChild != NULL && this->parseProteins(pChild));
531 
532  // // now we go through the protein map and set the correct type
533  // // on the SpeciesAlias for the corresponding species
534  // std::map<std::string,Protein>::const_iterator it=this->mProteinInformationMap.begin(),endit=this->mProteinInformationMap.end();
535  // std::map<std::string,SpeciesAnnotation>::iterator annoIt;
536  // std::cout << "num protein types:" << this->mProteinInformationMap.size() << std::endl;
537  // while(it != endit)
538  // {
539  // std::cout << "looking for annotation to " << it->first << std::endl;
540  // annoIt=this->mSpeciesAnnotationMap.find(it->first);
541  // if(annoIt != this->mSpeciesAnnotationMap.end())
542  // {
543  // annoIt->second.mIdentity.mSpeciesClass=it->second;
544  //}
545  // else
546  // {
547  // result=false;
548  //}
549  // ++it;
550  //}
551  }
552 
553  // go through all species glyphs and create a style for each one
554  if (result)
555  {
556  result = this->createSpeciesStyles();
557  }
558  }
559 
560  // clean up
561  if (!result && this->mpLayout != NULL)
562  {
563  if (this->mpDocument && this->mpDocument->getModel())
564  {
565  LayoutModelPlugin* lmPlugin = (LayoutModelPlugin*)this->mpDocument->getModel()->getPlugin("layout");
566 
567  if (lmPlugin != NULL)
568  {
569  unsigned int i, iMax = lmPlugin->getListOfLayouts()->size();
570 
571  for (i = 0; i < iMax; ++i)
572  {
573  if (lmPlugin->getLayout(i) == this->mpLayout)
574  {
575  lmPlugin->removeLayout(i);
576  break;
577  }
578  }
579  }
580  }
581 
582  delete this->mpLayout;
583  this->mpLayout = NULL;
584  }
585  }
586  else
587  {
588  result = false;
589  }
590 
591  return result;
592 }
std::string createUniqueId(const std::string &prefix)
static bool parseModelDisplay(const XMLNode *pNode, Dimensions &d)
std::list< CCopasiNode< std::string > * > mComplexDependencies
std::map< const CompartmentGlyph *, Point > mCompartmentNamePointMap
std::map< std::string, CompartmentAnnotation > mCompartmentAnnotationMap
bool createSpeciesGlyphs(const XMLNode *pLoSA)
std::map< std::string, GraphicalObject * > mCDIdToLayoutElement
static void collectIds(Model *pModel, std::map< std::string, const SBase * > &ids, std::map< std::string, const SBase * > &metaIds)
Definition: SBMLUtils.cpp:96
bool createCompartmentGlyphs(const XMLNode *pLoCA)
LocalRenderInformation * mpLocalRenderInfo
std::map< const SpeciesGlyph *, SpeciesAlias > mSpeciesAliasMap
std::map< std::string, SpeciesAnnotation > mSpeciesAnnotationMap
bool parseProteins(const XMLNode *pNode)
bool handleIncludedSpecies(const XMLNode *pNode)
std::map< std::string, BoundingBox > mCDBounds
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
std::map< const CompartmentGlyph *, CompartmentAlias > mCompartmentAliasMap
std::map< std::string, SpeciesAlias > mSpeciesAliases
static double determineVersion(const XMLNode *pNode)
static const XMLNode * findChildNode(const XMLNode *pNode, const std::string &prefix, const std::string &name, bool recursive=false)
std::map< std::string, Protein > mProteinInformationMap
std::multimap< std::string, GraphicalObject * > mModelIdToLayoutElement
bool CCellDesignerImporter::convertCompartmentAnnotations ( )
protected

Traverses the compartments of the model and looks for CellDesigner annotations. These are used to create text glyphs associated with compartments.

Definition at line 3374 of file CCellDesignerImporter.cpp.

References createTextGlyphStyle(), createUniqueId(), findCellDesignerAnnotation(), mCompartmentAliasMap, mCompartmentAnnotationMap, mCompartmentNamePointMap, mIdMap, mModelIdToLayoutElement, CompartmentAnnotation::mName, mpDocument, mpLayout, and parseCompartmentAnnotation().

Referenced by convertCellDesignerLayout().

3375 {
3376  bool result = true;
3377 
3378  if (this->mpDocument && this->mpDocument->getModel() && this->mpLayout)
3379  {
3380  Model* pModel = this->mpDocument->getModel();
3381  unsigned int i, iMax = pModel->getNumCompartments();
3382  Compartment* pCompartment = NULL;
3383  const XMLNode* pAnnotation = NULL;
3384 
3385  for (i = 0; i < iMax && result == true; ++i)
3386  {
3387  pCompartment = pModel->getCompartment(i);
3388 
3389  if (pCompartment->getAnnotation() != NULL)
3390  {
3391  pAnnotation = CCellDesignerImporter::findCellDesignerAnnotation(this->mpDocument, pCompartment->getAnnotation());
3392 
3393  // there should be a name element in there somewhere
3394  if (pAnnotation != NULL)
3395  {
3396  CompartmentAnnotation canno;
3397  result = CCellDesignerImporter::parseCompartmentAnnotation(pAnnotation, canno);
3398 
3399  if (result)
3400  {
3401  this->mCompartmentAnnotationMap.insert(std::pair<std::string, CompartmentAnnotation>(pCompartment->getId(), canno));
3402  // create the text glyph if there is a CompartmentGlyph
3403  std::multimap<std::string, GraphicalObject*>::const_iterator pos = this->mModelIdToLayoutElement.find(pCompartment->getId());
3404 
3405  if (pos != this->mModelIdToLayoutElement.end() && pos->second != NULL)
3406  {
3407  do
3408  {
3409  TextGlyph* pTGlyph = this->mpLayout->createTextGlyph();
3410  std::string id = this->createUniqueId("TextGlyph");
3411  pTGlyph->setId(id);
3412  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pTGlyph));
3413  // set the text and the associated layout element
3414  pTGlyph->setText(canno.mName);
3415  pTGlyph->setGraphicalObjectId(pos->second->getId());
3416  // set the position of the text relative to the layout element
3417  // from the mCompartmentNamePointMap
3418  const CompartmentGlyph* pCGlyph = dynamic_cast<const CompartmentGlyph*>(pos->second);
3419  assert(pCGlyph != NULL);
3420  std::map<const CompartmentGlyph*, Point>::const_iterator pos2 = this->mCompartmentNamePointMap.find(pCGlyph);
3421  Point p(new LayoutPkgNamespaces(), 0.0, 0.0);
3422 
3423  if (pos2 != this->mCompartmentNamePointMap.end())
3424  {
3425  p = pos2->second;
3426  }
3427 
3428  // set the position and dimensions of the text
3429  Point position = *pCGlyph->getBoundingBox()->getPosition();
3430  // add the name position to the position of the compartment
3431  position.setX(position.x() + p.x());
3432  position.setY(position.y() + p.y());
3433  Dimensions dim = *pCGlyph->getBoundingBox()->getDimensions();
3434  // subtract the name position from the dimensions of the compartment
3435  dim.setWidth(dim.getWidth() - p.x());
3436  dim.setHeight(dim.getHeight() - p.y());
3437  BoundingBox bb;
3438  bb.setPosition(&position);
3439  bb.setDimensions(&dim);
3440  pTGlyph->setBoundingBox(&bb);
3441  // create an appropriate style
3442  // first we need the style information for the CompartmentGlyph
3443  std::map<const CompartmentGlyph*, CompartmentAlias>::const_iterator compAliasPos = this->mCompartmentAliasMap.find(pCGlyph);
3444  assert(compAliasPos != this->mCompartmentAliasMap.end());
3445 
3446  if (compAliasPos != this->mCompartmentAliasMap.end())
3447  {
3448  this->createTextGlyphStyle(compAliasPos->second.mFontSize, Text::ANCHOR_START, Text::ANCHOR_BOTTOM, pTGlyph->getId());
3449  }
3450 
3451  ++pos;
3452  }
3453  while (pos != this->mModelIdToLayoutElement.end() && pos->first == pCompartment->getId());
3454  }
3455  else
3456  {
3457  // TODO this is OK as long as we only import compartments with bounds
3458  //result=false;
3459  }
3460  }
3461  else
3462  {
3463  result = false;
3464  }
3465  }
3466  }
3467  }
3468  }
3469  else
3470  {
3471  result = false;
3472  }
3473 
3474  return result;
3475 }
std::string createUniqueId(const std::string &prefix)
static const XMLNode * findCellDesignerAnnotation(SBMLDocument *pDocument, const XMLNode *pAnnotation)
std::map< const CompartmentGlyph *, Point > mCompartmentNamePointMap
std::map< std::string, CompartmentAnnotation > mCompartmentAnnotationMap
bool createTextGlyphStyle(double size, Text::TEXT_ANCHOR hAlign, Text::TEXT_ANCHOR vAlign, const std::string &objectReference)
std::map< std::string, const SBase * > mIdMap
std::map< const CompartmentGlyph *, CompartmentAlias > mCompartmentAliasMap
static bool parseCompartmentAnnotation(const XMLNode *pNode, CompartmentAnnotation &anno)
std::multimap< std::string, GraphicalObject * > mModelIdToLayoutElement
bool CCellDesignerImporter::convertReactionAnnotation ( Reaction *  pReaction,
const Model *  pModel 
)
protected

Looks for CellDesigner annotation in the given reaction and ries to convert the information in that annotation into a ReactionGlyph.

Definition at line 2246 of file CCellDesignerImporter.cpp.

References calculateAbsoluteValue(), CATALYSIS_RTYPE, checkLinkAnchor(), checkLinkAnchors(), createLineSegments(), createOrthogonal(), createUniqueId(), DISSOCIATION_RTYPE, distance(), findCellDesignerAnnotation(), getPositionPoint(), handleExtraReactionElements(), handleModificationLinks(), HETERODIMER_ASSOCIATION_RTYPE, INHIBITION_RTYPE, KNOWN_TRANSITION_OMITTED_RTYPE, ReactionAnnotation::mBaseProducts, ReactionAnnotation::mBaseReactants, mCDBounds, ReactionAnnotation::mConnectScheme, ReactionAnnotation::mEditPoints, mIdMap, EditPoints::mOmittedShapeIndex, mpDocument, mpLayout, EditPoints::mPoints, ConnectScheme::mRectangleIndex, EditPoints::mTShapeIndex, ReactionAnnotation::mType, parseReactionAnnotation(), POSITION_UNDEFINED, setSpeciesGlyphId(), setSpeciesReferenceId(), STATE_TRANSITION_RTYPE, TRANSCRIPTION_RTYPE, TRANSCRIPTIONAL_ACTIVATION_RTYPE, TRANSCRIPTIONAL_INHIBITION_RTYPE, TRANSLATION_RTYPE, TRANSLATIONAL_ACTIVATION_RTYPE, TRANSLATIONAL_INHIBITION_RTYPE, TRANSPORT_RTYPE, TRUNCATION_RTYPE, UNKNOWN_CATALYSIS_RTYPE, UNKNOWN_INHIBITION_RTYPE, and UNKNOWN_TRANSITION_RTYPE.

Referenced by convertReactionAnnotations().

2247 {
2248  bool result = true;
2249 
2250  if (pReaction != NULL && pModel != NULL && pReaction->getAnnotation() != NULL)
2251  {
2252  const XMLNode* pAnnotation = this->findCellDesignerAnnotation(this->mpDocument, pReaction->getAnnotation());
2253 
2254  if (pAnnotation != NULL && pAnnotation->getName() == "extension" && this->mpLayout != NULL)
2255  {
2256  // create a reaction glyph
2257  ReactionAnnotation ranno;
2258  result = this->parseReactionAnnotation(pAnnotation, ranno);
2259 
2260  if (result == true)
2261  {
2262  ReactionGlyph* pRGlyph = this->mpLayout->createReactionGlyph();
2263 
2264  if (pRGlyph != NULL)
2265  {
2266  std::string id = this->createUniqueId("ReactionGlyph");
2267  pRGlyph->setId(id);
2268  pRGlyph->setReactionId(pReaction->getId());
2269  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pRGlyph));
2270  // the reactionType element has a text element
2271  // that defines the type of reaction
2272 
2273  // the following reaction types have one reactant and one product
2274  // STATE_TRANSITION, KNOWN_TRANSITION_OMITTED, UNKNOWN_TRANSITION,
2275  // TRANSCRIPTION, TRANSLATION, TRANSPORT
2276  // I also have an example where an INHIBITION reaction has one substrate
2277  // and one product, so maybe we add some more like CATALYSIS, UNKNOWN_INHIBITION
2278  // UNKNOWN_CATALYSIS, TRANSCRITPTIONAL_INHIBITION, TRANSLATIONAL_INHIBITION,
2279  // TRANSLATIONAL_ACTIVATION, TRANSCRIPTIONAL_ACTIVATION
2280  // the following reactions have two reactants and one product
2281  // HETERODIMNER_ASSOCIATION
2282  // the following reactions have one substrate and two products:
2283  // DISSOCIATION, TRUNCATION
2284  switch (ranno.mType)
2285  {
2289  case TRANSCRIPTION_RTYPE:
2290  case TRANSLATION_RTYPE:
2291  case TRANSPORT_RTYPE:
2292  case CATALYSIS_RTYPE:
2294  case INHIBITION_RTYPE:
2300  {
2301  assert(ranno.mBaseReactants.size() == 1);
2302  assert(ranno.mBaseProducts.size() == 1);
2303  // check if both elements have a link anchor
2304  this->checkLinkAnchors(ranno.mBaseReactants[0], ranno.mBaseProducts[0]);
2305 
2306  if (ranno.mBaseReactants[0].mPosition != POSITION_UNDEFINED &&
2307  ranno.mBaseProducts[0].mPosition != POSITION_UNDEFINED &&
2308  !ranno.mBaseReactants[0].mAlias.empty() &&
2309  !ranno.mBaseProducts[0].mAlias.empty()
2310  )
2311  {
2312  // we should have a start and an end point now
2313  // and the reaction box lies in the middle between these two points
2314  std::map<std::string, BoundingBox>::const_iterator box_pos1 = this->mCDBounds.find(ranno.mBaseReactants[0].mAlias);
2315  std::map<std::string, BoundingBox>::const_iterator box_pos2 = this->mCDBounds.find(ranno.mBaseProducts[0].mAlias);
2316  assert(box_pos1 != this->mCDBounds.end());
2317  assert(box_pos2 != this->mCDBounds.end());
2318 
2319  if (box_pos1 != this->mCDBounds.end() && box_pos2 != this->mCDBounds.end())
2320  {
2321  // calculate the absolute values of all points
2322  // and put them in a vector
2323  // then we go through the vector and create
2324  // the line segments
2325  // add all edit points
2326  //
2327  // p1 stores the coordinates of the anchor point at the reactant
2328  Point p1 = CCellDesignerImporter::getPositionPoint(box_pos1->second, ranno.mBaseReactants[0].mPosition);
2329  // p2 stores the coordinates of the anchor point at the product
2330  Point p2 = CCellDesignerImporter::getPositionPoint(box_pos2->second, ranno.mBaseProducts[0].mPosition);
2331  Point v1(new LayoutPkgNamespaces(), p2.x() - p1.x(), p2.y() - p1.y());
2332  Point v2(new LayoutPkgNamespaces());
2333  result = CCellDesignerImporter::createOrthogonal(v1, v2);
2334 
2335  Point p3(new LayoutPkgNamespaces(), p1.x() + v2.x(), p1.y() + v2.y());
2336  std::vector<Point>::const_iterator pointIt = ranno.mEditPoints.mPoints.begin(), pointsEnd = ranno.mEditPoints.mPoints.end();
2337  Point p(new LayoutPkgNamespaces());
2338  std::vector<Point> points;
2339  // we add p1 and p2 to the points vector
2340  // then the values would be save and we could use the entries from the vector below
2341  // which would be save even if p1 and p2 got new values
2342  points.push_back(p1);
2343 
2344  while (pointIt != pointsEnd)
2345  {
2346  // create the absolute point
2347  p = CCellDesignerImporter::calculateAbsoluteValue(*pointIt, p1, p2, p3);
2348  points.push_back(p);
2349  ++pointIt;
2350  }
2351 
2352  points.push_back(p2);
2353 
2354  std::vector<Point> reactantPoints;
2355  pointIt = points.begin(), pointsEnd = points.end();
2356  reactantPoints.push_back(*pointIt);
2357  ++pointIt;
2358  std::vector<Point> productPoints;
2359  int index = 0;
2360  int rectangleIndex = ranno.mConnectScheme.mRectangleIndex;
2361 
2362  // rectangle index marks the segment that contains the "process symbol", i.e. the reaction glyph
2363  while (index < rectangleIndex)
2364  {
2365  reactantPoints.push_back(*pointIt);
2366  ++index;
2367  ++pointIt;
2368  }
2369 
2370  assert(pointIt != pointsEnd);
2371 
2372  if (pointIt != pointsEnd)
2373  {
2374  p2 = *pointIt;
2375  }
2376 
2377  // p2 now points to the end of the section that contains the reaction glyph
2378  // now we assing p3 to be the start of the segment that contains the reaction glyph
2379  // which is the last point we added to the reactants
2380  p3 = reactantPoints.back();
2381 
2382  double distance = CCellDesignerImporter::distance(p3, p2);
2383  Point v(new LayoutPkgNamespaces(), (p2.x() - p3.x()) / distance, (p2.y() - p3.y()) / distance);
2384  // create the curve for the reaction glyph
2385  // right now, the reaction glyph consists of a short
2386  // line segment
2387  // the curve should not be longer than 1/3 the distance
2388  distance /= 6.0;
2389 
2390  if (distance >= 7.5)
2391  {
2392  distance = 7.5;
2393  }
2394 
2395  Curve* pCurve = pRGlyph->getCurve();
2396  assert(pCurve != NULL);
2397  LineSegment* pLS = pCurve->createLineSegment();
2398  Point center(new LayoutPkgNamespaces(), (p3.x() + p2.x()) * 0.5, (p3.y() + p2.y()) * 0.5);
2399  pLS->setStart(center.x() - distance * v.x(), center.y() - distance * v.y());
2400  pLS->setEnd(center.x() + distance * v.x(), center.y() + distance * v.y());
2401  // add a new substrate point
2402  // the substrate points are in reverse order
2403  reactantPoints.push_back(*pLS->getStart());
2404  // add a new product point
2405  productPoints.push_back(*pLS->getEnd());
2406 
2407  if (pointIt == pointsEnd)
2408  {
2409  productPoints.push_back(p2);
2410  }
2411 
2412  while (pointIt != pointsEnd)
2413  {
2414  productPoints.push_back(*pointIt);
2415  ++pointIt;
2416  }
2417 
2418  // create the speciesReferenceGlyphs
2419  SpeciesReferenceGlyph* pSRefGlyph1 = pRGlyph->createSpeciesReferenceGlyph();
2420  SpeciesReferenceGlyph* pSRefGlyph2 = pRGlyph->createSpeciesReferenceGlyph();
2421  assert(pSRefGlyph1 != NULL);
2422  assert(pSRefGlyph2 != NULL);
2423 
2424  if (pSRefGlyph1 != NULL && pSRefGlyph2 != NULL)
2425  {
2426  // set the ids
2427  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2428  pSRefGlyph1->setId(id);
2429  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph1));
2430  id = this->createUniqueId("SpeciesReferenceGlyph");
2431  pSRefGlyph2->setId(id);
2432  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph2));
2433  // set the role
2434  pSRefGlyph1->setRole(SPECIES_ROLE_SUBSTRATE);
2435  pSRefGlyph2->setRole(SPECIES_ROLE_PRODUCT);
2436  // set the curve
2437  pCurve = pSRefGlyph1->getCurve();
2438  assert(pCurve != NULL);
2439 
2440  if (pCurve != NULL && result == true)
2441  {
2442  assert(reactantPoints.size() > 1);
2443  result = CCellDesignerImporter::createLineSegments(pCurve, reactantPoints.rbegin(), reactantPoints.rend());
2444  }
2445  else
2446  {
2447  result = false;
2448  }
2449 
2450  pCurve = pSRefGlyph2->getCurve();
2451  assert(pCurve != NULL);
2452 
2453  if (pCurve != NULL && result == true)
2454  {
2455  assert(productPoints.size() > 1);
2456  result = CCellDesignerImporter::createLineSegments(pCurve, productPoints.begin(), productPoints.end());
2457  }
2458 
2459  // make sure the role is set because setSpeciesReferenceId relies on it
2460  this->setSpeciesGlyphId(pSRefGlyph1, ranno.mBaseReactants[0]);
2461  this->setSpeciesReferenceId(pSRefGlyph1, ranno.mBaseReactants[0], pRGlyph->getReactionId());
2462  this->setSpeciesGlyphId(pSRefGlyph2, ranno.mBaseProducts[0]);
2463  this->setSpeciesReferenceId(pSRefGlyph2, ranno.mBaseProducts[0], pRGlyph->getReactionId());
2464  }
2465  else
2466  {
2467  result = false;
2468  }
2469  }
2470  else
2471  {
2472  result = false;
2473  }
2474  }
2475  else
2476  {
2477  result = false;
2478  }
2479  }
2480  break;
2481 
2482  case DISSOCIATION_RTYPE:
2483  case TRUNCATION_RTYPE:
2484  {
2485  assert(ranno.mBaseReactants.size() == 1);
2486  assert(ranno.mBaseProducts.size() == 2);
2487  // there must be some edit points
2488  assert(!ranno.mEditPoints.mPoints.empty());
2489  // there should be a tShapeIndex or an omittedShapeIndex element
2490  // that tells us, which of the points is the connection point
2491  // center_product1 - center_substrate_1)
2492  // if no tShapeIndex or omittedSHapeIndex is given, we assume it is 0
2493  Point connectionPoint(new LayoutPkgNamespaces());
2494 
2495  if (ranno.mEditPoints.mTShapeIndex < (int)ranno.mEditPoints.mPoints.size())
2496  {
2497  connectionPoint = ranno.mEditPoints.mPoints[ranno.mEditPoints.mTShapeIndex];
2498  }
2499  else if (ranno.mEditPoints.mOmittedShapeIndex < (int)ranno.mEditPoints.mPoints.size())
2500  {
2501  connectionPoint = ranno.mEditPoints.mPoints[ranno.mEditPoints.mOmittedShapeIndex];
2502  }
2503  else
2504  {
2505  connectionPoint = ranno.mEditPoints.mPoints[0];
2506  }
2507 
2508  // calculate the absolute position
2509  // the position for the relative points coordinates is calculated as
2510  // center_substrate1 + x*(center_substrate_2 - center_substrate_1)+y*(
2511  std::string alias1 = ranno.mBaseReactants[0].mAlias;
2512  assert(!alias1.empty());
2513  std::string alias2 = ranno.mBaseProducts[0].mAlias;
2514  assert(!alias2.empty());
2515  std::string alias3 = ranno.mBaseProducts[1].mAlias;
2516  assert(!alias3.empty());
2517  std::map<std::string, BoundingBox>::const_iterator pos1, pos2, pos3;
2518  pos1 = this->mCDBounds.find(alias1);
2519  assert(pos1 != this->mCDBounds.end());
2520  pos2 = this->mCDBounds.find(alias2);
2521  assert(pos2 != this->mCDBounds.end());
2522  pos3 = this->mCDBounds.find(alias3);
2523  assert(pos3 != this->mCDBounds.end());
2524 
2525  if (!alias1.empty() &&
2526  !alias3.empty() &&
2527  !alias3.empty() &&
2528  pos1 != this->mCDBounds.end() &&
2529  pos2 != this->mCDBounds.end() &&
2530  pos3 != this->mCDBounds.end())
2531  {
2532  Point p1(new LayoutPkgNamespaces(), pos1->second.getPosition()->x() + pos1->second.getDimensions()->getWidth() * 0.5, pos1->second.getPosition()->y() + pos1->second.getDimensions()->getHeight() * 0.5);
2533  Point p2(new LayoutPkgNamespaces(), pos2->second.getPosition()->x() + pos2->second.getDimensions()->getWidth() * 0.5, pos2->second.getPosition()->y() + pos2->second.getDimensions()->getHeight() * 0.5);
2534  Point p3(new LayoutPkgNamespaces(), pos3->second.getPosition()->x() + pos3->second.getDimensions()->getWidth() * 0.5, pos3->second.getPosition()->y() + pos3->second.getDimensions()->getHeight() * 0.5);
2535  Point v1(new LayoutPkgNamespaces(), p2.x() - p1.x(), p2.y() - p1.y());
2536  Point v2(new LayoutPkgNamespaces(), p3.x() - p1.x(), p3.y() - p1.y());
2537  Point p(new LayoutPkgNamespaces(), p1.x() + connectionPoint.x()*v1.x() + connectionPoint.y()*v2.x(), p1.y() + connectionPoint.x()*v1.y() + connectionPoint.y()*v2.y());
2538  // p is the start point of the reaction glyph
2539  // i.e. the point where the substrates connect
2540  // create the curve for the reaction glyph
2541  // the end point is a short distance further along the
2542  // path the the only product
2543 
2544  // first we have to check if we have linkAnchors for all
2545  // elements
2546  // if not, we create them based on the shortest distance to the
2547  // connection point
2548 
2552  assert(ranno.mBaseReactants[0].mPosition != POSITION_UNDEFINED);
2553  assert(ranno.mBaseProducts[0].mPosition != POSITION_UNDEFINED);
2554  assert(ranno.mBaseProducts[1].mPosition != POSITION_UNDEFINED);
2555 
2556  if (ranno.mBaseReactants[0].mPosition != POSITION_UNDEFINED &&
2557  ranno.mBaseProducts[0].mPosition != POSITION_UNDEFINED &&
2558  ranno.mBaseProducts[1].mPosition != POSITION_UNDEFINED)
2559  {
2560  // p is the end point of the reaction glyph
2561  // i.e. the point where the products connect
2562  // the start point is a short distance further along the
2563  // path the to the only substrate
2564  Curve* pCurve = pRGlyph->getCurve();
2565  assert(pCurve != NULL);
2566 
2567  if (pCurve != NULL)
2568  {
2569  LineSegment* pLS = pCurve->createLineSegment();
2570  assert(pLS != NULL);
2571 
2572  if (pLS != NULL)
2573  {
2574  pLS->setEnd(p.x(), p.y());
2575 
2576  Point p1 = CCellDesignerImporter::getPositionPoint(pos1->second, ranno.mBaseReactants[0].mPosition);
2577  double dist = CCellDesignerImporter::distance(p1, p);
2578  assert(dist != 0.0);
2579  Point v(new LayoutPkgNamespaces(), (p1.x() - p.x()) / dist, (p1.y() - p.y()) / dist);
2580  dist /= 3.0;
2581 
2582  if (dist > 15.0)
2583  {
2584  dist = 15.0;
2585  }
2586 
2587  pLS->setStart(p.x() + dist * v.x(), p.y() + dist * v.y());
2588 
2589  // create the species reference glyphs
2590  // since we already know the endpoint for the substrate, we start
2591  // with that
2592  SpeciesReferenceGlyph* pSRefGlyph = pRGlyph->createSpeciesReferenceGlyph();
2593  assert(pSRefGlyph != NULL);
2594 
2595  if (pSRefGlyph != NULL)
2596  {
2597  // set the curve
2598  pCurve = pSRefGlyph->getCurve();
2599 
2600  if (pCurve != NULL)
2601  {
2602  LineSegment* pLS2 = pCurve->createLineSegment();
2603  assert(pLS2 != NULL);
2604 
2605  if (pLS2 != NULL)
2606  {
2607  pLS2->setStart(pLS->getStart()->x(), pLS->getStart()->y());
2608  pLS2->setEnd(p1.x(), p1.y());
2609  }
2610  else
2611  {
2612  result = false;
2613  }
2614  }
2615  else
2616  {
2617  result = false;
2618  }
2619 
2620  // set an id
2621  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2622  pSRefGlyph->setId(id);
2623  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph));
2624  // set the role
2625  pSRefGlyph->setRole(SPECIES_ROLE_SUBSTRATE);
2626  // set the species glyph id
2627  this->setSpeciesGlyphId(pSRefGlyph, ranno.mBaseReactants[0]);
2628  // set the species reference id
2629  this->setSpeciesReferenceId(pSRefGlyph, ranno.mBaseReactants[0], pRGlyph->getReactionId());
2630  }
2631  else
2632  {
2633  result = false;
2634  }
2635 
2636  // first product
2637  if (result == true)
2638  {
2639  p1 = CCellDesignerImporter::getPositionPoint(pos2->second, ranno.mBaseProducts[0].mPosition);
2640  pSRefGlyph = pRGlyph->createSpeciesReferenceGlyph();
2641  assert(pSRefGlyph != NULL);
2642 
2643  if (pSRefGlyph != NULL)
2644  {
2645  // set the curve
2646  pCurve = pSRefGlyph->getCurve();
2647 
2648  if (pCurve != NULL)
2649  {
2650  LineSegment* pLS2 = pCurve->createLineSegment();
2651  assert(pLS2 != NULL);
2652 
2653  if (pLS2 != NULL)
2654  {
2655  pLS2->setStart(pLS->getEnd()->x(), pLS->getEnd()->y());
2656  pLS2->setEnd(p1.x(), p1.y());
2657  }
2658  else
2659  {
2660  result = false;
2661  }
2662  }
2663  else
2664  {
2665  result = false;
2666  }
2667 
2668  // set an id
2669  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2670  pSRefGlyph->setId(id);
2671  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph));
2672  // set the role
2673  pSRefGlyph->setRole(SPECIES_ROLE_PRODUCT);
2674  // set the species glyph id
2675  this->setSpeciesGlyphId(pSRefGlyph, ranno.mBaseProducts[0]);
2676  // set the species reference id
2677  this->setSpeciesReferenceId(pSRefGlyph, ranno.mBaseProducts[0], pRGlyph->getReactionId());
2678  }
2679  else
2680  {
2681  result = false;
2682  }
2683  }
2684 
2685  // second product
2686  if (result == true)
2687  {
2688  p1 = CCellDesignerImporter::getPositionPoint(pos3->second, ranno.mBaseProducts[1].mPosition);
2689  pSRefGlyph = pRGlyph->createSpeciesReferenceGlyph();
2690  assert(pSRefGlyph != NULL);
2691 
2692  if (pSRefGlyph != NULL)
2693  {
2694  // set the curve
2695  pCurve = pSRefGlyph->getCurve();
2696 
2697  if (pCurve != NULL)
2698  {
2699  LineSegment* pLS2 = pCurve->createLineSegment();
2700  assert(pLS2 != NULL);
2701 
2702  if (pLS2 != NULL)
2703  {
2704  pLS2->setStart(pLS->getEnd()->x(), pLS->getEnd()->y());
2705  pLS2->setEnd(p1.x(), p1.y());
2706  }
2707  else
2708  {
2709  result = false;
2710  }
2711  }
2712  else
2713  {
2714  result = false;
2715  }
2716 
2717  // set an id
2718  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2719  pSRefGlyph->setId(id);
2720  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph));
2721  // set the role
2722  pSRefGlyph->setRole(SPECIES_ROLE_PRODUCT);
2723  // set the species glyph id
2724  this->setSpeciesGlyphId(pSRefGlyph, ranno.mBaseProducts[1]);
2725  // set the species reference id
2726  this->setSpeciesReferenceId(pSRefGlyph, ranno.mBaseProducts[1], pRGlyph->getReactionId());
2727  }
2728  else
2729  {
2730  result = false;
2731  }
2732  }
2733  }
2734  else
2735  {
2736  result = false;
2737  }
2738  }
2739  else
2740  {
2741  result = false;
2742  }
2743  }
2744  else
2745  {
2746  result = false;
2747  }
2748  }
2749  else
2750  {
2751  result = false;
2752  }
2753  }
2754  break;
2755 
2757  {
2758  assert(ranno.mBaseReactants.size() == 2);
2759  assert(ranno.mBaseProducts.size() == 1);
2760  // assert that all elements have a link anchor
2761  assert(!ranno.mEditPoints.mPoints.empty());
2762  // there should be a tShapeIndex or an omittedShapeIndex element
2763  // that tells us, which of the points is the connection point
2764  Point connectionPoint(new LayoutPkgNamespaces());
2765 
2766  if (ranno.mEditPoints.mTShapeIndex < (int)ranno.mEditPoints.mPoints.size())
2767  {
2768  connectionPoint = ranno.mEditPoints.mPoints[ranno.mEditPoints.mTShapeIndex];
2769  }
2770  else if (ranno.mEditPoints.mOmittedShapeIndex < (int)ranno.mEditPoints.mPoints.size())
2771  {
2772  connectionPoint = ranno.mEditPoints.mPoints[ranno.mEditPoints.mOmittedShapeIndex];
2773  }
2774  else
2775  {
2776  connectionPoint = ranno.mEditPoints.mPoints[0];
2777  }
2778 
2779  // calculate the absolute position
2780  // the position for the relative points coordinates is calculated as
2781  // center_substrat1 + x*(center_product1 - center_substrate_1)+y*(
2782  // center_product2 - center_substrate_1)
2783  // if no tShapeIndex or omittedShapeIndex is given, we assume it is 0
2784  std::string alias1 = ranno.mBaseReactants[0].mAlias;
2785  assert(!alias1.empty());
2786  std::string alias2 = ranno.mBaseReactants[1].mAlias;
2787  assert(!alias2.empty());
2788  std::string alias3 = ranno.mBaseProducts[0].mAlias;
2789  assert(!alias3.empty());
2790  std::map<std::string, BoundingBox>::const_iterator pos1, pos2, pos3;
2791  pos1 = this->mCDBounds.find(alias1);
2792  assert(pos1 != this->mCDBounds.end());
2793  pos2 = this->mCDBounds.find(alias2);
2794  assert(pos2 != this->mCDBounds.end());
2795  pos3 = this->mCDBounds.find(alias3);
2796  assert(pos3 != this->mCDBounds.end());
2797 
2798  if (!alias1.empty() &&
2799  !alias3.empty() &&
2800  !alias3.empty() &&
2801  pos1 != this->mCDBounds.end() &&
2802  pos2 != this->mCDBounds.end() &&
2803  pos3 != this->mCDBounds.end())
2804  {
2805  Point p1(new LayoutPkgNamespaces(), pos1->second.getPosition()->x() + pos1->second.getDimensions()->getWidth() * 0.5, pos1->second.getPosition()->y() + pos1->second.getDimensions()->getHeight() * 0.5);
2806  Point p2(new LayoutPkgNamespaces(), pos2->second.getPosition()->x() + pos2->second.getDimensions()->getWidth() * 0.5, pos2->second.getPosition()->y() + pos2->second.getDimensions()->getHeight() * 0.5);
2807  Point p3(new LayoutPkgNamespaces(), pos3->second.getPosition()->x() + pos3->second.getDimensions()->getWidth() * 0.5, pos3->second.getPosition()->y() + pos3->second.getDimensions()->getHeight() * 0.5);
2808 
2809  Point p = CCellDesignerImporter::calculateAbsoluteValue(connectionPoint, p1, p2, p3);
2810 
2811  // first we have to check if we have linkAnchors for all
2812  // elements
2813  // if not, we create them based on the shortest distance to the
2814  // connection point
2818  assert(ranno.mBaseReactants[0].mPosition != POSITION_UNDEFINED);
2819  assert(ranno.mBaseReactants[1].mPosition != POSITION_UNDEFINED);
2820  assert(ranno.mBaseProducts[0].mPosition != POSITION_UNDEFINED);
2821 
2822  if (ranno.mBaseReactants[0].mPosition != POSITION_UNDEFINED &&
2823  ranno.mBaseReactants[1].mPosition != POSITION_UNDEFINED &&
2824  ranno.mBaseProducts[0].mPosition != POSITION_UNDEFINED)
2825  {
2826  // p is the start point of the reaction glyph
2827  // i.e. the point where the substrates connect
2828  // create the curve for the reaction glyph
2829  // the end point is a short distance further along the
2830  // path the to the only product
2831  Curve* pCurve = pRGlyph->getCurve();
2832  assert(pCurve != NULL);
2833 
2834  if (pCurve != NULL)
2835  {
2836  LineSegment* pLS = pCurve->createLineSegment();
2837  assert(pLS != NULL);
2838 
2839  if (pLS != NULL)
2840  {
2841  pLS->setStart(p.x(), p.y());
2842 
2843  Point p3 = CCellDesignerImporter::getPositionPoint(pos3->second, ranno.mBaseProducts[0].mPosition);
2844  double dist = CCellDesignerImporter::distance(p3, p);
2845  assert(dist != 0.0);
2846  Point v(new LayoutPkgNamespaces(), (p3.x() - p.x()) / dist, (p3.y() - p.y()) / dist);
2847  dist /= 3.0;
2848 
2849  if (dist > 15.0)
2850  {
2851  dist = 15.0;
2852  }
2853 
2854  pLS->setEnd(p.x() + dist * v.x(), p.y() + dist * v.y());
2855 
2856  // create the species reference glyphs
2857  // since we already know the endpoint for the product, we start
2858  // with that
2859  SpeciesReferenceGlyph* pSRefGlyph = pRGlyph->createSpeciesReferenceGlyph();
2860  assert(pSRefGlyph != NULL);
2861 
2862  if (pSRefGlyph != NULL)
2863  {
2864  // set the curve
2865  pCurve = pSRefGlyph->getCurve();
2866 
2867  if (pCurve != NULL)
2868  {
2869  LineSegment* pLS2 = pCurve->createLineSegment();
2870  assert(pLS2 != NULL);
2871 
2872  if (pLS2 != NULL)
2873  {
2874  pLS2->setStart(p.x(), p.y());
2875  pLS2->setEnd(p3.x(), p3.y());
2876  }
2877  else
2878  {
2879  result = false;
2880  }
2881  }
2882  else
2883  {
2884  result = false;
2885  }
2886 
2887  // set an id
2888  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2889  pSRefGlyph->setId(id);
2890  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph));
2891  // set the role
2892  pSRefGlyph->setRole(SPECIES_ROLE_PRODUCT);
2893  // set the species glyph id
2894  this->setSpeciesGlyphId(pSRefGlyph, ranno.mBaseProducts[0]);
2895  // set the species reference id
2896  this->setSpeciesReferenceId(pSRefGlyph, ranno.mBaseProducts[0], pRGlyph->getReactionId());
2897  }
2898  else
2899  {
2900  result = false;
2901  }
2902 
2903  // first substrate
2904  if (result == true)
2905  {
2906  p3 = CCellDesignerImporter::getPositionPoint(pos1->second, ranno.mBaseReactants[0].mPosition);
2907  pSRefGlyph = pRGlyph->createSpeciesReferenceGlyph();
2908  assert(pSRefGlyph != NULL);
2909 
2910  if (pSRefGlyph != NULL)
2911  {
2912  // set the curve
2913  pCurve = pSRefGlyph->getCurve();
2914 
2915  if (pCurve != NULL)
2916  {
2917  LineSegment* pLS2 = pCurve->createLineSegment();
2918  assert(pLS2 != NULL);
2919 
2920  if (pLS2 != NULL)
2921  {
2922  pLS2->setStart(pLS->getStart()->x(), pLS->getStart()->y());
2923  pLS2->setEnd(p3.x(), p3.y());
2924  }
2925  else
2926  {
2927  result = false;
2928  }
2929  }
2930  else
2931  {
2932  result = false;
2933  }
2934 
2935  // set an id
2936  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2937  pSRefGlyph->setId(id);
2938  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph));
2939  // set the role
2940  pSRefGlyph->setRole(SPECIES_ROLE_SUBSTRATE);
2941  // set the species glyph id
2942  this->setSpeciesGlyphId(pSRefGlyph, ranno.mBaseReactants[0]);
2943  // set the species reference id
2944  this->setSpeciesReferenceId(pSRefGlyph, ranno.mBaseReactants[0], pRGlyph->getReactionId());
2945  }
2946  else
2947  {
2948  result = false;
2949  }
2950  }
2951 
2952  // second substrate
2953  if (result == true)
2954  {
2955  p3 = CCellDesignerImporter::getPositionPoint(pos2->second, ranno.mBaseReactants[1].mPosition);
2956  pSRefGlyph = pRGlyph->createSpeciesReferenceGlyph();
2957  assert(pSRefGlyph != NULL);
2958 
2959  if (pSRefGlyph != NULL)
2960  {
2961  // set the curve
2962  pCurve = pSRefGlyph->getCurve();
2963 
2964  if (pCurve != NULL)
2965  {
2966  LineSegment* pLS2 = pCurve->createLineSegment();
2967  assert(pLS2 != NULL);
2968 
2969  if (pLS2 != NULL)
2970  {
2971  pLS2->setStart(pLS->getStart()->x(), pLS->getStart()->y());
2972  pLS2->setEnd(p3.x(), p3.y());
2973  }
2974  else
2975  {
2976  result = false;
2977  }
2978  }
2979  else
2980  {
2981  result = false;
2982  }
2983 
2984  // set an id
2985  std::string id = this->createUniqueId("SpeciesReferenceGlyph");
2986  pSRefGlyph->setId(id);
2987  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSRefGlyph));
2988  // set the role
2989  pSRefGlyph->setRole(SPECIES_ROLE_SUBSTRATE);
2990  // set the species glyph id
2991  this->setSpeciesGlyphId(pSRefGlyph, ranno.mBaseReactants[1]);
2992  // set the species reference id
2993  this->setSpeciesReferenceId(pSRefGlyph, ranno.mBaseReactants[1], pRGlyph->getReactionId());
2994  }
2995  else
2996  {
2997  result = false;
2998  }
2999  }
3000  }
3001  else
3002  {
3003  result = false;
3004  }
3005  }
3006  else
3007  {
3008  result = false;
3009  }
3010  }
3011  else
3012  {
3013  result = false;
3014  }
3015  }
3016  else
3017  {
3018  result = false;
3019  }
3020  }
3021  break;
3022 
3023  default:
3024  result = false;
3025  break;
3026  }
3027 
3028  // there might be additional substrates and reactants
3029  // in the listOfReactantLinks and the listOfProductLinks
3030  if (result == true)
3031  {
3032  result = this->handleExtraReactionElements(pRGlyph, ranno, true);
3033  }
3034 
3035  if (result == true)
3036  {
3037  result = this->handleExtraReactionElements(pRGlyph, ranno, false);
3038  }
3039 
3040  // now that the species reference glyphs are handled,
3041  // we should handle the modifiers
3042  if (result == true)
3043  {
3044  result = this->handleModificationLinks(pRGlyph, ranno);
3045  }
3046  }
3047  else
3048  {
3049  result = false;
3050  }
3051  }
3052  }
3053  }
3054  else
3055  {
3056  result = false;
3057  }
3058 
3059  return result;
3060 }
static Point getPositionPoint(const BoundingBox &box, POSITION position)
std::vector< LinkTarget > mBaseProducts
void checkLinkAnchors(LinkTarget &substrate, LinkTarget &product)
std::string createUniqueId(const std::string &prefix)
static const XMLNode * findCellDesignerAnnotation(SBMLDocument *pDocument, const XMLNode *pAnnotation)
static double distance(const Point &p1, const Point &p2)
bool setSpeciesGlyphId(SpeciesReferenceGlyph *pGlyph, const LinkTarget &link)
static bool createOrthogonal(const Point &v1, Point &v2)
bool handleModificationLinks(ReactionGlyph *pRGlyph, ReactionAnnotation &ranno)
std::map< std::string, BoundingBox > mCDBounds
std::map< std::string, const SBase * > mIdMap
static bool parseReactionAnnotation(const XMLNode *pNode, ReactionAnnotation &ranno)
std::vector< LinkTarget > mBaseReactants
bool handleExtraReactionElements(ReactionGlyph *pRGlyph, ReactionAnnotation &ranno, bool substrate)
static Point calculateAbsoluteValue(const Point &p, const Point &p1, const Point &p2, const Point &p3)
bool setSpeciesReferenceId(SpeciesReferenceGlyph *pGlyph, const LinkTarget &link, const std::string &reactionId)
static bool createLineSegments(Curve *pCurve, ITERATOR start, ITERATOR end)
std::vector< Point > mPoints
void checkLinkAnchor(LinkTarget &link, const Point &p)
bool CCellDesignerImporter::convertReactionAnnotations ( )
protected

Traverses the reactions of the model and looks for CellDesigner annotations. These are used to create reaction glyphs.

Definition at line 2212 of file CCellDesignerImporter.cpp.

References convertReactionAnnotation(), and mpDocument.

Referenced by convertCellDesignerLayout().

2213 {
2214  bool result = true;
2215 
2216  if (this->mpDocument != NULL)
2217  {
2218  Model* pModel = this->mpDocument->getModel();
2219 
2220  if (pModel != NULL)
2221  {
2222  unsigned int i, iMax = pModel->getNumReactions();
2223 
2224  for (i = 0; i < iMax && result == true; ++i)
2225  {
2226  result = this->convertReactionAnnotation(pModel->getReaction(i), pModel);
2227  }
2228  }
2229  else
2230  {
2231  result = false;
2232  }
2233  }
2234  else
2235  {
2236  result = false;
2237  }
2238 
2239  return result;
2240 }
bool convertReactionAnnotation(Reaction *pReaction, const Model *pModel)
bool CCellDesignerImporter::convertSpeciesAnnotations ( )
protected

Traverses the species of the model and looks for CellDesigner annotations. These are used to create text glyphs associated with species.

Definition at line 3481 of file CCellDesignerImporter.cpp.

References createTextGlyphStyle(), createUniqueId(), DEGRADED_CLASS, findCellDesignerAnnotation(), SpeciesAnnotation::mIdentity, mIdMap, mModelIdToLayoutElement, mpDocument, mpLayout, mSpeciesAliasMap, mSpeciesAnnotationMap, SpeciesIdentity::mSpeciesClass, and parseSpeciesAnnotation().

Referenced by convertCellDesignerLayout().

3482 {
3483  bool result = true;
3484 
3485  if (this->mpDocument && this->mpDocument->getModel() && this->mpLayout)
3486  {
3487  Model* pModel = this->mpDocument->getModel();
3488  unsigned int i, iMax = pModel->getNumSpecies();
3489  Species* pSpecies = NULL;
3490  const XMLNode* pAnnotation = NULL;
3491 
3492  for (i = 0; i < iMax && result == true; ++i)
3493  {
3494  pSpecies = pModel->getSpecies(i);
3495 
3496  if (pSpecies->getAnnotation() != NULL)
3497  {
3498  pAnnotation = CCellDesignerImporter::findCellDesignerAnnotation(this->mpDocument, pSpecies->getAnnotation());
3499 
3500  // there should be a name element in there somewhere
3501  if (pAnnotation != NULL)
3502  {
3503 
3504  SpeciesAnnotation sanno;
3505  result = CCellDesignerImporter::parseSpeciesAnnotation(pAnnotation, sanno);
3506 
3507  if (result == true)
3508  {
3509  this->mSpeciesAnnotationMap.insert(std::pair<std::string, SpeciesAnnotation>(pSpecies->getId(), sanno));
3510  std::string name = pSpecies->getName();
3511 
3512  //result=this->findNameForSpeciesIdentity(sanno.mIdentity,name);
3513  if (result && !name.empty() && sanno.mIdentity.mSpeciesClass != DEGRADED_CLASS)
3514  {
3515  // create the text glyph if there is a SpeciesGlyph
3516  std::multimap<std::string, GraphicalObject*>::const_iterator pos = this->mModelIdToLayoutElement.find(pSpecies->getId());
3517  assert(pos != this->mModelIdToLayoutElement.end());
3518  assert(pos->second != NULL);
3519 
3520  if (pos != this->mModelIdToLayoutElement.end() && pos->second != NULL)
3521  {
3522  do
3523  {
3524  const SpeciesGlyph* pSGlyph = dynamic_cast<const SpeciesGlyph*>(pos->second);
3525  assert(pSGlyph != NULL);
3526 
3527  if (pSGlyph != NULL)
3528  {
3529  TextGlyph* pTGlyph = this->mpLayout->createTextGlyph();
3530  std::string id = this->createUniqueId("TextGlyph");
3531  pTGlyph->setId(id);
3532  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pTGlyph));
3533  // set the text and the associated layout element
3534  pTGlyph->setText(name);
3535  pTGlyph->setGraphicalObjectId(pSGlyph->getId());
3536  // set the position and dimensions of the text
3537  Point position = *pSGlyph->getBoundingBox()->getPosition();
3538  Dimensions dim = *pSGlyph->getBoundingBox()->getDimensions();
3539  BoundingBox bb;
3540  bb.setPosition(&position);
3541  bb.setDimensions(&dim);
3542  pTGlyph->setBoundingBox(&bb);
3543  // create an appropriate style
3544  // first we need the style information for the CompartmentGlyph
3545  std::map<const SpeciesGlyph*, SpeciesAlias>::const_iterator speciesAliasPos = this->mSpeciesAliasMap.find(pSGlyph);
3546  assert(speciesAliasPos != this->mSpeciesAliasMap.end());
3547 
3548  if (speciesAliasPos != this->mSpeciesAliasMap.end())
3549  {
3550  Text::TEXT_ANCHOR vAnchor = Text::ANCHOR_MIDDLE;
3551 
3552  if (speciesAliasPos->second.mComplex)
3553  {
3554  vAnchor = Text::ANCHOR_BOTTOM;
3555  }
3556 
3557  this->createTextGlyphStyle(speciesAliasPos->second.mFontSize, Text::ANCHOR_MIDDLE, vAnchor, pTGlyph->getId());
3558  }
3559  }
3560  else
3561  {
3562  result = false;
3563  }
3564 
3565  ++pos;
3566  }
3567  while (result == true && pos != this->mModelIdToLayoutElement.end() && pos->first == pSpecies->getId());
3568  }
3569  else
3570  {
3571  result = false;
3572  }
3573  }
3574  }
3575  else
3576  {
3577  result = false;
3578  }
3579  }
3580  }
3581  }
3582  }
3583  else
3584  {
3585  result = false;
3586  }
3587 
3588  return result;
3589 }
std::string createUniqueId(const std::string &prefix)
SPECIES_CLASS mSpeciesClass
static const XMLNode * findCellDesignerAnnotation(SBMLDocument *pDocument, const XMLNode *pAnnotation)
std::map< const SpeciesGlyph *, SpeciesAlias > mSpeciesAliasMap
static bool parseSpeciesAnnotation(const XMLNode *pNode, SpeciesAnnotation &anno)
std::map< std::string, SpeciesAnnotation > mSpeciesAnnotationMap
bool createTextGlyphStyle(double size, Text::TEXT_ANCHOR hAlign, Text::TEXT_ANCHOR vAlign, const std::string &objectReference)
std::map< std::string, const SBase * > mIdMap
char name[1]
Definition: stdsoap2.h:1342
std::multimap< std::string, GraphicalObject * > mModelIdToLayoutElement
SpeciesIdentity mIdentity
bool CCellDesignerImporter::createCatalysisStyles ( )
protected

Create style for catalysis.

Definition at line 8727 of file CCellDesignerImporter.cpp.

References CATALYSIS_ML_TYPE, createUniqueId(), mColorStringMap, mIdMap, mModificationLinkStyleMap, mpLocalRenderInfo, and UNKNOWN_CATALYSIS_ML_TYPE.

Referenced by createDefaultStyles().

8728 {
8729  bool result = true;
8730 
8731  if (this->mpLocalRenderInfo != NULL)
8732  {
8733  // we need a head for products
8734  LineEnding* pLE = this->mpLocalRenderInfo->createLineEnding();
8735  assert(pLE != NULL);
8736  BoundingBox box;
8737  Point pos(new LayoutPkgNamespaces());
8738  Dimensions dim(new LayoutPkgNamespaces());
8739  RenderGroup* pGroup = NULL;
8740  std::string headId;
8741 
8742  if (pLE != NULL)
8743  {
8744  pLE->setEnableRotationalMapping(true);
8745  headId = this->createUniqueId("catalysis_arrow");
8746  pLE->setId(headId);
8747  this->mIdMap.insert(std::pair<std::string, const SBase*>(headId, pLE));
8748  pos = Point(new LayoutPkgNamespaces(), -5.0, -5.0);
8749  dim = Dimensions(new LayoutPkgNamespaces(), 10.0, 10.0);
8750  box.setPosition(&pos);
8751  box.setDimensions(&dim);
8752  pLE->setBoundingBox(&box);
8753  pGroup = pLE->getGroup();
8754  assert(pGroup != NULL);
8755 
8756  if (pGroup != NULL)
8757  {
8758  Ellipse* pEllipse = pGroup->createEllipse();
8759  assert(pEllipse != NULL);
8760 
8761  if (pEllipse != NULL)
8762  {
8763  pEllipse->setCX(RelAbsVector(5.0, 0.0));
8764  pEllipse->setCY(RelAbsVector(5.0, 0.0));
8765  pEllipse->setRX(RelAbsVector(5.0, 0.0));
8766  pEllipse->setRY(RelAbsVector(5.0, 0.0));
8767  pEllipse->setStrokeWidth(1.0);
8768  pEllipse->setStroke("#000000");
8769  pEllipse->setFillColor("none");
8770  }
8771  else
8772  {
8773  result = false;
8774  }
8775  }
8776  else
8777  {
8778  result = false;
8779  }
8780  }
8781  else
8782  {
8783  result = false;
8784  }
8785 
8786  if (result == true)
8787  {
8788  std::string style_id = this->createUniqueId("CatalysisStyle");
8789  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8790 
8791  if (pStyle != NULL)
8792  {
8793  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8794  assert(pStyle->getGroup() != NULL);
8795 
8796  if (pStyle->getGroup() != NULL)
8797  {
8798  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8799 
8800  if (pos != this->mColorStringMap.end())
8801  {
8802  pStyle->getGroup()->setStroke(pos->second);
8803  }
8804  else
8805  {
8806  pStyle->getGroup()->setStroke("#000000FF");
8807  }
8808 
8809  pStyle->getGroup()->setStrokeWidth(1.0);
8810  pStyle->getGroup()->setEndHead(headId);
8811  this->mModificationLinkStyleMap.insert(std::pair<MODIFICATION_LINK_TYPE, LocalStyle*>(CATALYSIS_ML_TYPE, pStyle));
8812  }
8813  else
8814  {
8815  result = false;
8816  }
8817  }
8818  else
8819  {
8820  result = false;
8821  }
8822  }
8823 
8824  if (result == true)
8825  {
8826  std::string style_id = this->createUniqueId("UnknownCatalysisStyle");
8827  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8828 
8829  if (pStyle != NULL)
8830  {
8831  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8832  assert(pStyle->getGroup() != NULL);
8833 
8834  if (pStyle->getGroup() != NULL)
8835  {
8836  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8837 
8838  if (pos != this->mColorStringMap.end())
8839  {
8840  pStyle->getGroup()->setStroke(pos->second);
8841  }
8842  else
8843  {
8844  pStyle->getGroup()->setStroke("#000000FF");
8845  }
8846 
8847  pStyle->getGroup()->setStrokeWidth(1.0);
8848  std::vector<unsigned int> dashes;
8849  dashes.push_back(5);
8850  dashes.push_back(5);
8851  pStyle->getGroup()->setDashArray(dashes);
8852  // Unknown Catalysis has a dashed stroke pattern
8853  pStyle->getGroup()->setEndHead(headId);
8854  this->mModificationLinkStyleMap.insert(std::pair<MODIFICATION_LINK_TYPE, LocalStyle*>(UNKNOWN_CATALYSIS_ML_TYPE, pStyle));
8855  }
8856  else
8857  {
8858  result = false;
8859  }
8860  }
8861  else
8862  {
8863  result = false;
8864  }
8865  }
8866  }
8867  else
8868  {
8869  result = false;
8870  }
8871 
8872  return result;
8873 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< MODIFICATION_LINK_TYPE, LocalStyle * > mModificationLinkStyleMap
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
bool CCellDesignerImporter::createCompartmentGlyph ( const CompartmentAlias ca)
protected

Creates the compartment glyph from the given compartmentAliase structure.

Definition at line 676 of file CCellDesignerImporter.cpp.

References createCompartmentStyle(), createUniqueId(), CompartmentAlias::mBounds, mCDIdToLayoutElement, CompartmentAlias::mCompartment, mCompartmentAliasMap, mCompartmentNamePointMap, CompartmentAlias::mId, mIdMap, mModelIdToLayoutElement, CompartmentAlias::mNamePoint, mpDocument, and mpLayout.

Referenced by createCompartmentGlyphs().

677 {
678  bool result = true;
679 
680  if (!ca.mId.empty())
681  {
682  CompartmentGlyph* pCGlyph = this->mpLayout->createCompartmentGlyph();
683 
684  if (pCGlyph != NULL)
685  {
686  this->mCDIdToLayoutElement.insert(std::pair<std::string, GraphicalObject*>(ca.mId, pCGlyph));
687  // create a unique id
688  std::string id = this->createUniqueId("CompartmentGlyph");
689  pCGlyph->setId(id);
690  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pCGlyph));
691 
692  // set the corresponding compartment
693  // check if a compartment with that id actually exists before making the link
694  if (!ca.mCompartment.empty() &&
695  this->mpDocument != NULL &&
696  this->mpDocument->getModel() != NULL &&
697  this->mpDocument->getModel()->getCompartment(ca.mCompartment) != NULL)
698  {
699  pCGlyph->setCompartmentId(ca.mCompartment);
700  this->mModelIdToLayoutElement.insert(std::pair<std::string, GraphicalObject*>(ca.mCompartment, pCGlyph));
701  assert(pCGlyph->getBoundingBox() != NULL);
702  pCGlyph->setBoundingBox(&ca.mBounds);
703  this->mCompartmentNamePointMap.insert(std::pair<const CompartmentGlyph*, Point>(pCGlyph, ca.mNamePoint));
704  }
705 
706  // create a style for the compartment glyph
707  result = this->createCompartmentStyle(ca, pCGlyph);
708 
709  if (result == true)
710  {
711  // store the compartment alias
712  this->mCompartmentAliasMap.insert(std::pair<const CompartmentGlyph*, CompartmentAlias>(pCGlyph, ca));
713  }
714  }
715  }
716  else
717  {
718  result = false;
719  }
720 
721  return result;
722 }
std::string createUniqueId(const std::string &prefix)
std::map< const CompartmentGlyph *, Point > mCompartmentNamePointMap
std::map< std::string, GraphicalObject * > mCDIdToLayoutElement
bool createCompartmentStyle(const CompartmentAlias &ca, const CompartmentGlyph *pCGlyph)
std::map< std::string, const SBase * > mIdMap
std::map< const CompartmentGlyph *, CompartmentAlias > mCompartmentAliasMap
std::multimap< std::string, GraphicalObject * > mModelIdToLayoutElement
bool CCellDesignerImporter::createCompartmentGlyphs ( const XMLNode *  pLoCA)
protected

Creates the compartment glyphs from the given node that represents the listOfCompartmentAliases.

Definition at line 598 of file CCellDesignerImporter.cpp.

References createCompartmentGlyph(), mpLayout, and parseCompartmentAlias().

Referenced by convertCellDesignerLayout().

599 {
600  bool result = true;
601 
602  if (pLoCA != NULL && pLoCA->getName() == "listOfCompartmentAliases")
603  {
604  std::string prefix = pLoCA->getPrefix();
605  const XMLNode* pChild = NULL;
606  unsigned int i, iMax = pLoCA->getNumChildren();
607 
608  for (i = 0; i < iMax && result == true; ++i)
609  {
610  pChild = &pLoCA->getChild(i);
611 
612  if (pChild != NULL && pChild->getPrefix() == prefix && pChild->getName() == "compartmentAlias")
613  {
614  CompartmentAlias ca;
615  result = CCellDesignerImporter::parseCompartmentAlias(pChild, ca, *this->mpLayout->getDimensions());
616 
617  if (result == true)
618  {
619  result = this->createCompartmentGlyph(ca);
620  }
621  }
622  }
623  }
624  else
625  {
626  result = false;
627  }
628 
629  return result;
630 }
bool createCompartmentGlyph(const CompartmentAlias &ca)
static bool parseCompartmentAlias(const XMLNode *pNode, CompartmentAlias &ca, const Dimensions &layout_dimensions)
bool CCellDesignerImporter::createCompartmentStyle ( const CompartmentAlias ca,
const CompartmentGlyph *  pCGlyph 
)
protected

This method creates a new local style based on the passed in CompartmentAlias object. The style is associated with the object via the given id. If Creating the style fails, false is returned.

Definition at line 6580 of file CCellDesignerImporter.cpp.

References createUniqueId(), findOrCreateColorDefinition(), CompartmentAlias::mClass, Paint::mColor, CompartmentAlias::mDoubleLine, CompartmentAlias::mFontSize, mIdMap, CompartmentAlias::mPaint, mpLocalRenderInfo, DoubleLine::mThickness, OVAL_CLASS, SQUARE_CLASS, SQUARE_E_CLASS, SQUARE_N_CLASS, SQUARE_NE_CLASS, SQUARE_NW_CLASS, SQUARE_S_CLASS, SQUARE_SE_CLASS, SQUARE_SW_CLASS, and SQUARE_W_CLASS.

Referenced by createCompartmentGlyph().

6581 {
6582  // TODO the GRADIENT flag is currently ignored
6583  bool result = true;
6584 
6585  if (this->mpLocalRenderInfo != NULL &&
6586  !ca.mPaint.mColor.empty() &&
6587  pCGlyph != NULL &&
6588  !pCGlyph->getId().empty())
6589  {
6590  std::string color_id;
6591  result = this->findOrCreateColorDefinition(ca.mPaint.mColor, color_id);
6592  // CellDesigner seems to use the paint color for the two edges
6593  // of the compartment representation
6594  // The inner area (between the two edges seems to be filled with the same color, but
6595  // with a opacity value of about 35 (23 hex).
6596  std::string inner_color_id, inner_color_string = ca.mPaint.mColor;
6597 
6598  if (inner_color_string.length() == 7)
6599  {
6600  inner_color_string += "23";
6601  result = this->findOrCreateColorDefinition(inner_color_string, inner_color_id);
6602  }
6603  else if (inner_color_string.length() == 9)
6604  {
6605  inner_color_string[7] = '2';
6606  inner_color_string[8] = '3';
6607  result = this->findOrCreateColorDefinition(inner_color_string, inner_color_id);
6608  }
6609  else
6610  {
6611  result = false;
6612  }
6613 
6614  if (result == true)
6615  {
6616  // create a new style for the object
6617  std::string style_id = this->createUniqueId("Style");
6618  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
6619 
6620  if (pStyle != NULL)
6621  {
6622  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
6623  RenderGroup* pGroup = pStyle->getGroup();
6624  assert(pGroup != NULL);
6625 
6626  if (pGroup != NULL)
6627  {
6628  // set the font size
6629  pGroup->setFontSize(ca.mFontSize);
6630  double d = ca.mDoubleLine.mThickness;
6631  double width = pCGlyph->getBoundingBox()->getDimensions()->getWidth();
6632  double height = pCGlyph->getBoundingBox()->getDimensions()->getHeight();
6633 
6634  switch (ca.mClass)
6635  {
6636  case SQUARE_CLASS:
6637  {
6638  // three rectangles the first is the thick one with the transparent color
6639  double small_side = (width < height) ? width : height;
6640  Rectangle* pRect = pGroup->createRectangle();
6641  assert(pRect != NULL);
6642 
6643  if (pRect != NULL)
6644  {
6645  pRect->setStroke(inner_color_id);
6646  pRect->setStrokeWidth(d);
6647  pRect->setCoordinates(RelAbsVector(0.0, 0.0), RelAbsVector(0.0, 0.0), RelAbsVector(0.0, 0.0));
6648  pRect->setSize(RelAbsVector(width, 0.0), RelAbsVector(height, 0.0));
6649  pRect->setRadiusX(RelAbsVector(small_side * 0.1, 0.0));
6650  pRect->setRadiusY(RelAbsVector(small_side * 0.1, 0.0));
6651  }
6652  else
6653  {
6654  result = false;
6655  }
6656 
6657  // the second has a width of 2 and is non-transparent
6658  pRect = pGroup->createRectangle();
6659  assert(pRect != NULL);
6660 
6661  if (pRect != NULL)
6662  {
6663  pRect->setStroke(color_id);
6664  pRect->setStrokeWidth(2.0);
6665  pRect->setCoordinates(RelAbsVector(-0.5 * d, 0.0), RelAbsVector(-0.5 * d, 0.0), RelAbsVector(0.0, 0.0));
6666  pRect->setSize(RelAbsVector(width + d, 0.0), RelAbsVector(height + d, 0.0));
6667  pRect->setRadiusX(RelAbsVector((small_side + d) * 0.1, 0.0));
6668  pRect->setRadiusY(RelAbsVector((small_side + d) * 0.1, 0.0));
6669  }
6670  else
6671  {
6672  result = false;
6673  }
6674 
6675  // the third has a width of 1 and is non-transparent
6676  pRect = pGroup->createRectangle();
6677  assert(pRect != NULL);
6678 
6679  if (pRect != NULL)
6680  {
6681  pRect->setStroke(color_id);
6682  pRect->setStrokeWidth(1.0);
6683  pRect->setCoordinates(RelAbsVector(0.5 * d, 0.0), RelAbsVector(0.5 * d, 0.0), RelAbsVector(0.0, 0.0));
6684  pRect->setSize(RelAbsVector(width - d, 0.0), RelAbsVector(height - d, 0.0));
6685  pRect->setRadiusX(RelAbsVector((small_side - d) * 0.1, 0.0));
6686  pRect->setRadiusY(RelAbsVector((small_side - d) * 0.1, 0.0));
6687  }
6688  else
6689  {
6690  result = false;
6691  }
6692  }
6693  break;
6694 
6695  case OVAL_CLASS:
6696  {
6697  // we need three ellipses
6698  // the bottom one is the one with the transparent color
6699  // and the full width
6700  Ellipse* pEllipse = pGroup->createEllipse();
6701  pEllipse->setCX(RelAbsVector(width * 0.5, 0.0));
6702  pEllipse->setCY(RelAbsVector(height * 0.5, 0.0));
6703  pEllipse->setRX(RelAbsVector(width * 0.5, 0.0));
6704  pEllipse->setRY(RelAbsVector(height * 0.5, 0.0));
6705  pEllipse->setStrokeWidth(d);
6706  pEllipse->setStroke(inner_color_id);
6707  // the outer one has a width of 2 and has the non-transparent color
6708  pEllipse = pGroup->createEllipse();
6709  pEllipse->setCX(RelAbsVector(width * 0.5, 0.0));
6710  pEllipse->setCY(RelAbsVector(height * 0.5, 0.0));
6711  pEllipse->setRX(RelAbsVector(width * 0.5 + d * 0.5, 0.0));
6712  pEllipse->setRY(RelAbsVector(height * 0.5 + d * 0.5, 0.0));
6713  pEllipse->setStrokeWidth(2.0);
6714  pEllipse->setStroke(color_id);
6715  // the inner one has a width of 1 and has the non-transparent color
6716  pEllipse = pGroup->createEllipse();
6717  pEllipse->setCX(RelAbsVector(width * 0.5, 0.0));
6718  pEllipse->setCY(RelAbsVector(height * 0.5, 0.0));
6719  pEllipse->setRX(RelAbsVector(width * 0.5 - d * 0.5, 0.0));
6720  pEllipse->setRY(RelAbsVector(height * 0.5 - d * 0.5, 0.0));
6721  pEllipse->setStrokeWidth(1.0);
6722  pEllipse->setStroke(color_id);
6723  }
6724  break;
6725 
6726  case SQUARE_NW_CLASS:
6727  // thick line with thicker edge to the northwest
6728  {
6729  // three curves, the first is thick and transparent
6730  double radius = 20.0;
6731  RenderPoint* pP = NULL;
6732  RenderCubicBezier* pCB = NULL;
6733  RenderCurve* pCurve = pGroup->createCurve();
6734  assert(pCurve != NULL);
6735 
6736  if (pCurve != NULL)
6737  {
6738  pCurve->setStrokeWidth(d);
6739  pCurve->setStroke(inner_color_id);
6740  pP = pCurve->createPoint();
6741  assert(pP != NULL);
6742 
6743  if (pP != NULL)
6744  {
6745  pP->setX(0.0);
6746  pP->setY(height);
6747  }
6748  else
6749  {
6750  result = false;
6751  }
6752 
6753  pP = pCurve->createPoint();
6754  assert(pP != NULL);
6755 
6756  if (pP != NULL)
6757  {
6758  pP->setX(0.0);
6759  pP->setY(radius);
6760  }
6761  else
6762  {
6763  result = false;
6764  }
6765 
6766  pCB = pCurve->createCubicBezier();
6767  assert(pCB != NULL);
6768 
6769  if (pCB != NULL)
6770  {
6771  pCB->setBasePoint1_X(0.0);
6772  pCB->setBasePoint1_Y(0.0);
6773  pCB->setBasePoint2_X(0.0);
6774  pCB->setBasePoint2_Y(0.0);
6775  pCB->setX(radius);
6776  pCB->setY(0.0);
6777  }
6778  else
6779  {
6780  result = false;
6781  }
6782 
6783  pP = pCurve->createPoint();
6784  assert(pP != NULL);
6785 
6786  if (pP != NULL)
6787  {
6788  pP->setX(width);
6789  pP->setY(0.0);
6790  }
6791  else
6792  {
6793  result = false;
6794  }
6795  }
6796  else
6797  {
6798  result = false;
6799  }
6800 
6801  // second curve for the outer edge
6802  pCurve = pGroup->createCurve();
6803  assert(pCurve != NULL);
6804 
6805  if (pCurve != NULL)
6806  {
6807  pCurve->setStrokeWidth(2.0);
6808  pCurve->setStroke(color_id);
6809  pP = pCurve->createPoint();
6810  assert(pP != NULL);
6811 
6812  if (pP != NULL)
6813  {
6814  pP->setX(-d * 0.5);
6815  pP->setY(height);
6816  }
6817  else
6818  {
6819  result = false;
6820  }
6821 
6822  pP = pCurve->createPoint();
6823  assert(pP != NULL);
6824 
6825  if (pP != NULL)
6826  {
6827  pP->setX(-d * 0.5);
6828  pP->setY(radius);
6829  }
6830  else
6831  {
6832  result = false;
6833  }
6834 
6835  pCB = pCurve->createCubicBezier();
6836  assert(pCB != NULL);
6837 
6838  if (pCB != NULL)
6839  {
6840  pCB->setBasePoint1_X(-d * 0.5);
6841  pCB->setBasePoint1_Y(-d * 0.5);
6842  pCB->setBasePoint2_X(-d * 0.5);
6843  pCB->setBasePoint2_Y(-d * 0.5);
6844  pCB->setX(radius);
6845  pCB->setY(-d * 0.5);
6846  }
6847  else
6848  {
6849  result = false;
6850  }
6851 
6852  pP = pCurve->createPoint();
6853  assert(pP != NULL);
6854 
6855  if (pP != NULL)
6856  {
6857  pP->setX(width);
6858  pP->setY(-d * 0.5);
6859  }
6860  else
6861  {
6862  result = false;
6863  }
6864  }
6865  else
6866  {
6867  result = false;
6868  }
6869 
6870  // third curve for the inner edge
6871  pCurve = pGroup->createCurve();
6872  assert(pCurve != NULL);
6873 
6874  if (pCurve != NULL)
6875  {
6876  pCurve->setStrokeWidth(1.0);
6877  pCurve->setStroke(color_id);
6878  pP = pCurve->createPoint();
6879  assert(pP != NULL);
6880 
6881  if (pP != NULL)
6882  {
6883  pP->setX(d * 0.5);
6884  pP->setY(height);
6885  }
6886  else
6887  {
6888  result = false;
6889  }
6890 
6891  pP = pCurve->createPoint();
6892  assert(pP != NULL);
6893 
6894  if (pP != NULL)
6895  {
6896  pP->setX(d * 0.5);
6897  pP->setY(radius);
6898  }
6899  else
6900  {
6901  result = false;
6902  }
6903 
6904  pCB = pCurve->createCubicBezier();
6905  assert(pCB != NULL);
6906 
6907  if (pCB != NULL)
6908  {
6909  pCB->setBasePoint1_X(d * 0.5);
6910  pCB->setBasePoint1_Y(d * 0.5);
6911  pCB->setBasePoint2_X(d * 0.5);
6912  pCB->setBasePoint2_Y(d * 0.5);
6913  pCB->setX(radius);
6914  pCB->setY(d * 0.5);
6915  }
6916  else
6917  {
6918  result = false;
6919  }
6920 
6921  pP = pCurve->createPoint();
6922  assert(pP != NULL);
6923 
6924  if (pP != NULL)
6925  {
6926  pP->setX(width);
6927  pP->setY(d * 0.5);
6928  }
6929  else
6930  {
6931  result = false;
6932  }
6933  }
6934  else
6935  {
6936  result = false;
6937  }
6938  }
6939  break;
6940 
6941  case SQUARE_NE_CLASS:
6942  // thick line with thicker edge to the northeast
6943  {
6944  // three curves, the first is thick and transparent
6945  double radius = 20.0;
6946  RenderPoint* pP = NULL;
6947  RenderCubicBezier* pCB = NULL;
6948  RenderCurve* pCurve = pGroup->createCurve();
6949  assert(pCurve != NULL);
6950 
6951  if (pCurve != NULL)
6952  {
6953  pCurve->setStrokeWidth(d);
6954  pCurve->setStroke(inner_color_id);
6955  pP = pCurve->createPoint();
6956  assert(pP != NULL);
6957 
6958  if (pP != NULL)
6959  {
6960  pP->setX(0.0);
6961  pP->setY(0.0);
6962  }
6963  else
6964  {
6965  result = false;
6966  }
6967 
6968  pP = pCurve->createPoint();
6969  assert(pP != NULL);
6970 
6971  if (pP != NULL)
6972  {
6973  pP->setX(width - radius);
6974  pP->setY(0.0);
6975  }
6976  else
6977  {
6978  result = false;
6979  }
6980 
6981  pCB = pCurve->createCubicBezier();
6982  assert(pCB != NULL);
6983 
6984  if (pCB != NULL)
6985  {
6986  pCB->setBasePoint1_X(width);
6987  pCB->setBasePoint1_Y(0.0);
6988  pCB->setBasePoint2_X(width);
6989  pCB->setBasePoint2_Y(0.0);
6990  pCB->setX(width);
6991  pCB->setY(radius);
6992  }
6993  else
6994  {
6995  result = false;
6996  }
6997 
6998  pP = pCurve->createPoint();
6999  assert(pP != NULL);
7000 
7001  if (pP != NULL)
7002  {
7003  pP->setX(width);
7004  pP->setY(height);
7005  }
7006  else
7007  {
7008  result = false;
7009  }
7010  }
7011  else
7012  {
7013  result = false;
7014  }
7015 
7016  // second curve for the outer edge
7017  pCurve = pGroup->createCurve();
7018  assert(pCurve != NULL);
7019 
7020  if (pCurve != NULL)
7021  {
7022  pCurve->setStrokeWidth(2.0);
7023  pCurve->setStroke(color_id);
7024  pP = pCurve->createPoint();
7025  assert(pP != NULL);
7026 
7027  if (pP != NULL)
7028  {
7029  pP->setX(0.0);
7030  pP->setY(-d * 0.5);
7031  }
7032  else
7033  {
7034  result = false;
7035  }
7036 
7037  pP = pCurve->createPoint();
7038  assert(pP != NULL);
7039 
7040  if (pP != NULL)
7041  {
7042  pP->setX(width - radius);
7043  pP->setY(-d * 0.5);
7044  }
7045  else
7046  {
7047  result = false;
7048  }
7049 
7050  pCB = pCurve->createCubicBezier();
7051  assert(pCB != NULL);
7052 
7053  if (pCB != NULL)
7054  {
7055  pCB->setBasePoint1_X(width + 0.5 * d);
7056  pCB->setBasePoint1_Y(-0.5 * d);
7057  pCB->setBasePoint2_X(width + 0.5 * d);
7058  pCB->setBasePoint2_Y(-0.5 * d);
7059  pCB->setX(width + 0.5 * d);
7060  pCB->setY(radius);
7061  }
7062  else
7063  {
7064  result = false;
7065  }
7066 
7067  pP = pCurve->createPoint();
7068  assert(pP != NULL);
7069 
7070  if (pP != NULL)
7071  {
7072  pP->setX(width + 0.5 * d);
7073  pP->setY(height);
7074  }
7075  else
7076  {
7077  result = false;
7078  }
7079  }
7080  else
7081  {
7082  result = false;
7083  }
7084 
7085  // third curve for the inner edge
7086  pCurve = pGroup->createCurve();
7087  assert(pCurve != NULL);
7088 
7089  if (pCurve != NULL)
7090  {
7091  pCurve->setStrokeWidth(1.0);
7092  pCurve->setStroke(color_id);
7093  pP = pCurve->createPoint();
7094  assert(pP != NULL);
7095 
7096  if (pP != NULL)
7097  {
7098  pP->setX(0.0);
7099  pP->setY(0.5 * d);
7100  }
7101  else
7102  {
7103  result = false;
7104  }
7105 
7106  pP = pCurve->createPoint();
7107  assert(pP != NULL);
7108 
7109  if (pP != NULL)
7110  {
7111  pP->setX(width - radius);
7112  pP->setY(0.5 * d);
7113  }
7114  else
7115  {
7116  result = false;
7117  }
7118 
7119  pCB = pCurve->createCubicBezier();
7120  assert(pCB != NULL);
7121 
7122  if (pCB != NULL)
7123  {
7124  pCB->setBasePoint1_X(width - 0.5 * d);
7125  pCB->setBasePoint1_Y(0.5 * d);
7126  pCB->setBasePoint2_X(width - 0.5 * d);
7127  pCB->setBasePoint2_Y(0.5 * d);
7128  pCB->setX(width - 0.5 * d);
7129  pCB->setY(radius);
7130  }
7131  else
7132  {
7133  result = false;
7134  }
7135 
7136  pP = pCurve->createPoint();
7137  assert(pP != NULL);
7138 
7139  if (pP != NULL)
7140  {
7141  pP->setX(width - 0.5 * d);
7142  pP->setY(height);
7143  }
7144  else
7145  {
7146  result = false;
7147  }
7148  }
7149  else
7150  {
7151  result = false;
7152  }
7153  }
7154  break;
7155 
7156  case SQUARE_SW_CLASS:
7157  // thick line with thicker edge to the southwest
7158  {
7159  // three curves, the first is thick and transparent
7160  double radius = 20.0;
7161  RenderPoint* pP = NULL;
7162  RenderCubicBezier* pCB = NULL;
7163  RenderCurve* pCurve = pGroup->createCurve();
7164  assert(pCurve != NULL);
7165 
7166  if (pCurve != NULL)
7167  {
7168  pCurve->setStrokeWidth(d);
7169  pCurve->setStroke(inner_color_id);
7170  pP = pCurve->createPoint();
7171  assert(pP != NULL);
7172 
7173  if (pP != NULL)
7174  {
7175  pP->setX(0.0);
7176  pP->setY(0.0);
7177  }
7178  else
7179  {
7180  result = false;
7181  }
7182 
7183  pP = pCurve->createPoint();
7184  assert(pP != NULL);
7185 
7186  if (pP != NULL)
7187  {
7188  pP->setX(0.0);
7189  pP->setY(height - radius);
7190  }
7191  else
7192  {
7193  result = false;
7194  }
7195 
7196  pCB = pCurve->createCubicBezier();
7197  assert(pCB != NULL);
7198 
7199  if (pCB != NULL)
7200  {
7201  pCB->setBasePoint1_X(0.0);
7202  pCB->setBasePoint1_Y(height);
7203  pCB->setBasePoint2_X(0.0);
7204  pCB->setBasePoint2_Y(height);
7205  pCB->setX(radius);
7206  pCB->setY(height);
7207  }
7208  else
7209  {
7210  result = false;
7211  }
7212 
7213  pP = pCurve->createPoint();
7214  assert(pP != NULL);
7215 
7216  if (pP != NULL)
7217  {
7218  pP->setX(width);
7219  pP->setY(height);
7220  }
7221  else
7222  {
7223  result = false;
7224  }
7225  }
7226  else
7227  {
7228  result = false;
7229  }
7230 
7231  // second curve for the outer edge
7232  pCurve = pGroup->createCurve();
7233  assert(pCurve != NULL);
7234 
7235  if (pCurve != NULL)
7236  {
7237  pCurve->setStrokeWidth(2.0);
7238  pCurve->setStroke(color_id);
7239  pP = pCurve->createPoint();
7240  assert(pP != NULL);
7241 
7242  if (pP != NULL)
7243  {
7244  pP->setX(-0.5 * d);
7245  pP->setY(0.0);
7246  }
7247  else
7248  {
7249  result = false;
7250  }
7251 
7252  pP = pCurve->createPoint();
7253  assert(pP != NULL);
7254 
7255  if (pP != NULL)
7256  {
7257  pP->setX(-d * 0.5);
7258  pP->setY(height - radius);
7259  }
7260  else
7261  {
7262  result = false;
7263  }
7264 
7265  pCB = pCurve->createCubicBezier();
7266  assert(pCB != NULL);
7267 
7268  if (pCB != NULL)
7269  {
7270  pCB->setBasePoint1_X(-d * 0.5);
7271  pCB->setBasePoint1_Y(height + d * 0.5);
7272  pCB->setBasePoint2_X(-d * 0.5);
7273  pCB->setBasePoint2_Y(height + d * 0.5);
7274  pCB->setX(radius);
7275  pCB->setY(height + d * 0.5);
7276  }
7277  else
7278  {
7279  result = false;
7280  }
7281 
7282  pP = pCurve->createPoint();
7283  assert(pP != NULL);
7284 
7285  if (pP != NULL)
7286  {
7287  pP->setX(width);
7288  pP->setY(height + d * 0.5);
7289  }
7290  else
7291  {
7292  result = false;
7293  }
7294  }
7295  else
7296  {
7297  result = false;
7298  }
7299 
7300  // third curve for the inner edge
7301  pCurve = pGroup->createCurve();
7302  assert(pCurve != NULL);
7303 
7304  if (pCurve != NULL)
7305  {
7306  pCurve->setStrokeWidth(1.0);
7307  pCurve->setStroke(color_id);
7308  pP = pCurve->createPoint();
7309  assert(pP != NULL);
7310 
7311  if (pP != NULL)
7312  {
7313  pP->setX(d * 0.5);
7314  pP->setY(0.0);
7315  }
7316  else
7317  {
7318  result = false;
7319  }
7320 
7321  pP = pCurve->createPoint();
7322  assert(pP != NULL);
7323 
7324  if (pP != NULL)
7325  {
7326  pP->setX(d * 0.5);
7327  pP->setY(height - radius);
7328  }
7329  else
7330  {
7331  result = false;
7332  }
7333 
7334  pCB = pCurve->createCubicBezier();
7335  assert(pCB != NULL);
7336 
7337  if (pCB != NULL)
7338  {
7339  pCB->setBasePoint1_X(d * 0.5);
7340  pCB->setBasePoint1_Y(height - d * 0.5);
7341  pCB->setBasePoint2_X(d * 0.5);
7342  pCB->setBasePoint2_Y(height - d * 0.5);
7343  pCB->setX(radius);
7344  pCB->setY(height - d * 0.5);
7345  }
7346  else
7347  {
7348  result = false;
7349  }
7350 
7351  pP = pCurve->createPoint();
7352  assert(pP != NULL);
7353 
7354  if (pP != NULL)
7355  {
7356  pP->setX(width);
7357  pP->setY(height - d * 0.5);
7358  }
7359  else
7360  {
7361  result = false;
7362  }
7363  }
7364  else
7365  {
7366  result = false;
7367  }
7368  }
7369  break;
7370 
7371  case SQUARE_SE_CLASS:
7372  // thick line with thicker edge to the southeast
7373  {
7374  // three curves, the first is thick and transparent
7375  double radius = 20.0;
7376  RenderPoint* pP = NULL;
7377  RenderCubicBezier* pCB = NULL;
7378  RenderCurve* pCurve = pGroup->createCurve();
7379  assert(pCurve != NULL);
7380 
7381  if (pCurve != NULL)
7382  {
7383  pCurve->setStrokeWidth(d);
7384  pCurve->setStroke(inner_color_id);
7385  pP = pCurve->createPoint();
7386  assert(pP != NULL);
7387 
7388  if (pP != NULL)
7389  {
7390  pP->setX(0.0);
7391  pP->setY(height);
7392  }
7393  else
7394  {
7395  result = false;
7396  }
7397 
7398  pP = pCurve->createPoint();
7399  assert(pP != NULL);
7400 
7401  if (pP != NULL)
7402  {
7403  pP->setX(width - radius);
7404  pP->setY(height);
7405  }
7406  else
7407  {
7408  result = false;
7409  }
7410 
7411  pCB = pCurve->createCubicBezier();
7412  assert(pCB != NULL);
7413 
7414  if (pCB != NULL)
7415  {
7416  pCB->setBasePoint1_X(width);
7417  pCB->setBasePoint1_Y(height);
7418  pCB->setBasePoint2_X(width);
7419  pCB->setBasePoint2_Y(height);
7420  pCB->setX(width);
7421  pCB->setY(height - radius);
7422  }
7423  else
7424  {
7425  result = false;
7426  }
7427 
7428  pP = pCurve->createPoint();
7429  assert(pP != NULL);
7430 
7431  if (pP != NULL)
7432  {
7433  pP->setX(width);
7434  pP->setY(0.0);
7435  }
7436  else
7437  {
7438  result = false;
7439  }
7440  }
7441  else
7442  {
7443  result = false;
7444  }
7445 
7446  // second curve for the outer edge
7447  pCurve = pGroup->createCurve();
7448  assert(pCurve != NULL);
7449 
7450  if (pCurve != NULL)
7451  {
7452  pCurve->setStrokeWidth(2.0);
7453  pCurve->setStroke(color_id);
7454  pP = pCurve->createPoint();
7455  assert(pP != NULL);
7456 
7457  if (pP != NULL)
7458  {
7459  pP->setX(0.0);
7460  pP->setY(height + 0.5 * d);
7461  }
7462  else
7463  {
7464  result = false;
7465  }
7466 
7467  pP = pCurve->createPoint();
7468  assert(pP != NULL);
7469 
7470  if (pP != NULL)
7471  {
7472  pP->setX(width - radius);
7473  pP->setY(height + 0.5 * d);
7474  }
7475  else
7476  {
7477  result = false;
7478  }
7479 
7480  pCB = pCurve->createCubicBezier();
7481  assert(pCB != NULL);
7482 
7483  if (pCB != NULL)
7484  {
7485  pCB->setBasePoint1_X(width + d * 0.5);
7486  pCB->setBasePoint1_Y(height + 0.5 * d);
7487  pCB->setBasePoint2_X(width + d * 0.5);
7488  pCB->setBasePoint2_Y(height + d * 0.5);
7489  pCB->setX(width + 0.5 * d);
7490  pCB->setY(height - radius);
7491  }
7492  else
7493  {
7494  result = false;
7495  }
7496 
7497  pP = pCurve->createPoint();
7498  assert(pP != NULL);
7499 
7500  if (pP != NULL)
7501  {
7502  pP->setX(width + 0.5 * d);
7503  pP->setY(0.0);
7504  }
7505  else
7506  {
7507  result = false;
7508  }
7509  }
7510  else
7511  {
7512  result = false;
7513  }
7514 
7515  // third curve for the inner edge
7516  pCurve = pGroup->createCurve();
7517  assert(pCurve != NULL);
7518 
7519  if (pCurve != NULL)
7520  {
7521  pCurve->setStrokeWidth(1.0);
7522  pCurve->setStroke(color_id);
7523  pP = pCurve->createPoint();
7524  assert(pP != NULL);
7525 
7526  if (pP != NULL)
7527  {
7528  pP->setX(0.0);
7529  pP->setY(height - 0.5 * d);
7530  }
7531  else
7532  {
7533  result = false;
7534  }
7535 
7536  pP = pCurve->createPoint();
7537  assert(pP != NULL);
7538 
7539  if (pP != NULL)
7540  {
7541  pP->setX(width - radius);
7542  pP->setY(height - 0.5 * d);
7543  }
7544  else
7545  {
7546  result = false;
7547  }
7548 
7549  pCB = pCurve->createCubicBezier();
7550  assert(pCB != NULL);
7551 
7552  if (pCB != NULL)
7553  {
7554  pCB->setBasePoint1_X(width - d * 0.5);
7555  pCB->setBasePoint1_Y(height - d * 0.5);
7556  pCB->setBasePoint2_X(width - d * 0.5);
7557  pCB->setBasePoint2_Y(height - d * 0.5);
7558  pCB->setX(width - 0.5 * d);
7559  pCB->setY(height - radius);
7560  }
7561  else
7562  {
7563  result = false;
7564  }
7565 
7566  pP = pCurve->createPoint();
7567  assert(pP != NULL);
7568 
7569  if (pP != NULL)
7570  {
7571  pP->setX(width - 0.5 * d);
7572  pP->setY(0.0);
7573  }
7574  else
7575  {
7576  result = false;
7577  }
7578  }
7579  else
7580  {
7581  result = false;
7582  }
7583  }
7584  break;
7585 
7586  case SQUARE_N_CLASS:
7587  // thick line with thicker edge to the north
7588  {
7589  // three curves, the first is thick and transparent
7590  RenderPoint* pP = NULL;
7591  RenderCurve* pCurve = pGroup->createCurve();
7592  assert(pCurve != NULL);
7593 
7594  if (pCurve != NULL)
7595  {
7596  pCurve->setStrokeWidth(d);
7597  pCurve->setStroke(inner_color_id);
7598  pP = pCurve->createPoint();
7599  assert(pP != NULL);
7600 
7601  if (pP != NULL)
7602  {
7603  pP->setX(0.0);
7604  pP->setY(0.0);
7605  }
7606  else
7607  {
7608  result = false;
7609  }
7610 
7611  pP = pCurve->createPoint();
7612  assert(pP != NULL);
7613 
7614  if (pP != NULL)
7615  {
7616  pP->setX(width);
7617  pP->setY(0.0);
7618  }
7619  else
7620  {
7621  result = false;
7622  }
7623  }
7624  else
7625  {
7626  result = false;
7627  }
7628 
7629  // the second has width 2 and is non-transparent
7630  pCurve = pGroup->createCurve();
7631  assert(pCurve != NULL);
7632 
7633  if (pCurve != NULL)
7634  {
7635  pCurve->setStrokeWidth(2.0);
7636  pCurve->setStroke(color_id);
7637  pP = pCurve->createPoint();
7638  assert(pP != NULL);
7639 
7640  if (pP != NULL)
7641  {
7642  pP->setX(0.0);
7643  pP->setY(-0.5 * d);
7644  }
7645  else
7646  {
7647  result = false;
7648  }
7649 
7650  pP = pCurve->createPoint();
7651  assert(pP != NULL);
7652 
7653  if (pP != NULL)
7654  {
7655  pP->setX(width);
7656  pP->setY(-0.5 * d);
7657  }
7658  else
7659  {
7660  result = false;
7661  }
7662  }
7663  else
7664  {
7665  result = false;
7666  }
7667 
7668  // the third has width 1 and is non-transparent
7669  pCurve = pGroup->createCurve();
7670  assert(pCurve != NULL);
7671 
7672  if (pCurve != NULL)
7673  {
7674  pCurve->setStrokeWidth(1.0);
7675  pCurve->setStroke(color_id);
7676  pP = pCurve->createPoint();
7677  assert(pP != NULL);
7678 
7679  if (pP != NULL)
7680  {
7681  pP->setX(0.0);
7682  pP->setY(0.5 * d);
7683  }
7684  else
7685  {
7686  result = false;
7687  }
7688 
7689  pP = pCurve->createPoint();
7690  assert(pP != NULL);
7691 
7692  if (pP != NULL)
7693  {
7694  pP->setX(width);
7695  pP->setY(0.5 * d);
7696  }
7697  else
7698  {
7699  result = false;
7700  }
7701  }
7702  else
7703  {
7704  result = false;
7705  }
7706  }
7707  break;
7708 
7709  case SQUARE_E_CLASS:
7710  // thick line with thicker edge to the east
7711  {
7712  // three curves, the first is thick and transparent
7713  RenderPoint* pP = NULL;
7714  RenderCurve* pCurve = pGroup->createCurve();
7715  assert(pCurve != NULL);
7716 
7717  if (pCurve != NULL)
7718  {
7719  pCurve->setStrokeWidth(d);
7720  pCurve->setStroke(inner_color_id);
7721  pP = pCurve->createPoint();
7722  assert(pP != NULL);
7723 
7724  if (pP != NULL)
7725  {
7726  pP->setX(width);
7727  pP->setY(0.0);
7728  }
7729  else
7730  {
7731  result = false;
7732  }
7733 
7734  pP = pCurve->createPoint();
7735  assert(pP != NULL);
7736 
7737  if (pP != NULL)
7738  {
7739  pP->setX(width);
7740  pP->setY(height);
7741  }
7742  else
7743  {
7744  result = false;
7745  }
7746  }
7747  else
7748  {
7749  result = false;
7750  }
7751 
7752  // the second has width 2 and is non-transparent
7753  pCurve = pGroup->createCurve();
7754  assert(pCurve != NULL);
7755 
7756  if (pCurve != NULL)
7757  {
7758  pCurve->setStrokeWidth(2.0);
7759  pCurve->setStroke(color_id);
7760  pP = pCurve->createPoint();
7761  assert(pP != NULL);
7762 
7763  if (pP != NULL)
7764  {
7765  pP->setX(width + 0.5 * d);
7766  pP->setY(0.0);
7767  }
7768  else
7769  {
7770  result = false;
7771  }
7772 
7773  pP = pCurve->createPoint();
7774  assert(pP != NULL);
7775 
7776  if (pP != NULL)
7777  {
7778  pP->setX(width + 0.5 * d);
7779  pP->setY(height);
7780  }
7781  else
7782  {
7783  result = false;
7784  }
7785  }
7786  else
7787  {
7788  result = false;
7789  }
7790 
7791  // the third has width 1 and is non-transparent
7792  pCurve = pGroup->createCurve();
7793  assert(pCurve != NULL);
7794 
7795  if (pCurve != NULL)
7796  {
7797  pCurve->setStrokeWidth(1.0);
7798  pCurve->setStroke(color_id);
7799  pP = pCurve->createPoint();
7800  assert(pP != NULL);
7801 
7802  if (pP != NULL)
7803  {
7804  pP->setX(width - 0.5 * d);
7805  pP->setY(0.0);
7806  }
7807  else
7808  {
7809  result = false;
7810  }
7811 
7812  pP = pCurve->createPoint();
7813  assert(pP != NULL);
7814 
7815  if (pP != NULL)
7816  {
7817  pP->setX(width - 0.5 * d);
7818  pP->setY(height);
7819  }
7820  else
7821  {
7822  result = false;
7823  }
7824  }
7825  else
7826  {
7827  result = false;
7828  }
7829  }
7830  break;
7831 
7832  case SQUARE_W_CLASS:
7833  // thick line with thicker edge to the west
7834  {
7835  // three curves, the first is thick and transparent
7836  RenderPoint* pP = NULL;
7837  RenderCurve* pCurve = pGroup->createCurve();
7838  assert(pCurve != NULL);
7839 
7840  if (pCurve != NULL)
7841  {
7842  pCurve->setStrokeWidth(d);
7843  pCurve->setStroke(inner_color_id);
7844  pP = pCurve->createPoint();
7845  assert(pP != NULL);
7846 
7847  if (pP != NULL)
7848  {
7849  pP->setX(0.0);
7850  pP->setY(0.0);
7851  }
7852  else
7853  {
7854  result = false;
7855  }
7856 
7857  pP = pCurve->createPoint();
7858  assert(pP != NULL);
7859 
7860  if (pP != NULL)
7861  {
7862  pP->setX(0.0);
7863  pP->setY(height);
7864  }
7865  else
7866  {
7867  result = false;
7868  }
7869  }
7870  else
7871  {
7872  result = false;
7873  }
7874 
7875  // the second has width 2 and is non-transparent
7876  pCurve = pGroup->createCurve();
7877  assert(pCurve != NULL);
7878 
7879  if (pCurve != NULL)
7880  {
7881  pCurve->setStrokeWidth(2.0);
7882  pCurve->setStroke(color_id);
7883  pP = pCurve->createPoint();
7884  assert(pP != NULL);
7885 
7886  if (pP != NULL)
7887  {
7888  pP->setX(-0.5 * d);
7889  pP->setY(0.0);
7890  }
7891  else
7892  {
7893  result = false;
7894  }
7895 
7896  pP = pCurve->createPoint();
7897  assert(pP != NULL);
7898 
7899  if (pP != NULL)
7900  {
7901  pP->setX(-0.5 * d);
7902  pP->setY(height);
7903  }
7904  else
7905  {
7906  result = false;
7907  }
7908  }
7909  else
7910  {
7911  result = false;
7912  }
7913 
7914  // the third has width 1 and is non-transparent
7915  pCurve = pGroup->createCurve();
7916  assert(pCurve != NULL);
7917 
7918  if (pCurve != NULL)
7919  {
7920  pCurve->setStrokeWidth(1.0);
7921  pCurve->setStroke(color_id);
7922  pP = pCurve->createPoint();
7923  assert(pP != NULL);
7924 
7925  if (pP != NULL)
7926  {
7927  pP->setX(0.5 * d);
7928  pP->setY(0.0);
7929  }
7930  else
7931  {
7932  result = false;
7933  }
7934 
7935  pP = pCurve->createPoint();
7936  assert(pP != NULL);
7937 
7938  if (pP != NULL)
7939  {
7940  pP->setX(0.5 * d);
7941  pP->setY(height);
7942  }
7943  else
7944  {
7945  result = false;
7946  }
7947  }
7948  else
7949  {
7950  result = false;
7951  }
7952  }
7953  break;
7954 
7955  case SQUARE_S_CLASS:
7956  // thick line with thicker edge to the south
7957  {
7958  // three curves, the first is thick and transparent
7959  RenderPoint* pP = NULL;
7960  RenderCurve* pCurve = pGroup->createCurve();
7961  assert(pCurve != NULL);
7962 
7963  if (pCurve != NULL)
7964  {
7965  pCurve->setStrokeWidth(d);
7966  pCurve->setStroke(inner_color_id);
7967  pP = pCurve->createPoint();
7968  assert(pP != NULL);
7969 
7970  if (pP != NULL)
7971  {
7972  pP->setX(0.0);
7973  pP->setY(height);
7974  }
7975  else
7976  {
7977  result = false;
7978  }
7979 
7980  pP = pCurve->createPoint();
7981  assert(pP != NULL);
7982 
7983  if (pP != NULL)
7984  {
7985  pP->setX(width);
7986  pP->setY(height);
7987  }
7988  else
7989  {
7990  result = false;
7991  }
7992  }
7993  else
7994  {
7995  result = false;
7996  }
7997 
7998  // the second has width 2 and is non-transparent
7999  pCurve = pGroup->createCurve();
8000  assert(pCurve != NULL);
8001 
8002  if (pCurve != NULL)
8003  {
8004  pCurve->setStrokeWidth(2.0);
8005  pCurve->setStroke(color_id);
8006  pP = pCurve->createPoint();
8007  assert(pP != NULL);
8008 
8009  if (pP != NULL)
8010  {
8011  pP->setX(0.0);
8012  pP->setY(height + d * 0.5);
8013  }
8014  else
8015  {
8016  result = false;
8017  }
8018 
8019  pP = pCurve->createPoint();
8020  assert(pP != NULL);
8021 
8022  if (pP != NULL)
8023  {
8024  pP->setX(width);
8025  pP->setY(height + d * 0.5);
8026  }
8027  else
8028  {
8029  result = false;
8030  }
8031  }
8032  else
8033  {
8034  result = false;
8035  }
8036 
8037  // the third has width 1 and is non-transparent
8038  pCurve = pGroup->createCurve();
8039  assert(pCurve != NULL);
8040 
8041  if (pCurve != NULL)
8042  {
8043  pCurve->setStrokeWidth(1.0);
8044  pCurve->setStroke(color_id);
8045  pP = pCurve->createPoint();
8046  assert(pP != NULL);
8047 
8048  if (pP != NULL)
8049  {
8050  pP->setX(0.0);
8051  pP->setY(height - d * 0.5);
8052  }
8053  else
8054  {
8055  result = false;
8056  }
8057 
8058  pP = pCurve->createPoint();
8059  assert(pP != NULL);
8060 
8061  if (pP != NULL)
8062  {
8063  pP->setX(width);
8064  pP->setY(height - d * 0.5);
8065  }
8066  else
8067  {
8068  result = false;
8069  }
8070  }
8071  else
8072  {
8073  result = false;
8074  }
8075  }
8076  break;
8077 
8078  default:
8079  result = false;
8080  break;
8081  }
8082  }
8083 
8084  // don't forget to associate the style and the layout object via the id
8085  pStyle->addId(pCGlyph->getId());
8086  }
8087  }
8088  }
8089  else
8090  {
8091  result = false;
8092  }
8093 
8094  return result;
8095 }
std::string mColor
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
bool findOrCreateColorDefinition(const std::string &color_string, std::string &id)
std::map< std::string, const SBase * > mIdMap
bool CCellDesignerImporter::createDefaultActivatorStyle ( )
protected

Create default style for activators.

Definition at line 8590 of file CCellDesignerImporter.cpp.

References createUniqueId(), mColorStringMap, mIdMap, and mpLocalRenderInfo.

Referenced by createDefaultStyles().

8591 {
8592  bool result = true;
8593 
8594  if (this->mpLocalRenderInfo != NULL)
8595  {
8596  // we need a head for products
8597  LineEnding* pLE = this->mpLocalRenderInfo->createLineEnding();
8598  assert(pLE != NULL);
8599  BoundingBox box;
8600  Point pos(new LayoutPkgNamespaces());
8601  Dimensions dim(new LayoutPkgNamespaces());
8602  RenderGroup* pGroup = NULL;
8603  std::string headId;
8604 
8605  if (pLE != NULL)
8606  {
8607  pLE->setEnableRotationalMapping(true);
8608  headId = this->createUniqueId("activator_arrow");
8609  pLE->setId(headId);
8610  this->mIdMap.insert(std::pair<std::string, const SBase*>(headId, pLE));
8611  pos = Point(new LayoutPkgNamespaces(), -5.0, -5.0);
8612  dim = Dimensions(new LayoutPkgNamespaces(), 10.0, 10.0);
8613  box.setPosition(&pos);
8614  box.setDimensions(&dim);
8615  pLE->setBoundingBox(&box);
8616  pGroup = pLE->getGroup();
8617  assert(pGroup != NULL);
8618 
8619  if (pGroup != NULL)
8620  {
8621  Polygon* pPolygon = pGroup->createPolygon();
8622  assert(pPolygon != NULL);
8623 
8624  if (pPolygon != NULL)
8625  {
8626  RenderPoint* pP = pPolygon->createPoint();
8627  assert(pP != NULL);
8628 
8629  if (pP != NULL)
8630  {
8631  pP->setX(RelAbsVector(0.0, 0.0));
8632  pP->setY(RelAbsVector(0.0, 0.0));
8633  pP = pPolygon->createPoint();
8634  assert(pP != NULL);
8635 
8636  if (pP != NULL)
8637  {
8638  pP->setX(RelAbsVector(0.0, 0.0));
8639  pP->setY(RelAbsVector(0.0, 100.0));
8640  pP = pPolygon->createPoint();
8641  assert(pP != NULL);
8642 
8643  if (pP != NULL)
8644  {
8645  pP->setX(RelAbsVector(0.0, 100.0));
8646  pP->setY(RelAbsVector(0.0, 50.0));
8647  }
8648  else
8649  {
8650  result = false;
8651  }
8652  }
8653  else
8654  {
8655  result = false;
8656  }
8657  }
8658  else
8659  {
8660  result = false;
8661  }
8662  }
8663  else
8664  {
8665  result = false;
8666  }
8667  }
8668  else
8669  {
8670  result = false;
8671  }
8672  }
8673  else
8674  {
8675  result = false;
8676  }
8677 
8678  if (result == true)
8679  {
8680  std::string style_id = this->createUniqueId("AvtivatorStyle");
8681  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8682 
8683  if (pStyle != NULL)
8684  {
8685  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8686  assert(pStyle->getGroup() != NULL);
8687 
8688  if (pStyle->getGroup() != NULL)
8689  {
8690  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8691 
8692  if (pos != this->mColorStringMap.end())
8693  {
8694  pStyle->getGroup()->setStroke(pos->second);
8695  }
8696  else
8697  {
8698  pStyle->getGroup()->setStroke("#000000FF");
8699  }
8700 
8701  pStyle->getGroup()->setStrokeWidth(1.0);
8702  pStyle->getGroup()->setEndHead(headId);
8703  pStyle->addRole("activator");
8704  }
8705  else
8706  {
8707  result = false;
8708  }
8709  }
8710  else
8711  {
8712  result = false;
8713  }
8714  }
8715  }
8716  else
8717  {
8718  result = false;
8719  }
8720 
8721  return result;
8722 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
bool CCellDesignerImporter::createDefaultInhibitorStyle ( )
protected

Create default style for inhibitors.

Definition at line 8486 of file CCellDesignerImporter.cpp.

References createUniqueId(), mColorStringMap, mIdMap, and mpLocalRenderInfo.

Referenced by createDefaultStyles().

8487 {
8488  bool result = true;
8489 
8490  if (this->mpLocalRenderInfo != NULL)
8491  {
8492  LineEnding* pLE = this->mpLocalRenderInfo->createLineEnding();
8493  assert(pLE != NULL);
8494  BoundingBox box;
8495  Point pos(new LayoutPkgNamespaces());
8496  Dimensions dim(new LayoutPkgNamespaces());
8497  RenderGroup* pGroup = NULL;
8498  std::string headId;
8499 
8500  if (pLE != NULL)
8501  {
8502  pLE->setEnableRotationalMapping(true);
8503  headId = this->createUniqueId("inhibitor_arrow");
8504  pLE->setId(headId);
8505  this->mIdMap.insert(std::pair<std::string, const SBase*>(headId, pLE));
8506  pos = Point(new LayoutPkgNamespaces(), 0.0, -5.0);
8507  dim = Dimensions(new LayoutPkgNamespaces(), 3.0, 10.0);
8508  box.setPosition(&pos);
8509  box.setDimensions(&dim);
8510  pLE->setBoundingBox(&box);
8511  pGroup = pLE->getGroup();
8512  assert(pGroup != NULL);
8513 
8514  if (pGroup != NULL)
8515  {
8516  Rectangle* pRect = pGroup->createRectangle();
8517  assert(pRect != NULL);
8518 
8519  if (pRect != NULL)
8520  {
8521  pRect->setFillColor("#000000");
8522  pRect->setStrokeWidth(1.0);
8523  pRect->setCoordinates(RelAbsVector(0.0, 0.0), RelAbsVector(0.0, 0.0), RelAbsVector(0.0, 0.0));
8524  pRect->setSize(RelAbsVector(0.0, 100.0), RelAbsVector(0.0, 100.0));
8525  }
8526  else
8527  {
8528  result = false;
8529  }
8530  }
8531  else
8532  {
8533  result = false;
8534  }
8535  }
8536  else
8537  {
8538  result = false;
8539  }
8540 
8541  if (result == true)
8542  {
8543  std::string style_id = this->createUniqueId("InhibitorStyle");
8544  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8545 
8546  if (pStyle != NULL)
8547  {
8548  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8549  assert(pStyle->getGroup() != NULL);
8550 
8551  if (pStyle->getGroup() != NULL)
8552  {
8553  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8554 
8555  if (pos != this->mColorStringMap.end())
8556  {
8557  pStyle->getGroup()->setStroke(pos->second);
8558  }
8559  else
8560  {
8561  pStyle->getGroup()->setStroke("#000000FF");
8562  }
8563 
8564  pStyle->getGroup()->setStrokeWidth(1.0);
8565  pStyle->getGroup()->setEndHead(headId);
8566  pStyle->addRole("inhibitor");
8567  }
8568  else
8569  {
8570  result = false;
8571  }
8572  }
8573  else
8574  {
8575  result = false;
8576  }
8577  }
8578  }
8579  else
8580  {
8581  result = false;
8582  }
8583 
8584  return result;
8585 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
bool CCellDesignerImporter::createDefaultModifierStyle ( )
protected

Create default style for modifiers.

Definition at line 8338 of file CCellDesignerImporter.cpp.

References createUniqueId(), mColorStringMap, mIdMap, and mpLocalRenderInfo.

Referenced by createDefaultStyles().

8339 {
8340  bool result = true;
8341 
8342  if (this->mpLocalRenderInfo != NULL)
8343  {
8344  // we need a head for modifiers
8345  LineEnding* pLE = this->mpLocalRenderInfo->createLineEnding();
8346  std::string headId;
8347 
8348  if (pLE != NULL)
8349  {
8350  pLE->setEnableRotationalMapping(true);
8351  // set the id
8352  headId = this->createUniqueId("modifier_arrow");
8353  pLE->setId(headId);
8354  this->mIdMap.insert(std::pair<std::string, const SBase*>(headId, pLE));
8355  Point pos(new LayoutPkgNamespaces(), -5.0, -5.0);
8356  Dimensions dim = Dimensions(new LayoutPkgNamespaces(), 10.0, 10.0);
8357  BoundingBox box;
8358  box.setPosition(&pos);
8359  box.setDimensions(&dim);
8360  pLE->setBoundingBox(&box);
8361  RenderGroup* pGroup = pLE->getGroup();
8362  assert(pGroup != NULL);
8363 
8364  if (pGroup != NULL)
8365  {
8366  Polygon* pPolygon = pGroup->createPolygon();
8367  assert(pPolygon != NULL);
8368 
8369  if (pPolygon != NULL)
8370  {
8371  pPolygon->setFillColor("#000000");
8372  pPolygon->setStroke("#000000");
8373  RenderPoint* pP = pPolygon->createPoint();
8374  assert(pP != NULL);
8375 
8376  if (pP != NULL)
8377  {
8378  pP->setX(RelAbsVector(0.0, 0.0));
8379  pP->setY(RelAbsVector(0.0, 50.0));
8380  pP = pPolygon->createPoint();
8381  assert(pP != NULL);
8382 
8383  if (pP != NULL)
8384  {
8385  pP->setX(RelAbsVector(0.0, 50.0));
8386  pP->setY(RelAbsVector(0.0, 100.0));
8387  pP = pPolygon->createPoint();
8388  assert(pP != NULL);
8389 
8390  if (pP != NULL)
8391  {
8392  pP->setX(RelAbsVector(0.0, 100.0));
8393  pP->setY(RelAbsVector(0.0, 50.0));
8394  pP = pPolygon->createPoint();
8395  assert(pP != NULL);
8396 
8397  if (pP != NULL)
8398  {
8399  pP->setX(RelAbsVector(0.0, 50.0));
8400  pP->setY(RelAbsVector(0.0, 0.0));
8401  }
8402  else
8403  {
8404  result = false;
8405  }
8406  }
8407  else
8408  {
8409  result = false;
8410  }
8411  }
8412  else
8413  {
8414  result = false;
8415  }
8416  }
8417  else
8418  {
8419  result = false;
8420  }
8421  }
8422  else
8423  {
8424  result = false;
8425  }
8426  }
8427  else
8428  {
8429  result = false;
8430  }
8431  }
8432  else
8433  {
8434  result = false;
8435  }
8436 
8437  if (result == true)
8438  {
8439  std::string style_id = this->createUniqueId("ModifierStyle");
8440  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8441 
8442  if (pStyle != NULL)
8443  {
8444  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8445  assert(pStyle->getGroup() != NULL);
8446 
8447  if (pStyle->getGroup() != NULL)
8448  {
8449  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8450 
8451  if (pos != this->mColorStringMap.end())
8452  {
8453  pStyle->getGroup()->setStroke(pos->second);
8454  }
8455  else
8456  {
8457  pStyle->getGroup()->setStroke("#000000FF");
8458  }
8459 
8460  pStyle->getGroup()->setStrokeWidth(1.0);
8461  pStyle->getGroup()->setEndHead(headId);
8462  pStyle->addRole("modifier");
8463  }
8464  else
8465  {
8466  result = false;
8467  }
8468  }
8469  else
8470  {
8471  result = false;
8472  }
8473  }
8474  }
8475  else
8476  {
8477  result = false;
8478  }
8479 
8480  return result;
8481 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
bool CCellDesignerImporter::createDefaultProductStyle ( )
protected

Create default style for products.

Definition at line 8878 of file CCellDesignerImporter.cpp.

References createUniqueId(), mColorStringMap, mIdMap, and mpLocalRenderInfo.

Referenced by createDefaultStyles().

8879 {
8880  bool result = true;
8881 
8882  if (this->mpLocalRenderInfo != NULL)
8883  {
8884  // we need a head for products
8885  LineEnding* pLE = this->mpLocalRenderInfo->createLineEnding();
8886  assert(pLE != NULL);
8887  BoundingBox box;
8888  Point pos(new LayoutPkgNamespaces());
8889  Dimensions dim(new LayoutPkgNamespaces());
8890  RenderGroup* pGroup = NULL;
8891  std::string headId;
8892 
8893  if (pLE != NULL)
8894  {
8895  pLE->setEnableRotationalMapping(true);
8896  headId = this->createUniqueId("product_arrow");
8897  pLE->setId(headId);
8898  this->mIdMap.insert(std::pair<std::string, const SBase*>(headId, pLE));
8899  pos = Point(new LayoutPkgNamespaces(), -5.0, -5.0);
8900  dim = Dimensions(new LayoutPkgNamespaces(), 10.0, 10.0);
8901  box.setPosition(&pos);
8902  box.setDimensions(&dim);
8903  pLE->setBoundingBox(&box);
8904  pGroup = pLE->getGroup();
8905  assert(pGroup != NULL);
8906 
8907  if (pGroup != NULL)
8908  {
8909  Polygon* pPolygon = pGroup->createPolygon();
8910  assert(pPolygon != NULL);
8911 
8912  if (pPolygon != NULL)
8913  {
8914  pPolygon->setFillColor("#000000");
8915  RenderPoint* pP = pPolygon->createPoint();
8916  assert(pP != NULL);
8917 
8918  if (pP != NULL)
8919  {
8920  pP->setX(RelAbsVector(0.0, 0.0));
8921  pP->setY(RelAbsVector(0.0, 0.0));
8922  pP = pPolygon->createPoint();
8923  assert(pP != NULL);
8924 
8925  if (pP != NULL)
8926  {
8927  pP->setX(RelAbsVector(0.0, 0.0));
8928  pP->setY(RelAbsVector(0.0, 100.0));
8929  pP = pPolygon->createPoint();
8930  assert(pP != NULL);
8931 
8932  if (pP != NULL)
8933  {
8934  pP->setX(RelAbsVector(0.0, 100.0));
8935  pP->setY(RelAbsVector(0.0, 50.0));
8936  }
8937  else
8938  {
8939  result = false;
8940  }
8941  }
8942  else
8943  {
8944  result = false;
8945  }
8946  }
8947  else
8948  {
8949  result = false;
8950  }
8951  }
8952  else
8953  {
8954  result = false;
8955  }
8956  }
8957  else
8958  {
8959  result = false;
8960  }
8961  }
8962  else
8963  {
8964  result = false;
8965  }
8966 
8967  if (result == true)
8968  {
8969  std::string style_id = this->createUniqueId("ProductStyle");
8970  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8971 
8972  if (pStyle != NULL)
8973  {
8974  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8975  assert(pStyle->getGroup() != NULL);
8976 
8977  if (pStyle->getGroup() != NULL)
8978  {
8979  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8980 
8981  if (pos != this->mColorStringMap.end())
8982  {
8983  pStyle->getGroup()->setStroke(pos->second);
8984  }
8985  else
8986  {
8987  pStyle->getGroup()->setStroke("#000000FF");
8988  }
8989 
8990  pStyle->getGroup()->setStrokeWidth(1.0);
8991  pStyle->getGroup()->setEndHead(headId);
8992  pStyle->addRole("product");
8993  pStyle->addRole("sideproduct");
8994  }
8995  else
8996  {
8997  result = false;
8998  }
8999  }
9000  else
9001  {
9002  result = false;
9003  }
9004  }
9005  }
9006  else
9007  {
9008  result = false;
9009  }
9010 
9011  return result;
9012 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
bool CCellDesignerImporter::createDefaultReactionGlyphStyle ( )
protected

Create default style for reaction glyphs.

Definition at line 8284 of file CCellDesignerImporter.cpp.

References createUniqueId(), mColorStringMap, mIdMap, and mpLocalRenderInfo.

Referenced by createDefaultStyles().

8285 {
8286  bool result = true;
8287 
8288  if (this->mpLocalRenderInfo != NULL)
8289  {
8290  std::string style_id = this->createUniqueId("ReactionGlyphStyle");
8291  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
8292 
8293  if (pStyle != NULL)
8294  {
8295  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
8296  assert(pStyle->getGroup() != NULL);
8297 
8298  if (pStyle->getGroup() != NULL)
8299  {
8300  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
8301 
8302  if (pos != this->mColorStringMap.end())
8303  {
8304  pStyle->getGroup()->setStroke(pos->second);
8305  }
8306  else
8307  {
8308  pStyle->getGroup()->setStroke("#000000FF");
8309  }
8310 
8311  pStyle->getGroup()->setStrokeWidth(1.0);
8312  // we also use this as fallback to species reference glyphs that don't
8313  // specify a role
8314  pStyle->addType("SPECIESREFERENCEGLYPH");
8315  pStyle->addType("REACTIONGLYPH");
8316  }
8317  else
8318  {
8319  result = false;
8320  }
8321  }
8322  else
8323  {
8324  result = false;
8325  }
8326  }
8327  else
8328  {
8329  result = false;
8330  }
8331 
8332  return result;
8333 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
bool CCellDesignerImporter::createDefaultStyles ( )
protected

TODO right now, we use default styles for species reference glyphs TODO and reaction glyphs. TODO These are created here. TODO later we have to create individual styles based on the type of reaction TODO and the color set in the CellDesigner annotation.

Definition at line 8258 of file CCellDesignerImporter.cpp.

References createCatalysisStyles(), createDefaultActivatorStyle(), createDefaultInhibitorStyle(), createDefaultModifierStyle(), createDefaultProductStyle(), createDefaultReactionGlyphStyle(), createDefaultSubstrateStyle(), mModificationLinkStyleMap, and mpLocalRenderInfo.

Referenced by convertCellDesignerLayout().

8259 {
8260  bool result = true;
8261  this->mModificationLinkStyleMap.clear();
8262 
8263  if (this->mpLocalRenderInfo != NULL)
8264  {
8265  result = this->createDefaultReactionGlyphStyle();
8266  result = (result && this->createDefaultModifierStyle());
8267  result = (result && this->createDefaultInhibitorStyle());
8268  result = (result && this->createDefaultActivatorStyle());
8269  result = (result && this->createCatalysisStyles());
8270  result = (result && this->createDefaultProductStyle());
8271  result = (result && this->createDefaultSubstrateStyle());
8272  }
8273  else
8274  {
8275  result = false;
8276  }
8277 
8278  return result;
8279 }
LocalRenderInformation * mpLocalRenderInfo
std::map< MODIFICATION_LINK_TYPE, LocalStyle * > mModificationLinkStyleMap
bool CCellDesignerImporter::createDefaultSubstrateStyle ( )
protected

Create default style for substrates.

Definition at line 9017 of file CCellDesignerImporter.cpp.

References createUniqueId(), mColorStringMap, mIdMap, and mpLocalRenderInfo.

Referenced by createDefaultStyles().

9018 {
9019  bool result = true;
9020 
9021  if (this->mpLocalRenderInfo != NULL)
9022  {
9023  std::string style_id = this->createUniqueId("SubstrateStyle");
9024  LocalStyle* pStyle = this->mpLocalRenderInfo->createStyle(style_id);
9025 
9026  if (pStyle != NULL)
9027  {
9028  this->mIdMap.insert(std::pair<std::string, const SBase*>(style_id, pStyle));
9029  assert(pStyle->getGroup() != NULL);
9030 
9031  if (pStyle->getGroup() != NULL)
9032  {
9033  std::map<std::string, std::string>::const_iterator pos = this->mColorStringMap.find("#000000FF");
9034 
9035  if (pos != this->mColorStringMap.end())
9036  {
9037  pStyle->getGroup()->setStroke(pos->second);
9038  }
9039  else
9040  {
9041  pStyle->getGroup()->setStroke("#000000FF");
9042  }
9043 
9044  pStyle->getGroup()->setStrokeWidth(1.0);
9045  pStyle->addRole("substrate");
9046  pStyle->addRole("sidesubstrate");
9047  }
9048  else
9049  {
9050  result = false;
9051  }
9052  }
9053  else
9054  {
9055  result = false;
9056  }
9057  }
9058  else
9059  {
9060  result = false;
9061  } return result;
9062 }
std::string createUniqueId(const std::string &prefix)
LocalRenderInformation * mpLocalRenderInfo
std::map< std::string, const SBase * > mIdMap
std::map< std::string, std::string > mColorStringMap
template<typename ITERATOR >
static bool CCellDesignerImporter::createLineSegments ( Curve *  pCurve,
ITERATOR  start,
ITERATOR  end 
)
inlinestaticprotected

This method takes a pointer to a curve object as well as a start iterator and an end iterator which both iterate over a datastructure that contains points. For each point pair, a line segment is created and added to curve. The new curve segments are added to the end of the curve.

If no error occurs, true is returned, else false is returned.

Definition at line 1260 of file CCellDesignerImporter.h.

Referenced by convertReactionAnnotation().

1261  {
1262  bool result = true;
1263 
1264  // check if there is a curve and if there are points
1265  if (pCurve != NULL && start != end)
1266  {
1267  ITERATOR tmpEnd = end;
1268  --tmpEnd;
1269 
1270  // make sure there is more than one point
1271  if (start != tmpEnd)
1272  {
1273  LineSegment* pLS = pCurve->createLineSegment();
1274  pLS->setStart(&(*start));
1275  ++start;
1276 
1277  while (start != tmpEnd)
1278  {
1279  pLS->setEnd(&(*start));
1280  pLS = pCurve->createLineSegment();
1281  pLS->setStart(&(*start));
1282  ++start;
1283  }
1284 
1285  pLS->setEnd(&(*start));
1286  }
1287  else
1288  {
1289  result = false;
1290  }
1291  }
1292  else
1293  {
1294  result = false;
1295  }
1296 
1297  return result;
1298  }
bool CCellDesignerImporter::createOrthogonal ( const Point &  v1,
Point &  v2 
)
staticprotected

Creates a vector that is orthogonal to the given first vector. If there is a problem, false is returned.

Definition at line 10267 of file CCellDesignerImporter.cpp.

Referenced by convertReactionAnnotation(), and handleModificationLinks().

10268 {
10269  bool result = true;
10270 
10271  if (v1.x() == v1.x() &&
10272  v1.y() == v1.y() &&
10273  !(fabs(v1.x()) < 1e-20 &&
10274  fabs(v1.y()) < 1e-20)
10275  )
10276  {
10277  if (std::numeric_limits<double>::has_infinity)
10278  {
10279  double inf = std::numeric_limits<double>::infinity();
10280 
10281  if (v1.x() == inf ||
10282  v1.y() == inf ||
10283  v1.x() == -inf ||
10284  v1.y() == -inf)
10285  {
10286  result = false;
10287  }
10288  else
10289  {
10290  /*
10291  if(fabs(v1.x()) < 1e-20)
10292  {
10293  // create horizontal line
10294  v2.setX(-v1.y());
10295  v2.setY(0.0);
10296  }
10297  else if(fabs(v1.y()) < 1e-20)
10298  {
10299  // create vertical line
10300  v2.setX(0.0);
10301  v2.setY(v1.x());
10302  }
10303  else
10304  */
10305  {
10306  v2.setX(-v1.y());
10307  v2.setY(v1.x());
10308  }
10309  }
10310  }
10311  }
10312  else
10313  {
10314  result = false;
10315  }
10316 
10317  return result;
10318 }
bool CCellDesignerImporter::createPrimitive ( RenderGroup *  pGroup,
const SpeciesIdentity si,
const BoundingBox &  bounds,
const Point &  offset,
double  stroke_width,
const std::string &  stroke_color,
const std::string &  fill_color,
const std::string &  text = "" 
)
protected

Create a primitive that corresponds to the given species specific class The primitive is created in the given group object. The complete primitive is translated by the given offset.

If creation of the primitive fails, false is returned.

Create a primitive that corresponds to the given class The promitive is created in the given group object. The complete primitive is translated by the given offset.

If creation of the primitive fails, false is returned.

Definition at line 1038 of file CCellDesignerImporter.cpp.

References ANTISENSE_RNA_CLASS, CHANNEL_CLASS, COMPLEX_CLASS, createProteinModification(), DEGRADED_CLASS, DRUG_CLASS, GENE_CLASS, ION_CLASS, SpeciesState::mModifications, SpeciesIdentity::mNameOrReference, mProteinInformationMap, SpeciesIdentity::mSpeciesClass, SpeciesIdentity::mState, PHENOTYPE_CLASS, PROTEIN_CLASS, RECEPTOR_CLASS, RNA_CLASS, SIMPLE_MOLECULE_CLASS, TRUNCATED_CLASS, UNDEFINED_CLASS, and UNKNOWN_CLASS.

Referenced by createSpeciesStyles().

1047 {
1048  bool result = true;
1049 
1050  // maybe we should rule out all the SQUARE classes and the OVAL class
1051  // since they are probably only used for compartments
1052  // On the other hand, maybe we can use this method to create the primitives
1053  // for the compartments as well
1054  if (pGroup != NULL &&
1056  )
1057  {
1058  // if it is a protein, find the specific type
1060 
1061  if (si.mSpeciesClass == PROTEIN_CLASS && !si.mNameOrReference.empty())
1062  {
1063  std::map<std::string, Protein>::const_iterator pos = this->mProteinInformationMap.find(si.mNameOrReference);
1064 
1065  if (pos != this->mProteinInformationMap.end())
1066  {
1067  cl = pos->second.mType;
1068  }
1069  }
1070  else
1071  {
1072  cl = si.mSpeciesClass;
1073  }
1074 
1075  switch (cl)
1076  {
1077  case ION_CLASS:
1078  {
1079  double width = bounds.getDimensions()->getWidth();
1080  double height = bounds.getDimensions()->getHeight();
1081  double shortside = (width < height) ? width : height;
1082  Ellipse* pEllipse = pGroup->createEllipse();
1083  assert(pEllipse != NULL);
1084 
1085  if (pEllipse != NULL)
1086  {
1087  pEllipse->setCX(RelAbsVector(offset.x() + bounds.getPosition()->x() + width * 0.5, 0.0));
1088  pEllipse->setCY(RelAbsVector(offset.y() + bounds.getPosition()->y() + height * 0.5, 0.0));
1089  pEllipse->setRX(RelAbsVector(shortside * 0.5, 0.0));
1090  pEllipse->setRY(RelAbsVector(shortside * 0.5, 0.0));
1091  pEllipse->setStrokeWidth(stroke_width);
1092  pEllipse->setStroke(stroke_color);
1093  pEllipse->setFillColor(fill_color);
1094  }
1095  else
1096  {
1097  result = false;
1098  }
1099  }
1100  break;
1101 
1102  case UNKNOWN_CLASS:
1103  // unknown has no edge
1104  {
1105  Ellipse* pEllipse = pGroup->createEllipse();
1106  assert(pEllipse != NULL);
1107 
1108  if (pEllipse != NULL)
1109  {
1110  double width = bounds.getDimensions()->getWidth();
1111  double height = bounds.getDimensions()->getHeight();
1112  pEllipse->setCX(RelAbsVector(offset.x() + bounds.getPosition()->x() + width * 0.5, 0.0));
1113  pEllipse->setCY(RelAbsVector(offset.y() + bounds.getPosition()->y() + height * 0.5, 0.0));
1114  pEllipse->setRX(RelAbsVector(bounds.getDimensions()->getWidth() * 0.5, 0.0));
1115  pEllipse->setRY(RelAbsVector(bounds.getDimensions()->getHeight() * 0.5, 0.0));
1116  pEllipse->setFillColor(fill_color);
1117  }
1118  else
1119  {
1120  result = false;
1121  }
1122  }
1123  break;
1124 
1125  case DRUG_CLASS:
1126  // actually drug is a rectangle with rounded sides
1127  {
1128  // create two circles with radius height/2 at 10%,50% and 90%,50%
1129  // both have a fill and a black edge with stroke width 1
1130  double width = bounds.getDimensions()->getWidth();
1131  double height = bounds.getDimensions()->getHeight();
1132 
1133  // outer rectangle
1134  Rectangle* pRectangle = pGroup->createRectangle();
1135  assert(pRectangle != NULL);
1136 
1137  if (pRectangle != NULL)
1138  {
1139  pRectangle->setX(RelAbsVector(offset.x() + bounds.getPosition()->x(), 0.0));
1140  pRectangle->setY(RelAbsVector(offset.y() + bounds.getPosition()->y(), 0.0));
1141  pRectangle->setRadiusX(RelAbsVector(height * 0.5, 0.0));
1142  pRectangle->setRadiusY(RelAbsVector(height * 0.5, 0.0));
1143  pRectangle->setWidth(RelAbsVector(width, 0.0));
1144  pRectangle->setHeight(RelAbsVector(height, 0.0));
1145 
1146  pRectangle->setStrokeWidth(stroke_width);
1147  pRectangle->setStroke(stroke_color);
1148  pRectangle->setFillColor(fill_color);
1149  }
1150  else
1151  {
1152  result = false;
1153  }
1154 
1155  // inner rectangle
1156  pRectangle = pGroup->createRectangle();
1157  assert(pRectangle != NULL);
1158 
1159  if (pRectangle != NULL)
1160  {
1161  pRectangle->setX(RelAbsVector(offset.x() + bounds.getPosition()->x() + 5, 0.0));
1162  pRectangle->setY(RelAbsVector(offset.y() + bounds.getPosition()->y() + 5, 0.0));
1163  pRectangle->setRadiusX(RelAbsVector(height * 0.5 - 5, 0.0));
1164  pRectangle->setRadiusY(RelAbsVector(height * 0.5 - 5, 0.0));
1165  pRectangle->setWidth(RelAbsVector(width - 10, 0.0));
1166  pRectangle->setHeight(RelAbsVector(height - 10, 0.0));
1167 
1168  pRectangle->setStrokeWidth(stroke_width);
1169  pRectangle->setStroke(stroke_color);
1170  pRectangle->setFillColor(fill_color);
1171  }
1172  else
1173  {
1174  result = false;
1175  }
1176  }
1177  break;
1178 
1179  case SIMPLE_MOLECULE_CLASS:
1180  {
1181  Ellipse* pEllipse = pGroup->createEllipse();
1182  assert(pEllipse != NULL);
1183 
1184  if (pEllipse != NULL)
1185  {
1186  double width = bounds.getDimensions()->getWidth();
1187  double height = bounds.getDimensions()->getHeight();
1188  pEllipse->setCX(RelAbsVector(offset.x() + bounds.getPosition()->x() + width * 0.5, 0.0));
1189  pEllipse->setCY(RelAbsVector(offset.y() + bounds.getPosition()->y() + height * 0.5, 0.0));
1190  pEllipse->setRX(RelAbsVector(bounds.getDimensions()->getWidth() * 0.5, 0.0));
1191  pEllipse->setRY(RelAbsVector(bounds.getDimensions()->getHeight() * 0.5, 0.0));
1192  pEllipse->setStrokeWidth(stroke_width);
1193  pEllipse->setStroke(stroke_color);
1194  pEllipse->setFillColor(fill_color);
1195  }
1196  else
1197  {
1198  result = false;
1199  }
1200  }
1201  break;
1202 
1203  case DEGRADED_CLASS:
1204  {
1205  Ellipse* pEllipse = pGroup->createEllipse();
1206  assert(pEllipse != NULL);
1207 
1208  if (pEllipse != NULL)
1209  {
1210  double width = bounds.getDimensions()->getWidth();
1211  double height = bounds.getDimensions()->getHeight();
1212  pEllipse->setCX(RelAbsVector(offset.x() + bounds.getPosition()->x() + width * 0.5, 0.0));
1213  pEllipse->setCY(RelAbsVector(offset.y() + bounds.getPosition()->y() + height * 0.5, 0.0));
1214  double short_side = (width > height) ? height : width;
1215  pEllipse->setRX(RelAbsVector(short_side * 0.35, 0.0));
1216  pEllipse->setRY(RelAbsVector(short_side * 0.35, 0.0));
1217  pEllipse->setStrokeWidth(stroke_width);
1218  pEllipse->setStroke(stroke_color);
1219  pEllipse->setFillColor(fill_color);
1220  RenderCurve* pCurve = pGroup->createCurve();
1221  assert(pCurve != NULL);
1222 
1223  if (pCurve != NULL)
1224  {
1225  pCurve->setStrokeWidth(2.0);
1226  pCurve->setStroke("#000000FF");
1227  RenderPoint* pP = pCurve->createPoint();
1228  assert(pP != NULL);
1229 
1230  if (pP != NULL)
1231  {
1232  pP->setX((short_side - width) * 0.5);
1233  pP->setY((short_side - height) * 0.5 + short_side);
1234  pP = pCurve->createPoint();
1235  assert(pP != NULL);
1236 
1237  if (pP != NULL)
1238  {
1239  pP->setX((short_side - width) * 0.5 + short_side);
1240  pP->setY((short_side - height) * 0.5);
1241  }
1242  else
1243  {
1244  result = false;
1245  }
1246  }
1247  else
1248  {
1249  result = false;
1250  }
1251  }
1252  else
1253  {
1254  result = false;
1255  }
1256  }
1257  else
1258  {
1259  result = false;
1260  }
1261  }
1262  break;
1263 
1264  case TRUNCATED_CLASS:
1265  {
1266  // TODO the left corners should be rounded, but for now this is close enough
1267  double width = bounds.getDimensions()->getWidth();
1268  double height = bounds.getDimensions()->getHeight();
1269  // we take a fixed radius for the rounded corners
1270  double radius = 10.0;
1271  Polygon* pPoly = pGroup->createPolygon();
1272  assert(pPoly != NULL);
1273 
1274  if (pPoly != NULL)
1275  {
1276  pPoly->setStrokeWidth(stroke_width);
1277  pPoly->setStroke(stroke_color);
1278  pPoly->setFillColor(fill_color);
1279  RenderPoint* pP = pPoly->createPoint();
1280  RenderCubicBezier* pCB = NULL;
1281 
1282  if (pP != NULL)
1283  {
1284  pP->setX(RelAbsVector(radius, 0.0));
1285  pP->setY(RelAbsVector(0.0, 0.0));
1286  }
1287  else
1288  {
1289  result = false;
1290  }
1291 
1292  if (result == true)
1293  {
1294  pP = pPoly->createPoint();
1295 
1296  if (pP != NULL)
1297  {
1298  pP->setX(RelAbsVector(width, 0.0));
1299  pP->setY(RelAbsVector(0.0, 0.0));
1300  }
1301  else
1302  {
1303  result = false;
1304  }
1305  }
1306 
1307  if (result == true)
1308  {
1309  pP = pPoly->createPoint();
1310 
1311  if (pP != NULL)
1312  {
1313  pP->setX(RelAbsVector(width, 0.0));
1314  pP->setY(RelAbsVector(0.8 * height, 0.0));
1315  }
1316  else
1317  {
1318  result = false;
1319  }
1320  }
1321 
1322  if (result == true)
1323  {
1324  pP = pPoly->createPoint();
1325 
1326  if (pP != NULL)
1327  {
1328  pP->setX(RelAbsVector(0.8 * width, 0.0));
1329  pP->setY(RelAbsVector(0.5 * height, 0.0));
1330  }
1331  else
1332  {
1333  result = false;
1334  }
1335  }
1336 
1337  if (result == true)
1338  {
1339  pP = pPoly->createPoint();
1340 
1341  if (pP != NULL)
1342  {
1343  pP->setX(RelAbsVector(0.8 * width, 0.0));
1344  pP->setY(RelAbsVector(height, 0.0));
1345  }
1346  else
1347  {
1348  result = false;
1349  }
1350  }
1351 
1352  if (result == true)
1353  {
1354  pP = pPoly->createPoint();
1355 
1356  if (pP != NULL)
1357  {
1358  pP->setX(RelAbsVector(radius, 0.0));
1359  pP->setY(RelAbsVector(height, 0.0));
1360  }
1361  else
1362  {
1363  result = false;
1364  }
1365  }
1366 
1367  if (result == true)
1368  {
1369  pCB = pPoly->createCubicBezier();
1370 
1371  if (pCB != NULL)
1372  {
1373  pCB->setBasePoint1_X(RelAbsVector(0.0, 0.0));
1374  pCB->setBasePoint1_Y(RelAbsVector(height, 0.0));
1375  pCB->setBasePoint2_X(RelAbsVector(0.0, 0.0));
1376  pCB->setBasePoint2_Y(RelAbsVector(height, 0.0));
1377  pCB->setX(RelAbsVector(0.0, 0.0));
1378  pCB->setY(RelAbsVector(height - radius, 0.0));
1379  }
1380  else
1381  {
1382  result = false;
1383  }
1384  }
1385 
1386  if (result == true)
1387  {
1388  pP = pPoly->createPoint();
1389 
1390  if (pP != NULL)
1391  {
1392  pP->setX(RelAbsVector(0.0, 0.0));
1393  pP->setY(RelAbsVector(radius, 0.0));
1394  }
1395  else
1396  {
1397  result = false;
1398  }
1399  }
1400 
1401  if (result == true)
1402  {
1403  pCB = pPoly->createCubicBezier();
1404 
1405  if (pCB != NULL)
1406  {
1407  pCB->setBasePoint1_X(RelAbsVector(0.0, 0.0));
1408  pCB->setBasePoint1_Y(RelAbsVector(0.0, 0.0));
1409  pCB->setBasePoint2_X(RelAbsVector(0.0, 0.0));
1410  pCB->setBasePoint2_Y(RelAbsVector(0.0, 0.0));
1411  pCB->setX(RelAbsVector(radius, 0.0));
1412  pCB->setY(RelAbsVector(0.0, 0.0));
1413  }
1414  else
1415  {
1416  result = false;
1417  }
1418  }
1419  }
1420  else
1421  {
1422  result = false;
1423  }
1424  }
1425  break;
1426 
1427  case PROTEIN_CLASS:
1428  // make a rectangle with rounded edges
1429  {
1430  Rectangle* pRect = pGroup->createRectangle();
1431  assert(pRect != NULL);
1432 
1433  if (pRect != NULL)
1434  {
1435  pRect->setX(RelAbsVector(offset.x() + bounds.getPosition()->x(), 0.0));
1436  pRect->setY(RelAbsVector(offset.y() + bounds.getPosition()->y(), 0.0));
1437  pRect->setRadiusX(RelAbsVector(0.0, 10.0));
1438  pRect->setRadiusY(RelAbsVector(0.0, 10.0));
1439  pRect->setWidth(RelAbsVector(bounds.getDimensions()->getWidth(), 0.0));
1440  pRect->setHeight(RelAbsVector(bounds.getDimensions()->getHeight(), 0.0));
1441  pRect->setStrokeWidth(stroke_width);
1442  pRect->setStroke(stroke_color);
1443  pRect->setFillColor(fill_color);
1444  }
1445 
1446  else
1447  {
1448  result = false;
1449  }
1450 
1451  if (result == true)
1452  {
1453  // handle modifications
1454  std::vector<SpeciesModification>::const_iterator it = si.mState.mModifications.begin(), endit = si.mState.mModifications.end();
1455 
1456  while (it != endit)
1457  {
1458  result = this->createProteinModification(pGroup, *it, bounds, stroke_color);
1459  assert(result == true);
1460  ++it;
1461  }
1462  }
1463  }
1464  break;
1465 
1466  case PHENOTYPE_CLASS:
1467  {
1468  // we assume the width is larger
1469  Polygon* pPoly = pGroup->createPolygon();
1470  assert(pPoly != NULL);
1471 
1472  if (pPoly != NULL)
1473  {
1474  pPoly->setStrokeWidth(stroke_width);
1475  pPoly->setStroke(stroke_color);
1476  pPoly->setFillColor(fill_color);
1477  RenderPoint* pP = pPoly->createPoint();
1478 
1479  if (pP != NULL)
1480  {
1481  pP->setY(RelAbsVector(0.0, 0.0));
1482  pP->setY(RelAbsVector(0.0, 50.0));
1483  }
1484  else
1485  {
1486  result = false;
1487  }
1488 
1489  if (result == true)
1490  {
1491  pP = pPoly->createPoint();
1492 
1493  if (pP != NULL)
1494  {
1495  pP->setX(RelAbsVector(0.0, 15.0));
1496  pP->setY(RelAbsVector(0.0, 0.0));
1497  }
1498  else
1499  {
1500  result = false;
1501  }
1502  }
1503 
1504  if (result == true)
1505  {
1506  pP = pPoly->createPoint();
1507 
1508  if (pP != NULL)
1509  {
1510  pP->setX(RelAbsVector(0.0, 85.0));
1511  pP->setY(RelAbsVector(0.0, 0.0));
1512  }
1513  else
1514  {
1515  result = false;
1516  }
1517  }
1518 
1519  if (result == true)
1520  {
1521  pP = pPoly->createPoint();
1522 
1523  if (pP != NULL)
1524  {
1525  pP->setX(RelAbsVector(0.0, 100.0));
1526  pP->setY(RelAbsVector(0.0, 50.0));
1527  }
1528  else
1529  {
1530  result = false;
1531  }
1532  }
1533 
1534  if (result == true)
1535  {
1536  pP = pPoly->createPoint();
1537 
1538  if (pP != NULL)
1539  {
1540  pP->setX(RelAbsVector(0.0, 85.0));
1541  pP->setY(RelAbsVector(0.0, 100.0));
1542  }
1543  else
1544  {
1545  result = false;
1546  }
1547  }
1548 
1549  if (result == true)
1550  {
1551  pP = pPoly->createPoint();
1552 
1553  if (pP != NULL)
1554  {
1555  pP->setX(RelAbsVector(0.0, 15.0));
1556  pP->setY(RelAbsVector(0.0, 100.0));
1557  }
1558  else
1559  {
1560  result = false;
1561  }
1562  }
1563  }
1564  else
1565  {
1566  result = false;
1567  }
1568  }
1569  break;
1570 
1571  case RNA_CLASS:
1572  // make a trapezoid
1573  {
1574  // we assume the width is larger
1575  Polygon* pPoly = pGroup->createPolygon();
1576  assert(pPoly != NULL);
1577 
1578  if (pPoly != NULL)
1579  {
1580  pPoly->setStrokeWidth(stroke_width);
1581  pPoly->setStroke(stroke_color);
1582  pPoly->setFillColor(fill_color);
1583  RenderPoint* pP = pPoly->createPoint();
1584 
1585  if (pP != NULL)
1586  {
1587  pP->setX(RelAbsVector(0.0, 20.0));
1588  pP->setY(RelAbsVector(0.0, 0.0));
1589  }
1590  else
1591  {
1592  result = false;
1593  }
1594 
1595  if (result == true)
1596  {
1597  pP = pPoly->createPoint();
1598 
1599  if (pP != NULL)
1600  {
1601  pP->setX(RelAbsVector(0.0, 100.0));
1602  pP->setY(RelAbsVector(0.0, 0.0));
1603  }
1604  else
1605  {
1606  result = false;
1607  }
1608  }
1609 
1610  if (result == true)
1611  {
1612  pP = pPoly->createPoint();
1613 
1614  if (pP != NULL)
1615  {
1616  pP->setX(RelAbsVector(0.0, 80.0));
1617  pP->setY(RelAbsVector(0.0, 100.0));
1618  }
1619  else
1620  {
1621  result = false;
1622  }
1623  }
1624 
1625  if (result == true)
1626  {
1627  pP = pPoly->createPoint();
1628 
1629  if (pP != NULL)
1630  {
1631  pP->setX(RelAbsVector(0.0, 0.0));
1632  pP->setY(RelAbsVector(0.0, 100.0));
1633  }
1634  else
1635  {
1636  result = false;
1637  }
1638  }
1639  }
1640  else
1641  {
1642  result = false;
1643  }
1644  }
1645  break;
1646 
1647  case ANTISENSE_RNA_CLASS:
1648  // make a trapzoid
1649  {
1650  // we assume the width is larger
1651  Polygon* pPoly = pGroup->createPolygon();
1652  assert(pPoly != NULL);
1653 
1654  if (pPoly != NULL)
1655  {
1656  pPoly->setStrokeWidth(stroke_width);
1657  pPoly->setStroke(stroke_color);
1658  pPoly->setFillColor(fill_color);
1659  RenderPoint* pP = pPoly->createPoint();
1660 
1661  if (pP != NULL)
1662  {
1663  pP->setY(RelAbsVector(0.0, 0.0));
1664  pP->setY(RelAbsVector(0.0, 0.0));
1665  }
1666  else
1667  {
1668  result = false;
1669  }
1670 
1671  if (result == true)
1672  {
1673  pP = pPoly->createPoint();
1674 
1675  if (pP != NULL)
1676  {
1677  pP->setX(RelAbsVector(0.0, 80.0));
1678  pP->setY(RelAbsVector(0.0, 0.0));
1679  }
1680  else
1681  {
1682  result = false;
1683  }
1684  }
1685 
1686  if (result == true)
1687  {
1688  pP = pPoly->createPoint();
1689 
1690  if (pP != NULL)
1691  {
1692  pP->setX(RelAbsVector(0.0, 100.0));
1693  pP->setY(RelAbsVector(0.0, 100.0));
1694  }
1695  else
1696  {
1697  result = false;
1698  }
1699  }
1700 
1701  if (result == true)
1702  {
1703  pP = pPoly->createPoint();
1704 
1705  if (pP != NULL)
1706  {
1707  pP->setX(RelAbsVector(0.0, 20.0));
1708  pP->setY(RelAbsVector(0.0, 100.0));
1709  }
1710  else
1711  {
1712  result = false;
1713  }
1714  }
1715  }
1716  else
1717  {
1718  result = false;
1719  }
1720  }
1721  break;
1722 
1723  case COMPLEX_CLASS:
1724  // rectangle with cut edges
1725  {
1726  double width = bounds.getDimensions()->getWidth();
1727  double height = bounds.getDimensions()->getHeight();
1728  // we assume the width is larger
1729  double ratio = height / width;
1730  Polygon* pPoly = pGroup->createPolygon();
1731  assert(pPoly != NULL);
1732 
1733  if (pPoly != NULL)
1734  {
1735  pPoly->setStrokeWidth(stroke_width);
1736  pPoly->setStroke(stroke_color);
1737  pPoly->setFillColor(fill_color);
1738  RenderPoint* pP = pPoly->createPoint();
1739 
1740  if (pP != NULL)
1741  {
1742  pP->setX(RelAbsVector(0.0, 10.0 * ratio));
1743  pP->setY(RelAbsVector(0.0, 0.0));
1744  }
1745  else
1746  {
1747  result = false;
1748  }
1749 
1750  if (result == true)
1751  {
1752  pP = pPoly->createPoint();
1753 
1754  if (pP != NULL)
1755  {
1756  pP->setX(RelAbsVector(0.0, 100.0 - 10.0 * ratio));
1757  pP->setY(RelAbsVector(0.0, 0.0));
1758  }
1759  else
1760  {
1761  result = false;
1762  }
1763  }
1764 
1765  if (result == true)
1766  {
1767  pP = pPoly->createPoint();
1768 
1769  if (pP != NULL)
1770  {
1771  pP->setX(RelAbsVector(0.0, 100.0));
1772  pP->setY(RelAbsVector(0.0, 10.0));
1773  }
1774  else
1775  {
1776  result = false;
1777  }
1778  }
1779 
1780  if (result == true)
1781  {
1782  pP = pPoly->createPoint();
1783 
1784  if (pP != NULL)
1785  {
1786  pP->setX(RelAbsVector(0.0, 100.0));
1787  pP->setY(RelAbsVector(0.0, 90.0));
1788  }
1789  else
1790  {
1791  result = false;
1792  }
1793  }
1794 
1795  if (result == true)
1796  {
1797  pP = pPoly->createPoint();
1798 
1799  if (pP != NULL)
1800  {
1801  pP->setX(RelAbsVector(0.0, 100.0 - 10.0 * ratio));
1802  pP->setY(RelAbsVector(0.0, 100.0));
1803  }
1804  else
1805  {
1806  result = false;
1807  }
1808  }
1809 
1810  if (result == true)
1811  {
1812  pP = pPoly->createPoint();
1813 
1814  if (pP != NULL)
1815  {
1816  pP->setX(RelAbsVector(0.0, 10.0 * ratio));
1817  pP->setY(RelAbsVector(0.0, 100.0));
1818  }
1819  else
1820  {
1821  result = false;
1822  }
1823  }
1824 
1825  if (result == true)
1826  {
1827  pP = pPoly->createPoint();
1828 
1829  if (pP != NULL)
1830  {
1831  pP->setX(RelAbsVector(0.0, 0.0));
1832  pP->setY(RelAbsVector(0.0, 90.0));
1833  }
1834  else
1835  {
1836  result = false;
1837  }
1838  }
1839 
1840  if (result == true)
1841  {
1842  pP = pPoly->createPoint();
1843 
1844  if (pP != NULL)
1845  {
1846  pP->setX(RelAbsVector(0.0, 0.0));
1847  pP->setY(RelAbsVector(0.0, 10.0));
1848  }
1849  else
1850  {
1851  result = false;
1852  }
1853  }
1854  }
1855  else
1856  {
1857  result = false;
1858  }
1859  }
1860  break;
1861 
1862  case RECEPTOR_CLASS:
1863  {
1864  // we assume the width is larger
1865  Polygon* pPoly = pGroup->createPolygon();
1866  assert(pPoly != NULL);
1867 
1868  if (pPoly != NULL)
1869  {
1870  pPoly->setStrokeWidth(stroke_width);
1871  pPoly->setStroke(stroke_color);
1872  pPoly->setFillColor(fill_color);
1873  RenderPoint* pP = pPoly->createPoint();
1874 
1875  if (pP != NULL)
1876  {
1877  pP->setY(RelAbsVector(0.0, 0.0));
1878  pP->setY(RelAbsVector(0.0, 0.0));
1879  }
1880  else
1881  {
1882  result = false;
1883  }
1884 
1885  if (result == true)
1886  {
1887  pP = pPoly->createPoint();
1888 
1889  if (pP != NULL)
1890  {
1891  pP->setX(RelAbsVector(0.0, 50.0));
1892  pP->setY(RelAbsVector(0.0, 15.0));
1893  }
1894  else
1895  {
1896  result = false;
1897  }
1898  }
1899 
1900  if (result == true)
1901  {
1902  pP = pPoly->createPoint();
1903 
1904  if (pP != NULL)
1905  {
1906  pP->setX(RelAbsVector(0.0, 100.0));
1907  pP->setY(RelAbsVector(0.0, 0.0));
1908  }
1909  else
1910  {
1911  result = false;
1912  }
1913  }
1914 
1915  if (result == true)
1916  {
1917  pP = pPoly->createPoint();
1918 
1919  if (pP != NULL)
1920  {
1921  pP->setX(RelAbsVector(0.0, 100.0));
1922  pP->setY(RelAbsVector(0.0, 85.0));
1923  }
1924  else
1925  {
1926  result = false;
1927  }
1928  }
1929 
1930  if (result == true)
1931  {
1932  pP = pPoly->createPoint();
1933 
1934  if (pP != NULL)
1935  {
1936  pP->setX(RelAbsVector(0.0, 50.0));
1937  pP->setY(RelAbsVector(0.0, 100.0));
1938  }
1939  else
1940  {
1941  result = false;
1942  }
1943  }
1944 
1945  if (result == true)
1946  {
1947  pP = pPoly->createPoint();
1948 
1949  if (pP != NULL)
1950  {
1951  pP->setX(RelAbsVector(0.0, 0.0));
1952  pP->setY(RelAbsVector(0.0, 85.0));
1953  }
1954  else
1955  {
1956  result = false;
1957  }
1958  }
1959  }
1960  else
1961  {
1962  result = false;
1963  }
1964  }
1965  break;
1966 
1967  case CHANNEL_CLASS:
1968  // make two rectangles with rounded corners
1969  {
1970  double width = bounds.getDimensions()->getWidth();
1971  double height = bounds.getDimensions()->getHeight();
1972  Rectangle* pRect = pGroup->createRectangle();
1973  assert(pRect != NULL);
1974 
1975  if (pRect != NULL)
1976  {
1977  pRect->setX(RelAbsVector(offset.x() + bounds.getPosition()->x(), 0.0));
1978  pRect->setY(RelAbsVector(offset.y() + bounds.getPosition()->y(), 0.0));
1979  pRect->setRadiusX(RelAbsVector(6.0, 0.0));
1980  pRect->setRadiusY(RelAbsVector(6.0, 0.0));
1981  pRect->setWidth(RelAbsVector(width * 0.75, 0.0));
1982  pRect->setHeight(RelAbsVector(height, 0.0));
1983  pRect->setStrokeWidth(stroke_width);
1984  pRect->setStroke(stroke_color);
1985  pRect->setFillColor(fill_color);
1986  }
1987  else
1988  {
1989  result = false;
1990  }
1991 
1992  pRect = pGroup->createRectangle();
1993  assert(pRect != NULL);
1994 
1995  if (pRect != NULL)
1996  {
1997  pRect->setX(RelAbsVector(offset.x() + bounds.getPosition()->x() + width * 0.75, 0.0));
1998  pRect->setY(RelAbsVector(offset.y() + bounds.getPosition()->y(), 0.0));
1999  pRect->setWidth(RelAbsVector(width * 0.25, 0.0));
2000  pRect->setHeight(RelAbsVector(height, 0.0));
2001  pRect->setRadiusX(RelAbsVector(6.0, 0.0));
2002  pRect->setRadiusY(RelAbsVector(6.0, 0.0));
2003  pRect->setStrokeWidth(stroke_width);
2004  pRect->setStroke(stroke_color);
2005  pRect->setFillColor(fill_color);
2006  }
2007  else
2008  {
2009  result = false;
2010  }
2011  }
2012  break;
2013 
2014  case GENE_CLASS:
2015  {
2016  Rectangle* pRect = pGroup->createRectangle();
2017  assert(pRect != NULL);
2018 
2019  if (pRect != NULL)
2020  {
2021  pRect->setX(RelAbsVector(offset.x() + bounds.getPosition()->x(), 0.0));
2022  pRect->setY(RelAbsVector(offset.y() + bounds.getPosition()->y(), 0.0));
2023  pRect->setWidth(RelAbsVector(bounds.getDimensions()->getWidth(), 0.0));
2024  pRect->setHeight(RelAbsVector(bounds.getDimensions()->getHeight(), 0.0));
2025  pRect->setStrokeWidth(stroke_width);
2026  pRect->setStroke(stroke_color);
2027  pRect->setFillColor(fill_color);
2028  }
2029  else
2030  {
2031  result = false;
2032  }
2033  }
2034  break;
2035 
2036  default:
2037  result = false;
2038  break;
2039  }
2040 
2041  // create the text element
2042  if (result == true && !text.empty())
2043  {
2044  // place a text element in the box
2045  // specified by bounds
2046  Text* pText = pGroup->createText();
2047  assert(pText != NULL);
2048 
2049  if (pText != NULL)
2050  {
2051  pText->setTextAnchor(Text::ANCHOR_MIDDLE);
2052  pText->setVTextAnchor(Text::ANCHOR_MIDDLE);
2053  // middle of the box
2054  pText->setX(RelAbsVector(bounds.getPosition()->x() + offset.x() + 0.5 * bounds.getDimensions()->getWidth(), 0.0));
2055  // middle of the box
2056  pText->setY(RelAbsVector(bounds.getPosition()->y() + offset.y() + 0.5 * bounds.getDimensions()->getHeight(), 0.0));
2057  pText->setText(text);
2058  // TODO we need the font size and the font family
2059  // TODO for now we use a default
2060  pText->setFontFamily("serif");
2061  pText->setFontSize(RelAbsVector(10.0, 0.0));
2062  pText->setStroke("#000000");
2063  }
2064  else
2065  {
2066  result = false;
2067  }
2068  }
2069  }
2070  else
2071  {
2072  result = false;
2073  }
2074 
2075  return result;
2076 }
bool createProteinModification(RenderGroup *pGroup, const SpeciesModification &smod, const BoundingBox &bounds, const std::string &stroke_color)
SPECIES_CLASS mSpeciesClass
std::string mNameOrReference
std::vector< SpeciesModification > mModifications
std::map< std::string, Protein > mProteinInformationMap
bool CCellDesignerImporter::createProteinModification ( RenderGroup *  pGroup,
const SpeciesModification smod,
const BoundingBox &  bounds,
const std::string &  stroke_color 
)
protected

Takes a protein modification description and creates the corresponding primitive.

Definition at line 2081 of file CCellDesignerImporter.cpp.

References ACETYLATED_MOD_TYPE, DONTCARE_MOD_TYPE, GLYCOSYLATED_MOD_TYPE, HYDROXYLATED_MOD_TYPE, METHYLATED_MOD_TYPE, SpeciesModification::mType, MYRISTOYLATED_MOD_TYPE, PALMYTOYLATED_MOD_TYPE, PHOSPHORYLATED_MOD_TYPE, PRENYLATED_MOD_TYPE, PROTONATED_MOD_TYPE, SUFLATED_MOD_TYPE, UBIQUITINATED_MOD_TYPE, and UNKNOWN_MOD_TYPE.

Referenced by createPrimitive().

2086 {
2087  // TODO this method will place all modification in exactly the same spot, so
2088  // TODO if a protein has several modifications, they will sit on top of each other
2089  // TODO One would have to play around with CellDesigner to see how it is done there
2090  // TODO because there does not seem to be any stored information on where the
2091  // TODO modification symbol is supposed to be placed
2092  bool result = true;
2093  // this is a filled circle
2094  // the fill color is white
2095  Ellipse* pEllipse = pGroup->createEllipse();
2096  assert(pEllipse != NULL);
2097 
2098  if (pEllipse != NULL)
2099  {
2100  pEllipse->setCX(RelAbsVector(0.0, 0.0));
2101  pEllipse->setCY(RelAbsVector(0.0, 0.0));
2102  pEllipse->setRX(RelAbsVector(7.0, 0.0));
2103  pEllipse->setRY(RelAbsVector(7.0, 0.0));
2104  pEllipse->setStrokeWidth(1.0);
2105  pEllipse->setStroke(stroke_color);
2106  pEllipse->setFillColor("#FFFFFFFF");
2107  // depending on the type of modification, the string displayed in the circle varies
2108  std::string mod_string("");
2109 
2110  switch (smod.mType)
2111  {
2113  mod_string = "P";
2114  break;
2115 
2116  case ACETYLATED_MOD_TYPE:
2117  mod_string = "Ac";
2118  break;
2119 
2121  mod_string = "Ub";
2122  break;
2123 
2124  case METHYLATED_MOD_TYPE:
2125  mod_string = "Me";
2126  break;
2127 
2128  case HYDROXYLATED_MOD_TYPE:
2129  mod_string = "OH";
2130  break;
2131 
2132  case DONTCARE_MOD_TYPE:
2133  mod_string = "*";
2134  break;
2135 
2136  case UNKNOWN_MOD_TYPE:
2137  mod_string = "?";
2138  break;
2139 
2140  case GLYCOSYLATED_MOD_TYPE:
2141  mod_string = "G";
2142  break;
2143 
2145  mod_string = "My";
2146  break;
2147 
2149  mod_string = "Pa";
2150  break;
2151 
2152  case PRENYLATED_MOD_TYPE:
2153  mod_string = "Pr";
2154  break;
2155 
2156  case PROTONATED_MOD_TYPE:
2157  mod_string = "H";
2158  break;
2159 
2160  case SUFLATED_MOD_TYPE:
2161  mod_string = "S";
2162  break;
2163 
2164  default:
2165  break;
2166  }
2167 
2168  Text* pText = pGroup->createText();
2169  pText->setTextAnchor(Text::ANCHOR_MIDDLE);
2170  pText->setVTextAnchor(Text::ANCHOR_MIDDLE);
2171  pText->setX(RelAbsVector(0.0, 0.0));
2172  pText->setY(RelAbsVector(0.0, 0.0));
2173  pText->setText(mod_string);
2174  pText->setFontFamily("serif");
2175  pText->setFontSize(RelAbsVector(8.0, 0.0));
2176  pText->setStroke("#000000FF");
2177  }
2178  else
2179  {
2180  result = false;
2181  }
2182 
2183  return result;
2184 }
SPECIES_MODIFICATION_TYPE mType
bool CCellDesignerImporter::createSpeciesGlyph ( const SpeciesAlias sa)
protected

Creates the species glyph from the given SpeciesAliases structure.

Definition at line 728 of file CCellDesignerImporter.cpp.

References addDependency(), createUniqueId(), SpeciesAlias::mBounds, mCDBounds, mCDIdToLayoutElement, SpeciesAlias::mComplexSpeciesAlias, SpeciesAlias::mId, mIdMap, mModelIdToLayoutElement, mpDocument, mpLayout, SpeciesAlias::mSpecies, mSpeciesAliases, and mSpeciesAliasMap.

Referenced by createSpeciesGlyphs().

729 {
730  bool result = true;
731  // the speciesAlias node should
732  // have a bounds element with x,y,w and h
733  // attributes
734  SpeciesGlyph* pSGlyph = NULL;
735 
736  if (!sa.mId.empty())
737  {
738  if (sa.mComplexSpeciesAlias.empty())
739  {
740  pSGlyph = this->mpLayout->createSpeciesGlyph();
741 
742  if (pSGlyph != NULL)
743  {
744  // create unique id
745  std::string id = this->createUniqueId("SpeciesGlyph");
746  pSGlyph->setId(id);
747  this->mIdMap.insert(std::pair<std::string, const SBase*>(id, pSGlyph));
748  // set the bounds on the species glyph
749  pSGlyph->setBoundingBox(&sa.mBounds);
750  this->mCDIdToLayoutElement.insert(std::pair<std::string, GraphicalObject*>(sa.mId, pSGlyph));
751  // add the data to mCDBounds
752  this->mCDBounds.insert(std::pair<std::string, BoundingBox>(sa.mId, *pSGlyph->getBoundingBox()));
753 
754  // check if a compartment with that id actually exists before making the link
755  if (!sa.mSpecies.empty() &&
756  this->mpDocument != NULL &&
757  this->mpDocument->getModel() != NULL &&
758  this->mpDocument->getModel()->getSpecies(sa.mSpecies) != NULL)
759  {
760  pSGlyph->setSpeciesId(sa.mSpecies);
761  this->mModelIdToLayoutElement.insert(std::pair<std::string, GraphicalObject*>(sa.mSpecies, pSGlyph));