91 if (!ppp)
return false;
160 std::cout <<
"No compartment info for a species glyph!!!" << std::endl;
174 if (pCG != mapIt->second)
320 std::vector<UpdateAction>::const_iterator it, itEnd =
mUpdateActions.end();
345 std::cout <<
"Unknown Action!!!" << std::endl;
365 std::vector<CoordinateRelation>::const_iterator it, itEnd =
mFixedRelations.end();
368 it->target->setPosition(it->source->getPosition() + it->diff);
377 double s_c = 0;
double p_c = 0;
380 for (j = 0; j < jmax; ++j)
419 if (dir.
getX() == 0 && dir.
getY() == 0)
423 ortho_dir.
scale(1 / sqrt(pow(ortho_dir.
getX(), 2) + pow(ortho_dir.
getY(), 2)));
433 for (j = 0; j < jmax; ++j)
452 reaction_s + dir * direction,
453 (reaction_s + dir * (direction * 1.5) + metabPoint) * 0.5));
465 reaction_p + dir * direction,
466 (reaction_p + dir * (direction * 1.5) + metabPoint) * 0.5));
477 reactionPoint = reaction_m1;
482 reactionPoint = reaction_m2;
489 (reactionPoint + dir * (0 * direction * 1.5) + metabPoint) * 0.5,
490 reactionPoint + ortho_dir * direction));
528 double f = (fabs(go->
getWidth()) * 0.5 + d) / fabs(diff.
getX());
529 ret = center + diff * f;
533 double f = (fabs(go->
getHeight()) * 0.5 + d) / fabs(diff.
getY());
534 ret = center + diff * f;
548 if (tmp < 1) tmp = 1;
558 if (tmp < 1) tmp = 1;
568 if (tmp < 1) tmp = 1;
581 double tmp =
distance(pMG->getX() + pMG->getWidth() / 2, pMG->getY() + pMG->getHeight() / 2,
597 return pow(tmp - dist, 2);
608 return pow(tmp - dist, 2);
665 if (dist > (0.5 * c.
getWidth() - 50))
666 tmp += pow(dist - 0.5 * c.
getWidth() + 50, 2);
671 tmp += pow(dist - 0.5 * c.
getHeight() + 50, 2);
681 if (dist > (0.5 * c.
getWidth() - 50))
682 tmp += pow(dist - 0.5 * c.
getWidth() + 50, 2);
687 tmp += pow(dist - 0.5 * c.
getHeight() + 50, 2);
796 std::map<CLBase*, CLCompartmentGlyph*>::const_iterator mapIt =
mCompartmentMap.find(tmpMG);
802 std::cout <<
"No compartment info for a species glyph!!!" << std::endl;
817 std::map<CLBase*, CLCompartmentGlyph*>::const_iterator mapIt =
mCompartmentMap.find(tmpRG);
823 std::cout <<
"No compartment info for a reaction glyph!!!" << std::endl;
954 ->getMetabGlyph()->getBoundingBox().getCenter();
993 const std::set<const CCompartment*>& compartments,
994 const std::set<const CReaction*>& reactions,
995 const std::set<const CMetab*>& metabs,
996 const std::set<const CMetab*>& sideMetabs,
1002 double fontSize = 16.0;
1003 double fontHeight = fontSize * 1.5;
1007 std::map<const CCompartment*, CompartmentInfo> compInfo;
1008 std::map<const CMetab*, CLMetabGlyph*> metabMap;
1010 std::set<const CMetab*>::const_iterator metabIt;
1012 for (metabIt = metabs.begin(); metabIt != metabs.end(); ++metabIt)
1014 if (sideMetabs.find(*metabIt) != sideMetabs.end())
1018 double width = (double)((*metabIt)->getObjectName().length() * fontSize);
1019 double height = (double)fontHeight;
1032 metabMap[*metabIt] = pMetabGlyph;
1045 if (compartments.find((*metabIt)->getCompartment()) != compartments.end())
1046 pComp = (*metabIt)->getCompartment();
1048 compInfo[pComp].add((width + 4) * (height + 4));
1052 std::set<const CReaction*>::const_iterator reactIt;
1054 for (reactIt = reactions.begin(); reactIt != reactions.end(); ++reactIt)
1061 bool isReversible = (*reactIt)->isReversible();
1068 bool substrateExists =
false;
1071 for (elIt = substrates.
begin(); elIt != substrates.
end(); ++elIt)
1073 const CMetab* pMetab = (*elIt)->getMetabolite();
1082 if (sideMetabs.find(pMetab) != sideMetabs.end())
1085 double width = (double)((pMetab)->getObjectName().length() * fontSize);
1086 double height = (double)fontHeight;
1111 if (compartments.find(pMetab->
getCompartment()) != compartments.end())
1114 compInfo[pComp].add((width + 4) * (height + 4));
1123 std::map<const CMetab*, CLMetabGlyph*>::const_iterator mmIt;
1124 mmIt = metabMap.find(pMetab);
1126 if (mmIt != metabMap.end())
1127 pMetabGlyph = mmIt->second;
1142 substrateExists =
true;
1146 if (!substrateExists)
1162 bool productExists =
false;
1164 for (elIt = products.
begin(); elIt != products.
end(); ++elIt)
1166 const CMetab* pMetab = (*elIt)->getMetabolite();
1175 if (sideMetabs.find(pMetab) != sideMetabs.end())
1178 double width = (double)((pMetab)->getObjectName().length() * fontSize);
1179 double height = (double)fontHeight;
1204 if (compartments.find(pMetab->
getCompartment()) != compartments.end())
1207 compInfo[pComp].add((width + 4) * (height + 4));
1214 std::map<const CMetab*, CLMetabGlyph*>::const_iterator mmIt;
1215 mmIt = metabMap.find(pMetab);
1217 if (mmIt != metabMap.end())
1218 pMetabGlyph = mmIt->second;
1231 productExists =
true;
1252 for (elIt = modifiers.
begin(); elIt != modifiers.
end(); ++elIt)
1254 const CMetab* pMetab = (*elIt)->getMetabolite();
1263 if (sideMetabs.find(pMetab) != sideMetabs.end())
1266 double width = (double)((pMetab)->getObjectName().length() * fontSize);
1267 double height = (double)fontHeight;
1292 if (compartments.find(pMetab->
getCompartment()) != compartments.end())
1295 compInfo[pComp].add((width + 4) * (height + 4));
1302 std::map<const CMetab*, CLMetabGlyph*>::const_iterator mmIt;
1303 mmIt = metabMap.find(pMetab);
1305 if (mmIt != metabMap.end())
1306 pMetabGlyph = mmIt->second;
1344 pRefGlyph->
setRole(
"rule connection");
1351 std::set<const CCompartment*>::const_iterator compIt;
1353 for (compIt = compartments.begin(); compIt != compartments.end(); ++compIt)
1355 double compSize = 10000;
1356 std::map<const CCompartment*, CompartmentInfo>::const_iterator ccIt;
1357 ccIt = compInfo.find(*compIt);
1359 if (ccIt != compInfo.end())
1362 compSize = ccIt->second.mAreaSum * 40;
1370 xxx += sqrt(compSize) + 10;
void addReactionGlyph(CLReactionGlyph *glyph)
bool initFromLayout(CLayout *layout, Parameters *ppp)
performs all initializations that are later needed to calculate the potential
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
const C_FLOAT64 & getWidth() const
static unsigned C_INT32 getSystemSeed()
std::vector< double > values
CCopasiSpringLayout(CLayout *layout, Parameters *ppp=NULL)
void addGeneralGlyph(CLGeneralGlyph *glyph)
const CLBoundingBox & getBoundingBox() const
void addReferenceGlyph(CLReferenceGlyph *glyph)
virtual const std::vector< UpdateAction > & getUpdateActions() const
std::vector< double > mInitialState
virtual size_t size() const
const C_FLOAT64 & getX() const
const std::vector< CLLineSegment > & getCurveSegments() const
void addMetabReferenceGlyph(CLMetabReferenceGlyph *glyph)
void setDimensions(const CLDimensions &d)
void randomlyPlaceGlyphInDimensions(CLGraphicalObject *pGl, const CLDimensions *pContainer, CRandom *pRandom)
void setDimensions(const CLDimensions &d)
double potSecondOrderEdge(const CLMetabReferenceGlyph &e1, const CLMetabReferenceGlyph &e2, double &dist) const
const CLPoint & getPosition() const
static double distance(const double &x1, const double &y1, const double &x2, const double &y2)
CLGraphicalObject * getTargetGlyph() const
double potEdge(const CLMetabReferenceGlyph &e, const CLReactionGlyph &r) const
void setTargetGlyphKey(const std::string &k)
const CLGraphicalObject * source
void addMetaboliteGlyph(CLMetabGlyph *glyph)
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
virtual const std::string & getKey() const
void setModelObjectKey(const std::string &k)
const CLDimensions & getDimensions() const
void addTextGlyph(CLTextGlyph *glyph)
double potSpeciesCompartment(const CLMetabGlyph &s, const CLCompartmentGlyph &c) const
std::vector< UpdateAction > mUpdateActions
this is the list of all update actions that have to be performed during setState(); ...
double potGeneralEdge(const CLReferenceGlyph &e, const CLGeneralGlyph &r) const
CLPoint borderProjection(CLGraphicalObject *go, const CLPoint &p, double d)
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
void addPositionVariables(CLGraphicalObject *pGO)
create variables for the position of a species glyph
virtual C_FLOAT64 getRandomCC()
const C_FLOAT64 & getX() const
virtual const std::string & getKey() const
static CLayout * createLayout(CCopasiContainer *parent, const std::set< const CCompartment * > &compartments, const std::set< const CReaction * > &reactions, const std::set< const CMetab * > &metabs, const std::set< const CMetab * > &sideMetabs, Parameters *mParams=NULL)
void calculateAndAssignBounds()
void placeTextGlyphs(CLayout *pLayout)
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
const CCopasiVector< CLReferenceGlyph > & getListOfReferenceGlyphs() const
C_FLOAT64 dot(const CLPoint &rhs) const
void addCompartmentVariables(CLCompartmentGlyph *cg)
create variables for size and position of a compartment glyph
void addCurveSegment(const CLLineSegment &ls)
CLBoundingBox calculateBoundingBox() const
void setGraphicalObjectKey(const std::string &k)
CLPoint getCenter() const
virtual double getPotential()
std::vector< CoordinateRelation > mFixedRelations
a list of fixed positon relations between objects. Should be constructed in initFromLayout() ...
double potReactionReaction(const CLReactionGlyph &a, const CLReactionGlyph &b) const
std::vector< double > mMassVector
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
void setPosition(const CLPoint &p)
const C_FLOAT64 & getWidth() const
void addCompartmentGlyph(CLCompartmentGlyph *glyph)
static double bound_distance(const double &x1, const double &y1, const double &x2, const double &y2, const double &max)
CLGraphicalObject * getGraphicalObject() const
this describes one update action that has to be performed during setState()
const C_FLOAT64 & getY() const
const C_FLOAT64 & getY() const
CCopasiObject * getModelObject() const
double potReactionCompartment(const CLReactionGlyph &r, const CLCompartmentGlyph &c) const
void setObjectRole(const std::string &role)
const C_FLOAT64 & getHeight() const
CLGraphicalObject * target
std::map< CLBase *, CLCompartmentGlyph * > mCompartmentMap
this map contains information about the compartment glyph a given glyph is located in ...
double potSpeciesSpecies(const CLMetabGlyph &a, const CLMetabGlyph &b) const
void setRole(const std::string &r)
void scale(const double &scaleFactor)
virtual const std::vector< double > & getInitialValues() const
double potSpeciesReaction(const CLMetabGlyph &a, const CLReactionGlyph &b) const
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
void addReactionVariables(CLReactionGlyph *rg)
create variables for the position of a reaction glyph
const CModelEntity::Status & getStatus() const
void randomlyPlaceGlyphInCompartmentGlyph(CLGraphicalObject *pGl, const CLGraphicalObject *pContainer, CRandom *pRandom)
const CLDimensions & getDimensions() const
const C_FLOAT64 & getHeight() const
const CLCurve & getCurve() const
size_t getNumCurveSegments() const
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
virtual bool setState(const std::vector< double > &vars)
const CLDimensions & getDimensions() const
CLCompartmentGlyph * findCompartmentForReactionNode(CLReactionGlyph &r)
std::vector< VariableDescription > mVarDescription