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

#include <CCopasiSpringLayout.h>

Inheritance diagram for CCopasiSpringLayout:
Inheritance graph
[legend]
Collaboration diagram for CCopasiSpringLayout:
Collaboration graph
[legend]

Classes

struct  CoordinateRelation
 
class  Parameters
 
struct  UpdateAction
 this describes one update action that has to be performed during setState() More...
 

Public Member Functions

 CCopasiSpringLayout (CLayout *layout, Parameters *ppp=NULL)
 
bool createVariables ()
 
void finalizeState ()
 
CLCompartmentGlyphfindCompartmentForReactionNode (CLReactionGlyph &r)
 
virtual const std::vector
< double > & 
getInitialValues () const
 
virtual double getPotential ()
 
virtual const std::vector
< UpdateAction > & 
getUpdateActions () const
 
void randomize ()
 
virtual bool setState (const std::vector< double > &vars)
 
- Public Member Functions inherited from CAbstractLayoutInterface
 CAbstractLayoutInterface ()
 
virtual const std::vector
< double > & 
getMassVector () const
 
unsigned int getNumVariables () const
 
const std::vector
< VariableDescription > & 
getVariablesDescription () const
 
virtual ~CAbstractLayoutInterface ()
 

Static Public Member Functions

static CLayoutcreateLayout (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)
 

Protected Member Functions

void addCompartmentVariables (CLCompartmentGlyph *cg)
 create variables for size and position of a compartment glyph More...
 
void addPositionVariables (CLGraphicalObject *pGO)
 create variables for the position of a species glyph More...
 
void addReactionVariables (CLReactionGlyph *rg)
 create variables for the position of a reaction glyph More...
 
CLPoint borderProjection (CLGraphicalObject *go, const CLPoint &p, double d)
 
bool initFromLayout (CLayout *layout, Parameters *ppp)
 performs all initializations that are later needed to calculate the potential More...
 
double potEdge (const CLMetabReferenceGlyph &e, const CLReactionGlyph &r) const
 
double potGeneralEdge (const CLReferenceGlyph &e, const CLGeneralGlyph &r) const
 
double potReactionCompartment (const CLReactionGlyph &r, const CLCompartmentGlyph &c) const
 
double potReactionReaction (const CLReactionGlyph &a, const CLReactionGlyph &b) const
 
double potSecondOrderEdge (const CLMetabReferenceGlyph &e1, const CLMetabReferenceGlyph &e2, double &dist) const
 
double potSpeciesCompartment (const CLMetabGlyph &s, const CLCompartmentGlyph &c) const
 
double potSpeciesReaction (const CLMetabGlyph &a, const CLReactionGlyph &b) const
 
double potSpeciesSpecies (const CLMetabGlyph &a, const CLMetabGlyph &b) const
 

Static Protected Member Functions

static double bound_distance (const double &x1, const double &y1, const double &x2, const double &y2, const double &max)
 
static double distance (const double &x1, const double &y1, const double &x2, const double &y2)
 

Protected Attributes

std::map< CLBase
*, CLCompartmentGlyph * > 
mCompartmentMap
 this map contains information about the compartment glyph a given glyph is located in More...
 
std::vector< CoordinateRelationmFixedRelations
 a list of fixed positon relations between objects. Should be constructed in initFromLayout() More...
 
std::vector< double > mInitialState
 
CLayoutmpLayout
 
ParametersmpPar
 
std::vector< UpdateActionmUpdateActions
 this is the list of all update actions that have to be performed during setState(); More...
 
- Protected Attributes inherited from CAbstractLayoutInterface
std::vector< double > mMassVector
 
std::vector< VariableDescriptionmVarDescription
 

Detailed Description

This class defines how a layout optimization algorithm will see a COPASI layout, using a spring approach. No copy of the layout will be generated, meaning that setState() will change the layout.

Definition at line 34 of file CCopasiSpringLayout.h.

Constructor & Destructor Documentation

CCopasiSpringLayout::CCopasiSpringLayout ( CLayout layout,
Parameters ppp = NULL 
)

generate a spring layout view of a COPASI layout.

Definition at line 72 of file CCopasiSpringLayout.cpp.

References initFromLayout().

73  : mpLayout(NULL)
74 {
75  if (ppp == NULL)
76  {
77  // backward compatible
78  ppp = new Parameters();
79  }
80 
81  initFromLayout(layout, ppp);
82 }
bool initFromLayout(CLayout *layout, Parameters *ppp)
performs all initializations that are later needed to calculate the potential

Member Function Documentation

void CCopasiSpringLayout::addCompartmentVariables ( CLCompartmentGlyph cg)
protected

create variables for size and position of a compartment glyph

Definition at line 217 of file CCopasiSpringLayout.cpp.

References CCopasiSpringLayout::UpdateAction::COMPARTMENT_4V, CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), CLGraphicalObject::getY(), CAbstractLayoutInterface::VariableDescription::isAngle, mInitialState, CAbstractLayoutInterface::mMassVector, mUpdateActions, and CAbstractLayoutInterface::mVarDescription.

218 {
219  if (!cg)
220  return;
221 
222  VariableDescription desc;
223  desc.isAngle = false;
224 
225  int first_index = mInitialState.size();
226 
227  //x position
228  mInitialState.push_back(cg->getX());
229  mVarDescription.push_back(desc);
230  mMassVector.push_back(0.01);
231 
232  //y position
233  mInitialState.push_back(cg->getY());
234  mVarDescription.push_back(desc);
235  mMassVector.push_back(0.01);
236 
237  //width
238  mInitialState.push_back(cg->getWidth());
239  mVarDescription.push_back(desc);
240  mMassVector.push_back(0.01);
241 
242  //height
243  mInitialState.push_back(cg->getHeight());
244  mVarDescription.push_back(desc);
245  mMassVector.push_back(0.01);
246 
247  mUpdateActions.push_back(UpdateAction(UpdateAction::COMPARTMENT_4V, cg, first_index, first_index + 1, first_index + 2, first_index + 3));
248 }
std::vector< double > mInitialState
const C_FLOAT64 & getX() const
std::vector< UpdateAction > mUpdateActions
this is the list of all update actions that have to be performed during setState(); ...
std::vector< double > mMassVector
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
std::vector< VariableDescription > mVarDescription
void CCopasiSpringLayout::addPositionVariables ( CLGraphicalObject pGO)
protected

create variables for the position of a species glyph

Definition at line 250 of file CCopasiSpringLayout.cpp.

References CLGraphicalObject::getX(), CLGraphicalObject::getY(), CAbstractLayoutInterface::VariableDescription::isAngle, mInitialState, CAbstractLayoutInterface::mMassVector, mUpdateActions, CAbstractLayoutInterface::mVarDescription, and CCopasiSpringLayout::UpdateAction::POSITION_2V.

Referenced by createVariables().

251 {
252  if (!pGO)
253  return;
254 
255  bool side = false; //TODO: find out if it is a side reactant
256 
257  VariableDescription desc;
258  desc.isAngle = false;
259 
260  int first_index = mInitialState.size();
261 
262  //x position
263  mInitialState.push_back(pGO->getX());
264  mVarDescription.push_back(desc);
265  mMassVector.push_back(side ? 0.1 : 1.0);
266 
267  //y position
268  mInitialState.push_back(pGO->getY());
269  mVarDescription.push_back(desc);
270  mMassVector.push_back(side ? 0.1 : 1.0);
271 
272  mUpdateActions.push_back(UpdateAction(UpdateAction::POSITION_2V, pGO, first_index, first_index + 1));
273 }
std::vector< double > mInitialState
const C_FLOAT64 & getX() const
std::vector< UpdateAction > mUpdateActions
this is the list of all update actions that have to be performed during setState(); ...
std::vector< double > mMassVector
const C_FLOAT64 & getY() const
std::vector< VariableDescription > mVarDescription
void CCopasiSpringLayout::addReactionVariables ( CLReactionGlyph rg)
protected

create variables for the position of a reaction glyph

Definition at line 275 of file CCopasiSpringLayout.cpp.

References C_FLOAT64, CLGlyphWithCurve::getCurve(), CLCurve::getCurveSegments(), CLGraphicalObject::getHeight(), CLCurve::getNumCurveSegments(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), CLGraphicalObject::getY(), CAbstractLayoutInterface::VariableDescription::isAngle, mInitialState, CAbstractLayoutInterface::mMassVector, mUpdateActions, CAbstractLayoutInterface::mVarDescription, and CCopasiSpringLayout::UpdateAction::REACTION_2V.

Referenced by createVariables().

276 {
277  if (!rg)
278  return;
279 
280  VariableDescription desc;
281  desc.isAngle = false;
282 
283  int first_index = mInitialState.size();
284 
285  C_FLOAT64 xxx, yyy;
286 
287  //first look if the glyph is described by a curve
288  if (rg->getCurve().getNumCurveSegments())
289  {
290  unsigned int numsegs = rg->getCurve().getNumCurveSegments();
291  xxx = 0.5 * (rg->getCurve().getCurveSegments()[0].getStart().getX()
292  + rg->getCurve().getCurveSegments()[numsegs - 1].getEnd().getX());
293  yyy = 0.5 * (rg->getCurve().getCurveSegments()[0].getStart().getY()
294  + rg->getCurve().getCurveSegments()[numsegs - 1].getEnd().getY());
295  }
296  else
297  {
298  xxx = rg->getX() + 0.5 * rg->getWidth();
299  yyy = rg->getY() + 0.5 * rg->getHeight();
300  }
301 
302  //x position
303  mInitialState.push_back(xxx);
304  mVarDescription.push_back(desc);
305  mMassVector.push_back(1.0);
306 
307  //y position
308  mInitialState.push_back(yyy);
309  mVarDescription.push_back(desc);
310  mMassVector.push_back(1.0);
311 
312  mUpdateActions.push_back(UpdateAction(UpdateAction::REACTION_2V, rg, first_index, first_index + 1));
313 }
std::vector< double > mInitialState
const C_FLOAT64 & getX() const
const std::vector< CLLineSegment > & getCurveSegments() const
Definition: CLCurve.h:154
std::vector< UpdateAction > mUpdateActions
this is the list of all update actions that have to be performed during setState(); ...
std::vector< double > mMassVector
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
#define C_FLOAT64
Definition: copasi.h:92
const C_FLOAT64 & getHeight() const
const CLCurve & getCurve() const
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
std::vector< VariableDescription > mVarDescription
CLPoint CCopasiSpringLayout::borderProjection ( CLGraphicalObject go,
const CLPoint p,
double  d 
)
protected

calculate a point just outside the bounding box of a given graphical object on the line between the center of the object and the point p. d specifies the distance from the border of the object.

Definition at line 519 of file CCopasiSpringLayout.cpp.

References CLGraphicalObject::getBoundingBox(), CLBoundingBox::getCenter(), CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLPoint::getX(), and CLPoint::getY().

Referenced by finalizeState().

520 {
521  CLPoint center = go->getBoundingBox().getCenter();
522  CLPoint diff = p - center;
523 
524  CLPoint ret;
525 
526  if (fabs(diff.getX()) * (fabs(go->getHeight()) * 0.5 + d) > fabs(diff.getY()) * (fabs(go->getWidth()) * 0.5 + d))
527  {
528  double f = (fabs(go->getWidth()) * 0.5 + d) / fabs(diff.getX());
529  ret = center + diff * f;
530  }
531  else
532  {
533  double f = (fabs(go->getHeight()) * 0.5 + d) / fabs(diff.getY());
534  ret = center + diff * f;
535  }
536 
537  return ret;
538 }
const CLBoundingBox & getBoundingBox() const
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
Definition: CLBase.h:54
CLPoint getCenter() const
Definition: CLBase.h:269
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
const C_FLOAT64 & getHeight() const
static double CCopasiSpringLayout::bound_distance ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  max 
)
inlinestaticprotected

Definition at line 190 of file CCopasiSpringLayout.h.

References max.

Referenced by potReactionReaction(), potSpeciesReaction(), and potSpeciesSpecies().

192  {
193  //return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
194  //return fabs(x1-x2)<fabs(y1-y2)?fabs(y1-y2):fabs(x1-x2);
195 
196  if (fabs(x1 - x2) > max) return max;
197 
198  if (fabs(y1 - y2) > max) return max;
199 
200  double tmp = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
201  return tmp > max ? max : tmp;
202  }
#define max(a, b)
Definition: f2c.h:176
CLayout * CCopasiSpringLayout::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 
)
static

This method creates a random layout using the elements in the compartments, reactions, species and side species containers.

Definition at line 991 of file CCopasiSpringLayout.cpp.

References CLayout::addCompartmentGlyph(), CLayout::addGeneralGlyph(), CLayout::addMetaboliteGlyph(), CLReactionGlyph::addMetabReferenceGlyph(), CLayout::addReactionGlyph(), CLGeneralGlyph::addReferenceGlyph(), CLayout::addTextGlyph(), CModelEntity::ASSIGNMENT, CCopasiVector< T >::begin(), CLayout::calculateBoundingBox(), CCopasiVector< T >::end(), CMetab::getCompartment(), CLBoundingBox::getDimensions(), CLDimensions::getHeight(), CLGraphicalObject::getKey(), CModelEntity::getKey(), CLayout::getListOfMetaboliteGlyphs(), CLGraphicalObject::getModelObject(), CModelEntity::getStatus(), CLDimensions::getWidth(), CLMetabReferenceGlyph::MODIFIER, CModelEntity::ODE, pResult, CLMetabReferenceGlyph::PRODUCT, randomize(), CLayout::setDimensions(), CLGraphicalObject::setDimensions(), CLTextGlyph::setGraphicalObjectKey(), CLMetabReferenceGlyph::setMetabGlyphKey(), CLGraphicalObject::setModelObjectKey(), CLGraphicalObject::setObjectRole(), CLGraphicalObject::setPosition(), CLReferenceGlyph::setRole(), CLMetabReferenceGlyph::setRole(), CLReferenceGlyph::setTargetGlyphKey(), CLMetabReferenceGlyph::SIDEPRODUCT, CLMetabReferenceGlyph::SIDESUBSTRATE, CCopasiVector< T >::size(), and CLMetabReferenceGlyph::SUBSTRATE.

Referenced by CQLayoutsWidget::slotBtnNewClicked().

999 {
1000  CLayout *pResult = new CLayout("Layout", parent);
1001 
1002  double fontSize = 16.0;
1003  double fontHeight = fontSize * 1.5;
1004 
1005  // create a species glyph for each species in metabs
1006 
1007  std::map<const CCompartment*, CompartmentInfo> compInfo;
1008  std::map<const CMetab*, CLMetabGlyph*> metabMap;
1009 
1010  std::set<const CMetab*>::const_iterator metabIt;
1011 
1012  for (metabIt = metabs.begin(); metabIt != metabs.end(); ++metabIt)
1013  {
1014  if (sideMetabs.find(*metabIt) != sideMetabs.end())
1015  continue;
1016 
1017  //estimate the size of the glyph
1018  double width = (double)((*metabIt)->getObjectName().length() * fontSize);
1019  double height = (double)fontHeight;
1020 
1021  if (width < height)
1022  {
1023  width = height;
1024  }
1025 
1026  //create the glyph
1027  CLMetabGlyph* pMetabGlyph = new CLMetabGlyph;
1028  pMetabGlyph->setDimensions(CLDimensions(width + 4, height + 4));
1029  pMetabGlyph->setModelObjectKey((*metabIt)->getKey());
1030 
1031  pResult->addMetaboliteGlyph(pMetabGlyph);
1032  metabMap[*metabIt] = pMetabGlyph;
1033 
1034  //create the text glyph for the label
1035  CLTextGlyph* pTextGlyph = new CLTextGlyph;
1036  pTextGlyph->setDimensions(CLDimensions(width, height));
1037  pTextGlyph->setGraphicalObjectKey(pMetabGlyph->getKey());
1038  pTextGlyph->setModelObjectKey((*metabIt)->getKey());
1039 
1040  pResult->addTextGlyph(pTextGlyph);
1041 
1042  //add up the sizes for the compartment
1043  const CCompartment* pComp = NULL;
1044 
1045  if (compartments.find((*metabIt)->getCompartment()) != compartments.end())
1046  pComp = (*metabIt)->getCompartment();
1047 
1048  compInfo[pComp].add((width + 4) * (height + 4));
1049  }
1050 
1051  //now the reaction glyphs
1052  std::set<const CReaction*>::const_iterator reactIt;
1053 
1054  for (reactIt = reactions.begin(); reactIt != reactions.end(); ++reactIt)
1055  {
1056  CLReactionGlyph* pReactionGlyph = new CLReactionGlyph;
1057  //pResult->setDimensions(CLDimensions(width, height));
1058  pReactionGlyph->setModelObjectKey((*reactIt)->getKey());
1059  //pReactionGlyph->getCurve().addCurveSegment(CLLineSegment(CLPoint(x, y),
1060  // CLPoint(x + length, y)));
1061  bool isReversible = (*reactIt)->isReversible();
1062  pResult->addReactionGlyph(pReactionGlyph);
1063 
1064  //now add the species reference glyphs.
1065 
1066  //substrates
1067  const CCopasiVector < CChemEqElement >& substrates = (*reactIt)->getChemEq().getSubstrates();
1068  bool substrateExists = false;
1070 
1071  for (elIt = substrates.begin(); elIt != substrates.end(); ++elIt)
1072  {
1073  const CMetab* pMetab = (*elIt)->getMetabolite();
1074 
1075  if (!pMetab)
1076  continue;
1077 
1078  CLMetabGlyph* pMetabGlyph = NULL;
1079  CLMetabReferenceGlyph::Role role; // = CLMetabReferenceGlyph::SUBSTRATE;
1080 
1081  //is it a side reactant? If yes, create a new metab glyph
1082  if (sideMetabs.find(pMetab) != sideMetabs.end())
1083  {
1084  //estimate the size of the glyph
1085  double width = (double)((pMetab)->getObjectName().length() * fontSize);
1086  double height = (double)fontHeight;
1087 
1088  if (width < height)
1089  {
1090  width = height;
1091  }
1092 
1093  //create the glyph
1094  pMetabGlyph = new CLMetabGlyph;
1095  pMetabGlyph->setDimensions(CLDimensions(width + 4, height + 4));
1096  pMetabGlyph->setModelObjectKey(pMetab->getKey());
1097  //TODO: mark as duplicate
1098  pResult->addMetaboliteGlyph(pMetabGlyph);
1099 
1100  //create the text glyph for the label
1101  CLTextGlyph* pTextGlyph = new CLTextGlyph;
1102  pTextGlyph->setDimensions(CLDimensions(width, height));
1103  pTextGlyph->setGraphicalObjectKey(pMetabGlyph->getKey());
1104  pTextGlyph->setModelObjectKey(pMetab->getKey());
1105 
1106  pResult->addTextGlyph(pTextGlyph);
1107 
1108  //add up the sizes for the compartment
1109  const CCompartment* pComp = NULL;
1110 
1111  if (compartments.find(pMetab->getCompartment()) != compartments.end())
1112  pComp = pMetab->getCompartment();
1113 
1114  compInfo[pComp].add((width + 4) * (height + 4));
1115 
1116  role = isReversible
1119  }
1120  else
1121  {
1122  //find the existing metab glyph
1123  std::map<const CMetab*, CLMetabGlyph*>::const_iterator mmIt;
1124  mmIt = metabMap.find(pMetab);
1125 
1126  if (mmIt != metabMap.end())
1127  pMetabGlyph = mmIt->second;
1128 
1129  role = isReversible
1132  }
1133 
1134  if (!pMetabGlyph)
1135  continue;
1136 
1138  //pResult->setModelObjectKey(modelobjectkey);
1139  pRefGlyph->setMetabGlyphKey(pMetabGlyph->getKey());
1140  pRefGlyph->setRole(role);
1141  pReactionGlyph->addMetabReferenceGlyph(pRefGlyph);
1142  substrateExists = true;
1143  } //substrates
1144 
1145  // if we have no substrates, add a dummy / invisible node for now
1146  if (!substrateExists)
1147  {
1148  CLMetabGlyph* pMetabGlyph = new CLMetabGlyph;
1149  pMetabGlyph->setDimensions(CLDimensions(1, 1));
1150  pMetabGlyph->setObjectRole("invisible");
1151  pResult->addMetaboliteGlyph(pMetabGlyph);
1152 
1154  //pResult->setModelObjectKey(modelobjectkey);
1155  pRefGlyph->setMetabGlyphKey(pMetabGlyph->getKey());
1156  pRefGlyph->setRole(CLMetabReferenceGlyph::SUBSTRATE); //TODO side substr?
1157  pReactionGlyph->addMetabReferenceGlyph(pRefGlyph);
1158  }
1159 
1160  //products
1161  const CCopasiVector < CChemEqElement >& products = (*reactIt)->getChemEq().getProducts();
1162  bool productExists = false;
1163 
1164  for (elIt = products.begin(); elIt != products.end(); ++elIt)
1165  {
1166  const CMetab* pMetab = (*elIt)->getMetabolite();
1167 
1168  if (!pMetab)
1169  continue;
1170 
1171  CLMetabGlyph* pMetabGlyph = NULL;
1172  CLMetabReferenceGlyph::Role role; // = CLMetabReferenceGlyph::SUBSTRATE;
1173 
1174  //is it a side reactant? If yes, create a new metab glyph
1175  if (sideMetabs.find(pMetab) != sideMetabs.end())
1176  {
1177  //estimate the size of the glyph
1178  double width = (double)((pMetab)->getObjectName().length() * fontSize);
1179  double height = (double)fontHeight;
1180 
1181  if (width < height)
1182  {
1183  width = height;
1184  }
1185 
1186  //create the glyph
1187  pMetabGlyph = new CLMetabGlyph;
1188  pMetabGlyph->setDimensions(CLDimensions(width + 4, height + 4));
1189  pMetabGlyph->setModelObjectKey(pMetab->getKey());
1190  //TODO: mark as duplicate
1191  pResult->addMetaboliteGlyph(pMetabGlyph);
1192 
1193  //create the text glyph for the label
1194  CLTextGlyph* pTextGlyph = new CLTextGlyph;
1195  pTextGlyph->setDimensions(CLDimensions(width, height));
1196  pTextGlyph->setGraphicalObjectKey(pMetabGlyph->getKey());
1197  pTextGlyph->setModelObjectKey(pMetab->getKey());
1198 
1199  pResult->addTextGlyph(pTextGlyph);
1200 
1201  //add up the sizes for the compartment
1202  const CCompartment* pComp = NULL;
1203 
1204  if (compartments.find(pMetab->getCompartment()) != compartments.end())
1205  pComp = pMetab->getCompartment();
1206 
1207  compInfo[pComp].add((width + 4) * (height + 4));
1208 
1210  }
1211  else
1212  {
1213  //find the existing metab glyph
1214  std::map<const CMetab*, CLMetabGlyph*>::const_iterator mmIt;
1215  mmIt = metabMap.find(pMetab);
1216 
1217  if (mmIt != metabMap.end())
1218  pMetabGlyph = mmIt->second;
1219 
1221  }
1222 
1223  if (!pMetabGlyph)
1224  continue;
1225 
1227  //pResult->setModelObjectKey(modelobjectkey);
1228  pRefGlyph->setMetabGlyphKey(pMetabGlyph->getKey());
1229  pRefGlyph->setRole(role);
1230  pReactionGlyph->addMetabReferenceGlyph(pRefGlyph);
1231  productExists = true;
1232  } //products
1233 
1234  // if we have no substrates, add a dummy / invisible node for now
1235  if (!productExists)
1236  {
1237  CLMetabGlyph* pMetabGlyph = new CLMetabGlyph;
1238  pMetabGlyph->setDimensions(CLDimensions(1, 1));
1239  pMetabGlyph->setObjectRole("invisible");
1240  pResult->addMetaboliteGlyph(pMetabGlyph);
1241 
1243  //pResult->setModelObjectKey(modelobjectkey);
1244  pRefGlyph->setMetabGlyphKey(pMetabGlyph->getKey());
1245  pRefGlyph->setRole(CLMetabReferenceGlyph::PRODUCT); //TODO side substr?
1246  pReactionGlyph->addMetabReferenceGlyph(pRefGlyph);
1247  }
1248 
1249  //modifiers
1250  const CCopasiVector < CChemEqElement >& modifiers = (*reactIt)->getChemEq().getModifiers();
1251 
1252  for (elIt = modifiers.begin(); elIt != modifiers.end(); ++elIt)
1253  {
1254  const CMetab* pMetab = (*elIt)->getMetabolite();
1255 
1256  if (!pMetab)
1257  continue;
1258 
1259  CLMetabGlyph* pMetabGlyph = NULL;
1260  CLMetabReferenceGlyph::Role role; // = CLMetabReferenceGlyph::SUBSTRATE;
1261 
1262  //is it a side reactant? If yes, create a new metab glyph
1263  if (sideMetabs.find(pMetab) != sideMetabs.end())
1264  {
1265  //estimate the size of the glyph
1266  double width = (double)((pMetab)->getObjectName().length() * fontSize);
1267  double height = (double)fontHeight;
1268 
1269  if (width < height)
1270  {
1271  width = height;
1272  }
1273 
1274  //create the glyph
1275  pMetabGlyph = new CLMetabGlyph;
1276  pMetabGlyph->setDimensions(CLDimensions(width + 4, height + 4));
1277  pMetabGlyph->setModelObjectKey(pMetab->getKey());
1278  //TODO: mark as duplicate
1279  pResult->addMetaboliteGlyph(pMetabGlyph);
1280 
1281  //create the text glyph for the label
1282  CLTextGlyph* pTextGlyph = new CLTextGlyph;
1283  pTextGlyph->setDimensions(CLDimensions(width, height));
1284  pTextGlyph->setGraphicalObjectKey(pMetabGlyph->getKey());
1285  pTextGlyph->setModelObjectKey(pMetab->getKey());
1286 
1287  pResult->addTextGlyph(pTextGlyph);
1288 
1289  //add up the sizes for the compartment
1290  const CCompartment* pComp = NULL;
1291 
1292  if (compartments.find(pMetab->getCompartment()) != compartments.end())
1293  pComp = pMetab->getCompartment();
1294 
1295  compInfo[pComp].add((width + 4) * (height + 4));
1296 
1297  role = CLMetabReferenceGlyph::MODIFIER; //TODO SIDEMODIFIER???
1298  }
1299  else
1300  {
1301  //find the existing metab glyph
1302  std::map<const CMetab*, CLMetabGlyph*>::const_iterator mmIt;
1303  mmIt = metabMap.find(pMetab);
1304 
1305  if (mmIt != metabMap.end())
1306  pMetabGlyph = mmIt->second;
1307 
1309  }
1310 
1311  if (!pMetabGlyph)
1312  continue;
1313 
1315  //pResult->setModelObjectKey(modelobjectkey);
1316  pRefGlyph->setMetabGlyphKey(pMetabGlyph->getKey());
1317  pRefGlyph->setRole(role);
1318  pReactionGlyph->addMetabReferenceGlyph(pRefGlyph);
1319  } //modifiers
1320  } //reactions
1321 
1322  //rules
1323  size_t i;
1324 
1325  for (i = 0; i < pResult->getListOfMetaboliteGlyphs().size(); ++i)
1326  {
1327  const CLMetabGlyph* pMetabGlyph = pResult->getListOfMetaboliteGlyphs()[i];
1328  const CMetab* pMetab = dynamic_cast<const CMetab*>(pMetabGlyph->getModelObject());
1329 
1330  if (!pMetab)
1331  continue;
1332 
1333  if (pMetab->getStatus() == CModelEntity::ODE || pMetab->getStatus() == CModelEntity::ASSIGNMENT)
1334  {
1335  CLGeneralGlyph* pGG = new CLGeneralGlyph;
1336  pGG->setDimensions(CLDimensions(10, 10));
1337  pGG->setObjectRole("rule");
1338 
1339  pResult->addGeneralGlyph(pGG);
1340 
1341  CLReferenceGlyph* pRefGlyph = new CLReferenceGlyph;
1342  pRefGlyph->setDimensions(CLDimensions(10, 10));
1343  pRefGlyph->setTargetGlyphKey(pMetabGlyph->getKey());
1344  pRefGlyph->setRole("rule connection");
1345  pGG->addReferenceGlyph(pRefGlyph);
1346  }
1347  }
1348 
1349  //after all other glyphs are created, create the compartment glyphs
1350  double xxx = 0;
1351  std::set<const CCompartment*>::const_iterator compIt;
1352 
1353  for (compIt = compartments.begin(); compIt != compartments.end(); ++compIt)
1354  {
1355  double compSize = 10000;
1356  std::map<const CCompartment*, CompartmentInfo>::const_iterator ccIt;
1357  ccIt = compInfo.find(*compIt);
1358 
1359  if (ccIt != compInfo.end())
1360  {
1361  //some glyphs are placed inside this compartment glyph
1362  compSize = ccIt->second.mAreaSum * 40;
1363  }
1364 
1365  //create the glyph
1366  CLCompartmentGlyph* pCompGlyph = new CLCompartmentGlyph;
1367  pCompGlyph->setModelObjectKey((*compIt)->getKey());
1368  pCompGlyph->setDimensions(CLDimensions(CLDimensions(sqrt(compSize), sqrt(compSize))));
1369  pCompGlyph->setPosition(CLPoint(xxx, 5));
1370  xxx += sqrt(compSize) + 10;
1371 
1372  pResult->addCompartmentGlyph(pCompGlyph);
1373  }
1374 
1375  //
1376  // double sss = sqrt(compInfo[NULL].mAreaSum * 40);
1377  //
1378  // // determine and set the layout dimensions
1379  // CLBoundingBox box = pResult->calculateBoundingBox();
1380  // if (box.getDimensions().getWidth() < sss)
1381  // box.getDimensions().setWidth(sss);
1382  //
1383  // if (box.getDimensions().getHeight() < sss)
1384  // box.getDimensions().setHeight(sss);
1385  //
1386  // pResult->setDimensions(CLDimensions(box.getDimensions().getWidth() + 30.0, box.getDimensions().getHeight() + 30.0));
1387 
1388  // randomize
1389  CCopasiSpringLayout l(pResult, mParams);
1390  l.randomize();
1391 
1392  // determine and set the layout dimensions
1393  CLBoundingBox box = pResult->calculateBoundingBox();
1394  pResult->setDimensions(CLDimensions(box.getDimensions().getWidth() + 30.0, box.getDimensions().getHeight() + 30.0));
1395 
1396  return pResult;
1397 }
void addReactionGlyph(CLReactionGlyph *glyph)
Definition: CLayout.cpp:251
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
void addGeneralGlyph(CLGeneralGlyph *glyph)
Definition: CLayout.cpp:263
void addReferenceGlyph(CLReferenceGlyph *glyph)
virtual size_t size() const
iterator begin()
void addMetabReferenceGlyph(CLMetabReferenceGlyph *glyph)
void setDimensions(const CLDimensions &d)
Definition: CLayout.h:77
void setDimensions(const CLDimensions &d)
void setTargetGlyphKey(const std::string &k)
Definition: CMetab.h:178
void addMetaboliteGlyph(CLMetabGlyph *glyph)
Definition: CLayout.cpp:245
virtual const std::string & getKey() const
void setModelObjectKey(const std::string &k)
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
void addTextGlyph(CLTextGlyph *glyph)
Definition: CLayout.cpp:257
iterator end()
Definition: CLBase.h:54
virtual const std::string & getKey() const
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
CLBoundingBox calculateBoundingBox() const
Definition: CLayout.cpp:684
void setGraphicalObjectKey(const std::string &k)
Definition: CLGlyphs.cpp:338
void setPosition(const CLPoint &p)
const CArrayAnnotation * pResult
void addCompartmentGlyph(CLCompartmentGlyph *glyph)
Definition: CLayout.cpp:239
void setMetabGlyphKey(const std::string &k)
CCopasiObject * getModelObject() const
void setObjectRole(const std::string &role)
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
void setRole(const std::string &r)
const CModelEntity::Status & getStatus() const
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
bool CCopasiSpringLayout::createVariables ( )

generates the list of variables from the layout. This method will generate variables for the coordinates of all the nodes in the layout. TODO: make it possible to only auto-layout a subset of the graph

Definition at line 184 of file CCopasiSpringLayout.cpp.

References addPositionVariables(), addReactionVariables(), CLayout::getListOfGeneralGlyphs(), CLayout::getListOfMetaboliteGlyphs(), CLayout::getListOfReactionGlyphs(), mInitialState, CAbstractLayoutInterface::mMassVector, mpLayout, CAbstractLayoutInterface::mVarDescription, and CCopasiVector< T >::size().

Referenced by CQLayoutThread::run().

185 {
186  //delete current variables
187  mInitialState.clear();
188  mVarDescription.clear();
189  mMassVector.clear();
190 
191  unsigned int i;
192 
193  // add variables for the coordinates of all metabs
194  for (i = 0; i < mpLayout->getListOfMetaboliteGlyphs().size() ; ++i)
195  {
197  }
198 
199  // add variables for the coordinates of all reaction glyphs
200  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size() ; ++i)
201  {
203  }
204 
205  // add variables for the coordinates of all general glyphs
206  for (i = 0; i < mpLayout->getListOfGeneralGlyphs().size() ; ++i)
207  {
209  }
210 
211  // add variables for text glyphs that are not fixed to anything.
212  //TODO
213 
214  return true;
215 }
std::vector< double > mInitialState
virtual size_t size() const
void addPositionVariables(CLGraphicalObject *pGO)
create variables for the position of a species glyph
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
std::vector< double > mMassVector
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
void addReactionVariables(CLReactionGlyph *rg)
create variables for the position of a reaction glyph
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
std::vector< VariableDescription > mVarDescription
static double CCopasiSpringLayout::distance ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2 
)
inlinestaticprotected

Definition at line 183 of file CCopasiSpringLayout.h.

Referenced by potEdge(), potGeneralEdge(), and potSecondOrderEdge().

185  {
186  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
187  //return fabs(x1-x2)<fabs(y1-y2)?fabs(y1-y2):fabs(x1-x2);
188  }
void CCopasiSpringLayout::finalizeState ( )

complete the update of the layout. This updates the things that are not needed for the calculation of the potential. After calling this method the layout should be ready for drawing or storing

Definition at line 358 of file CCopasiSpringLayout.cpp.

References CLCurve::addCurveSegment(), borderProjection(), CLayout::calculateAndAssignBounds(), CLCurve::clear(), CLPoint::dot(), CLGraphicalObject::getBoundingBox(), CLBoundingBox::getCenter(), CLGlyphWithCurve::getCurve(), CLayout::getListOfGeneralGlyphs(), CLReactionGlyph::getListOfMetabReferenceGlyphs(), CLayout::getListOfReactionGlyphs(), CLGeneralGlyph::getListOfReferenceGlyphs(), CLMetabReferenceGlyph::getMetabGlyph(), CLCurve::getNumCurveSegments(), CLGraphicalObject::getPosition(), CLMetabReferenceGlyph::getRole(), CLReferenceGlyph::getTargetGlyph(), CLPoint::getX(), CLPoint::getY(), mFixedRelations, mpLayout, CLMetabReferenceGlyph::PRODUCT, CLPoint::scale(), CLMetabReferenceGlyph::SIDEPRODUCT, CLMetabReferenceGlyph::SIDESUBSTRATE, CCopasiVector< T >::size(), and CLMetabReferenceGlyph::SUBSTRATE.

Referenced by CQLayoutThread::finalize(), randomize(), and CQLayoutScene::updatePosition().

359 {
360  unsigned int i;
361 
362  //update the positions of the dependent glyphs
363  //this can be done here since we assume that those glyphs
364  //do not affect the layout.
365  std::vector<CoordinateRelation>::const_iterator it, itEnd = mFixedRelations.end();
366 
367  for (it = mFixedRelations.begin(); it != itEnd; ++it)
368  it->target->setPosition(it->source->getPosition() + it->diff);
369 
370  //for now, only create curves for the reaction glyphs
371  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size() ; ++i)
372  {
374 
375  //Determine the average position of substrates and products, giving less weight to side reactants
376  CLPoint s, p;
377  double s_c = 0; double p_c = 0;
378  unsigned int j, jmax = pRG->getListOfMetabReferenceGlyphs().size();
379 
380  for (j = 0; j < jmax; ++j)
381  {
383  {
384  s_c += 1.0;
385  s = s + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter();
386  }
387 
389  {
390  s_c += 0.1;
391  s = s + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter() * 0.1;
392  }
393 
395  {
396  p_c += 1.0;
397  p = p + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter();
398  }
399 
401  {
402  p_c += 0.1;
403  p = p + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter() * 0.1;
404  }
405  }
406 
407  if (s_c > 0)
408  s = s * (1 / s_c);
409  else
410  s = pRG->getPosition();
411 
412  if (p_c > 0)
413  p = p * (1 / p_c);
414  else
415  p = pRG->getPosition();
416 
417  CLPoint dir = p - s; //overall direction of reaction
418 
419  if (dir.getX() == 0 && dir.getY() == 0)
420  dir = CLPoint(1, 0);
421 
422  CLPoint ortho_dir = CLPoint(dir.getY(), -dir.getX());
423  ortho_dir.scale(1 / sqrt(pow(ortho_dir.getX(), 2) + pow(ortho_dir.getY(), 2)));
424 
425  CLPoint reaction_s = pRG->getPosition() - (dir * 0.05);
426  CLPoint reaction_p = pRG->getPosition() + (dir * 0.05);
427  CLPoint reaction_m1 = pRG->getPosition() + ortho_dir * 10;
428  CLPoint reaction_m2 = pRG->getPosition() - ortho_dir * 10;
429 
430  pRG->getCurve().clear();
431  pRG->getCurve().addCurveSegment(CLLineSegment(reaction_s, reaction_p));
432 
433  for (j = 0; j < jmax; ++j)
434  {
435  //here we need to generate the curves for the MetabReferenceGlyphs.
436  //we will need to consider the size of the glyphs, role of the metab in the reaction, etc.
437  //For now, only a primitive implementation: TODO: improve
439  double direction;
440  //double modifierLength = -0.2;
441 
442  switch (pMRG->getRole())
443  {
446  {
447  direction = -0.1;
448  CLPoint metabPoint = borderProjection(pMRG->getMetabGlyph(), reaction_s + dir * direction /*(modifierLength * 1.5)*/, 5);
449  pMRG->getCurve().clear();
450  pMRG->getCurve().addCurveSegment(CLLineSegment(reaction_s,
451  metabPoint,
452  reaction_s + dir * direction,
453  (reaction_s + dir * (direction * 1.5) + metabPoint) * 0.5));
454  }
455  break;
456 
459  {
460  direction = 0.1;
461  CLPoint metabPoint = borderProjection(pMRG->getMetabGlyph(), reaction_p + dir * direction /*(modifierLength * 1.5)*/, 5);
462  pMRG->getCurve().clear();
463  pMRG->getCurve().addCurveSegment(CLLineSegment(reaction_p,
464  metabPoint,
465  reaction_p + dir * direction,
466  (reaction_p + dir * (direction * 1.5) + metabPoint) * 0.5));
467  }
468  break;
469 
470  default:
471  {
472  CLPoint reactionPoint;
473 
474  if (ortho_dir.dot(pRG->getPosition() - pMRG->getMetabGlyph()->getPosition()) < 0)
475  {
476  direction = +10.0;
477  reactionPoint = reaction_m1;
478  }
479  else
480  {
481  direction = -10.0;
482  reactionPoint = reaction_m2;
483  }
484 
485  CLPoint metabPoint = borderProjection(pMRG->getMetabGlyph(), reactionPoint + dir * 0 * direction /*(modifierLength * 1.5)*/, 5);
486  pMRG->getCurve().clear();
487  pMRG->getCurve().addCurveSegment(CLLineSegment(metabPoint,
488  reactionPoint,
489  (reactionPoint + dir * (0 * direction * 1.5) + metabPoint) * 0.5,
490  reactionPoint + ortho_dir * direction));
491  }
492  }
493  }
494  }
495 
496  //update the curves in the general glyph
497  for (i = 0; i < mpLayout->getListOfGeneralGlyphs().size() ; ++i)
498  {
500 
501  size_t j;
502 
503  for (j = 0; j < pGG->getListOfReferenceGlyphs().size(); ++j)
504  {
506 
507  if (pRG->getCurve().getNumCurveSegments() == 0) continue;
508 
509  CLPoint refPoint = borderProjection(pRG->getTargetGlyph(), pRG->getBoundingBox().getCenter(), 5);
510  pRG->getCurve().clear();
511  pRG->getCurve().addCurveSegment(CLLineSegment(refPoint, pRG->getBoundingBox().getCenter()));
512  }
513  }
514 
515  //calculate bounding box for the layout, or recenter the layout
517 }
const CLBoundingBox & getBoundingBox() const
virtual size_t size() const
const CLPoint & getPosition() const
CLGraphicalObject * getTargetGlyph() const
CLPoint borderProjection(CLGraphicalObject *go, const CLPoint &p, double d)
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
Definition: CLBase.h:54
void calculateAndAssignBounds()
Definition: CLayout.cpp:955
const CCopasiVector< CLReferenceGlyph > & getListOfReferenceGlyphs() const
C_FLOAT64 dot(const CLPoint &rhs) const
Definition: CLBase.h:135
void addCurveSegment(const CLLineSegment &ls)
Definition: CLCurve.cpp:101
CLPoint getCenter() const
Definition: CLBase.h:269
CLMetabGlyph * getMetabGlyph() const
std::vector< CoordinateRelation > mFixedRelations
a list of fixed positon relations between objects. Should be constructed in initFromLayout() ...
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
void scale(const double &scaleFactor)
Definition: CLBase.h:95
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
const CLCurve & getCurve() const
size_t getNumCurveSegments() const
Definition: CLCurve.h:168
void clear()
Definition: CLCurve.cpp:112
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
CLCompartmentGlyph * CCopasiSpringLayout::findCompartmentForReactionNode ( CLReactionGlyph r)

if all participants of a reaction are in a single compartment return the compartment glyph, otherwise return NULL

Definition at line 145 of file CCopasiSpringLayout.cpp.

References CLReactionGlyph::getListOfMetabReferenceGlyphs(), mCompartmentMap, and CCopasiVector< T >::size().

Referenced by initFromLayout().

146 {
147  CLCompartmentGlyph* pCG = NULL;
148 
149  //r.compartmentIndex = mSpeciesNodes[r.getEdges()[0].sindex].compartmentIndex;
150  unsigned int i;
151 
152  for (i = 0; i < r.getListOfMetabReferenceGlyphs().size(); ++i)
153  {
154  std::map<CLBase*, CLCompartmentGlyph*>::const_iterator mapIt = mCompartmentMap.find(r.getListOfMetabReferenceGlyphs()[i]->getMetabGlyph());
155 
156  if (mapIt == mCompartmentMap.end())
157  {
158  //there is no information in the map. Should not happen.
159 #ifdef COPASI_DEBUG
160  std::cout << "No compartment info for a species glyph!!!" << std::endl;
161 #endif
162  continue;
163  }
164 
165  if (! mapIt->second)
166  continue; //the species glyph is not linked to a compartment
167 
168  if (!pCG) //this is the first compartment
169  {
170  pCG = mapIt->second;
171  continue;
172  }
173 
174  if (pCG != mapIt->second) //there are at least two different compartments
175  {
176  pCG = NULL;
177  break;
178  }
179  }
180 
181  return pCG;
182 }
virtual size_t size() const
std::map< CLBase *, CLCompartmentGlyph * > mCompartmentMap
this map contains information about the compartment glyph a given glyph is located in ...
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
const std::vector< double > & CCopasiSpringLayout::getInitialValues ( ) const
virtual

Implements CAbstractLayoutInterface.

Definition at line 859 of file CCopasiSpringLayout.cpp.

References mInitialState.

860 {
861  return mInitialState;
862 }
std::vector< double > mInitialState
double CCopasiSpringLayout::getPotential ( )
virtual

Implements CAbstractLayoutInterface.

Definition at line 707 of file CCopasiSpringLayout.cpp.

References CLayout::getListOfGeneralGlyphs(), CLayout::getListOfMetaboliteGlyphs(), CLReactionGlyph::getListOfMetabReferenceGlyphs(), CLayout::getListOfReactionGlyphs(), CLGeneralGlyph::getListOfReferenceGlyphs(), mCompartmentMap, mpLayout, mpPar, potEdge(), potGeneralEdge(), potReactionCompartment(), potReactionReaction(), potSecondOrderEdge(), potSpeciesCompartment(), potSpeciesReaction(), potSpeciesSpecies(), CLMetabReferenceGlyph::PRODUCT, CLMetabReferenceGlyph::SIDEPRODUCT, CLMetabReferenceGlyph::SIDESUBSTRATE, CCopasiVector< T >::size(), CLMetabReferenceGlyph::SUBSTRATE, and CCopasiSpringLayout::Parameters::values.

708 {
709  //here we need to add the different effects that contribute to the potential
710 
711  double tmp = 0;
712 
713  //repulsion between species nodes
714  unsigned int i, j;
715 
716  for (i = 0; i < mpLayout->getListOfMetaboliteGlyphs().size() - 1; ++i)
717  for (j = i + 1; j < mpLayout->getListOfMetaboliteGlyphs().size(); ++j)
718  {
719  if (i != j)
721  }
722 
723  // only if we have reactions!
725  {
726  //repulsion between species nodes and reaction nodes
727  for (i = 0; i < mpLayout->getListOfMetaboliteGlyphs().size(); ++i)
728  for (j = 0; j < mpLayout->getListOfReactionGlyphs().size(); ++j)
729  {
731  }
732 
733  //repulsion between reaction nodes
734  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size() - 1; ++i)
735  for (j = i + 1; j < mpLayout->getListOfReactionGlyphs().size(); ++j)
736  {
737  if (i != j)
739  }
740  }
741 
742  //spring force for species references
743  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size(); ++i)
744  {
746 
747  for (j = 0; j < pRG->getListOfMetabReferenceGlyphs().size(); ++j)
748  {
749  tmp += potEdge(*pRG->getListOfMetabReferenceGlyphs()[j], *pRG);
750 
751  //second order
753 
755  continue;
756 
757  double dist = role == CLMetabReferenceGlyph::SUBSTRATE ? mpPar->values[1] : mpPar->values[3];
758  size_t k;
759 
760  for (k = 0; k < pRG->getListOfMetabReferenceGlyphs().size(); ++k)
761  {
762  CLMetabReferenceGlyph::Role role2 = pRG->getListOfMetabReferenceGlyphs()[k]->getRole();
763 
765  continue;
766 
767  dist += role2 == CLMetabReferenceGlyph::PRODUCT ? mpPar->values[1] : mpPar->values[3];
768 
770  }
771  }
772  }
773 
774  for (i = 0; i < mpLayout->getListOfGeneralGlyphs().size(); ++i)
775  {
777 
778  for (j = 0; j < pRG->getListOfReferenceGlyphs().size(); ++j)
779  {
780  tmp += potGeneralEdge(*pRG->getListOfReferenceGlyphs()[j], *pRG);
781  }
782  }
783 
784  /*
785  //forces at reaction nodes
786  for (i=0; i<mReactionNodes.size(); ++i)
787  {
788  tmp += 3000* potReaction(mReactionNodes[i]);
789  }
790  */
791 
792  //force to keep species in compartment
793  for (i = 0; i < mpLayout->getListOfMetaboliteGlyphs().size(); ++i)
794  {
796  std::map<CLBase*, CLCompartmentGlyph*>::const_iterator mapIt = mCompartmentMap.find(tmpMG);
797 
798  if (mapIt == mCompartmentMap.end())
799  {
800  //there is no information in the map. Should not happen.
801 #ifdef COPASI_DEBUG
802  std::cout << "No compartment info for a species glyph!!!" << std::endl;
803 #endif
804  continue;
805  }
806 
807  CLCompartmentGlyph* tmpCG = mapIt->second;
808 
809  if (tmpCG) //the species glyph is inside a compartment glyph
810  tmp += mpPar->values[6] * potSpeciesCompartment(*tmpMG, *tmpCG);
811  }
812 
813  //force to keep reaction nodes in compartment
814  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size(); ++i)
815  {
817  std::map<CLBase*, CLCompartmentGlyph*>::const_iterator mapIt = mCompartmentMap.find(tmpRG);
818 
819  if (mapIt == mCompartmentMap.end())
820  {
821  //there is no information in the map. Should not happen.
822 #ifdef COPASI_DEBUG
823  std::cout << "No compartment info for a reaction glyph!!!" << std::endl;
824 #endif
825  continue;
826  }
827 
828  CLCompartmentGlyph* tmpCG = mapIt->second;
829 
830  if (tmpCG) //the reaction glyph is inside a compartment glyph
831  tmp += mpPar->values[7] * potReactionCompartment(*tmpRG, *tmpCG);
832  }
833 
834  /*
835 
836  //force to shrink compartments
837  for (i=0; i<mCompartmentNodes.size(); ++i)
838  {
839  tmp += 0.2*(fabs(mCompartmentNodes[i].w-100)+fabs(mCompartmentNodes[i].h-100));
840  }
841 
842  //repulsion between compartments
843  for (i=0; i<mCompartmentNodes.size(); ++i)
844  for (j=0; j<mCompartmentNodes.size(); ++j)
845  {
846  if (i!=j)
847  tmp += 100*potCompartmentCompartment(mCompartmentNodes[i], mCompartmentNodes[j]);
848  }
849 
850  //centering force
851  for (i=0; i<mCompartmentNodes.size(); ++i)
852  {
853  tmp += 10*(fabs(mCompartmentNodes[i].x)+fabs(mCompartmentNodes[i].y));
854  }
855  */
856  return tmp;
857 }
virtual size_t size() const
double potSecondOrderEdge(const CLMetabReferenceGlyph &e1, const CLMetabReferenceGlyph &e2, double &dist) const
double potEdge(const CLMetabReferenceGlyph &e, const CLReactionGlyph &r) const
double potSpeciesCompartment(const CLMetabGlyph &s, const CLCompartmentGlyph &c) const
double potGeneralEdge(const CLReferenceGlyph &e, const CLGeneralGlyph &r) const
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
const CCopasiVector< CLReferenceGlyph > & getListOfReferenceGlyphs() const
double potReactionReaction(const CLReactionGlyph &a, const CLReactionGlyph &b) const
const CCopasiVector< CLGeneralGlyph > & getListOfGeneralGlyphs() const
Definition: CLayout.h:133
double potReactionCompartment(const CLReactionGlyph &r, const CLCompartmentGlyph &c) const
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
double potSpeciesReaction(const CLMetabGlyph &a, const CLReactionGlyph &b) const
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
const std::vector< CCopasiSpringLayout::UpdateAction > & CCopasiSpringLayout::getUpdateActions ( ) const
virtual

Definition at line 864 of file CCopasiSpringLayout.cpp.

References mUpdateActions.

865 {
866  return mUpdateActions;
867 }
std::vector< UpdateAction > mUpdateActions
this is the list of all update actions that have to be performed during setState(); ...
bool CCopasiSpringLayout::initFromLayout ( CLayout layout,
Parameters ppp 
)
protected

performs all initializations that are later needed to calculate the potential

Definition at line 84 of file CCopasiSpringLayout.cpp.

References CCopasiSpringLayout::CoordinateRelation::diff, findCompartmentForReactionNode(), CMetab::getCompartment(), CModelEntity::getKey(), CLayout::getListOfCompartmentGlyphs(), CLayout::getListOfMetaboliteGlyphs(), CLayout::getListOfReactionGlyphs(), CLayout::getListOfTextGlyphs(), CLGraphicalObject::getPosition(), mCompartmentMap, mFixedRelations, mpLayout, mpPar, CCopasiVector< T >::size(), CCopasiSpringLayout::CoordinateRelation::source, and CCopasiSpringLayout::CoordinateRelation::target.

Referenced by CCopasiSpringLayout().

85 {
86  mpLayout = layout;
87  mpPar = ppp;
88 
89  if (!mpLayout) return false;
90 
91  if (!ppp) return false;
92 
93  mCompartmentMap.clear();
94 
95  //store the compartment glyph for each species glyph (if it exists)
96  unsigned int i;
97 
98  for (i = 0; i < mpLayout->getListOfMetaboliteGlyphs().size() ; ++i)
99  {
100  CMetab* metab = dynamic_cast<CMetab*>(mpLayout->getListOfMetaboliteGlyphs()[i]->getModelObject());
101  CLCompartmentGlyph* tmp = NULL;
102 
103  if (metab)
104  {
105  unsigned int j;
106 
107  for (j = 0; j < mpLayout->getListOfCompartmentGlyphs().size(); ++j)
108  if (mpLayout->getListOfCompartmentGlyphs()[j]->getModelObjectKey() == metab->getCompartment()->getKey())
109  {
111  break;
112  }
113  }
114 
116  }
117 
118  //store the compartment glyph for each reaction glyph (if it exists)
119  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size() ; ++i)
120  {
122  }
123 
124  //create the list of constant positional relations
125  //we assume that text glyphs are always moved with the glyph they refer to.
126  //(i.e. the are not layed out independently)
127  mFixedRelations.clear();
128 
129  for (i = 0; i < mpLayout->getListOfTextGlyphs().size(); ++i)
130  {
131  CoordinateRelation tmp;
132  tmp.target = mpLayout->getListOfTextGlyphs()[i];
133  tmp.source = mpLayout->getListOfTextGlyphs()[i]->getGraphicalObject();
134 
135  if (tmp.source)
136  {
137  tmp.diff = tmp.target->getPosition() - tmp.source->getPosition();
138  mFixedRelations.push_back(tmp);
139  }
140  }
141 
142  return true;
143 }
const CCopasiVector< CLTextGlyph > & getListOfTextGlyphs() const
Definition: CLayout.h:120
virtual size_t size() const
Definition: CMetab.h:178
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
virtual const std::string & getKey() const
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
std::vector< CoordinateRelation > mFixedRelations
a list of fixed positon relations between objects. Should be constructed in initFromLayout() ...
std::map< CLBase *, CLCompartmentGlyph * > mCompartmentMap
this map contains information about the compartment glyph a given glyph is located in ...
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
CLCompartmentGlyph * findCompartmentForReactionNode(CLReactionGlyph &r)
double CCopasiSpringLayout::potEdge ( const CLMetabReferenceGlyph e,
const CLReactionGlyph r 
) const
protected

Definition at line 573 of file CCopasiSpringLayout.cpp.

References distance(), CLGraphicalObject::getHeight(), CLMetabReferenceGlyph::getMetabGlyph(), CLMetabReferenceGlyph::getRole(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), CLGraphicalObject::getY(), CLMetabReferenceGlyph::MODIFIER, mpPar, CLMetabReferenceGlyph::SIDEPRODUCT, CLMetabReferenceGlyph::SIDESUBSTRATE, and CCopasiSpringLayout::Parameters::values.

Referenced by getPotential().

574 {
575  double dist = mpPar->values[1];
576 
578  dist = mpPar->values[3];
579 
580  const CLMetabGlyph * pMG = e.getMetabGlyph();
581  double tmp = distance(pMG->getX() + pMG->getWidth() / 2, pMG->getY() + pMG->getHeight() / 2,
582  r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2);
583 
585  return mpPar->values[4] * pow(tmp - dist, 2);
586  else
587  return mpPar->values[2] * pow(tmp - dist, 2);
588 }
const C_FLOAT64 & getX() const
static double distance(const double &x1, const double &y1, const double &x2, const double &y2)
CLMetabGlyph * getMetabGlyph() const
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potGeneralEdge ( const CLReferenceGlyph e,
const CLGeneralGlyph r 
) const
protected

Definition at line 600 of file CCopasiSpringLayout.cpp.

References distance(), CLGraphicalObject::getHeight(), CLReferenceGlyph::getTargetGlyph(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

601 {
602  double dist = 30;
603 
604  const CLGraphicalObject * pMG = e.getTargetGlyph();
605  double tmp = distance(pMG->getX() + pMG->getWidth() / 2, pMG->getY() + pMG->getHeight() / 2,
606  r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2);
607 
608  return pow(tmp - dist, 2);
609 }
const C_FLOAT64 & getX() const
static double distance(const double &x1, const double &y1, const double &x2, const double &y2)
CLGraphicalObject * getTargetGlyph() const
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potReactionCompartment ( const CLReactionGlyph r,
const CLCompartmentGlyph c 
) const
protected

s.charge

Definition at line 676 of file CCopasiSpringLayout.cpp.

References CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

677 {
678  double tmp = 0;
679  double dist = fabs((r.getX() + 0.5 * r.getWidth()) - (c.getX() + 0.5 * c.getWidth()));
680 
681  if (dist > (0.5 * c.getWidth() - 50))
682  tmp += pow(dist - 0.5 * c.getWidth() + 50, 2);
683 
684  dist = fabs((r.getY() + 0.5 * r.getHeight()) - (c.getY() + 0.5 * c.getHeight()));
685 
686  if (dist > (0.5 * c.getHeight() - 50))
687  tmp += pow(dist - 0.5 * c.getHeight() + 50, 2);
688 
689  return tmp /**s.charge*/; //TODO reintroduce charge
690 }
const C_FLOAT64 & getX() const
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potReactionReaction ( const CLReactionGlyph a,
const CLReactionGlyph b 
) const
protected

Definition at line 563 of file CCopasiSpringLayout.cpp.

References bound_distance(), CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

564 {
565  double tmp = bound_distance(a.getX() + a.getWidth() / 2, a.getY() + a.getHeight() / 2,
566  b.getX() + b.getWidth() / 2, b.getY() + b.getHeight() / 2, 200);
567 
568  if (tmp < 1) tmp = 1;
569 
570  return /*a.charge*b.charge*/ 1 / tmp; //TODO: reintroduce the charge
571 }
const C_FLOAT64 & getX() const
const C_FLOAT64 & getWidth() const
static double bound_distance(const double &x1, const double &y1, const double &x2, const double &y2, const double &max)
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potSecondOrderEdge ( const CLMetabReferenceGlyph e1,
const CLMetabReferenceGlyph e2,
double &  dist 
) const
protected

Definition at line 590 of file CCopasiSpringLayout.cpp.

References distance(), CLGraphicalObject::getHeight(), CLMetabReferenceGlyph::getMetabGlyph(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

591 {
592  const CLMetabGlyph * pMG1 = e1.getMetabGlyph();
593  const CLMetabGlyph * pMG2 = e2.getMetabGlyph();
594  double tmp = distance(pMG1->getX() + pMG1->getWidth() / 2, pMG1->getY() + pMG1->getHeight() / 2,
595  pMG2->getX() + pMG2->getWidth() / 2, pMG2->getY() + pMG2->getHeight() / 2);
596 
597  return pow(tmp - dist, 2);
598 }
const C_FLOAT64 & getX() const
static double distance(const double &x1, const double &y1, const double &x2, const double &y2)
CLMetabGlyph * getMetabGlyph() const
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potSpeciesCompartment ( const CLMetabGlyph s,
const CLCompartmentGlyph c 
) const
protected

s.charge

Definition at line 660 of file CCopasiSpringLayout.cpp.

References CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

661 {
662  double tmp = 0;
663  double dist = fabs((s.getX() + 0.5 * s.getWidth()) - (c.getX() + 0.5 * c.getWidth()));
664 
665  if (dist > (0.5 * c.getWidth() - 50))
666  tmp += pow(dist - 0.5 * c.getWidth() + 50, 2);
667 
668  dist = fabs((s.getY() + 0.5 * s.getHeight()) - (c.getY() + 0.5 * c.getHeight()));
669 
670  if (dist > (0.5 * c.getHeight() - 50))
671  tmp += pow(dist - 0.5 * c.getHeight() + 50, 2);
672 
673  return tmp /**s.charge*/; //TODO reintroduce charge
674 }
const C_FLOAT64 & getX() const
const C_FLOAT64 & getWidth() const
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potSpeciesReaction ( const CLMetabGlyph a,
const CLReactionGlyph b 
) const
protected

Definition at line 553 of file CCopasiSpringLayout.cpp.

References bound_distance(), CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

554 {
555  double tmp = bound_distance(a.getX() + a.getWidth() / 2, a.getY() + a.getHeight() / 2,
556  b.getX() + b.getWidth() / 2, b.getY() + b.getHeight() / 2, 200);
557 
558  if (tmp < 1) tmp = 1;
559 
560  return /*a.charge*b.charge*/ 1 / tmp; //TODO: reintroduce the charge
561 }
const C_FLOAT64 & getX() const
const C_FLOAT64 & getWidth() const
static double bound_distance(const double &x1, const double &y1, const double &x2, const double &y2, const double &max)
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
double CCopasiSpringLayout::potSpeciesSpecies ( const CLMetabGlyph a,
const CLMetabGlyph b 
) const
protected

Definition at line 542 of file CCopasiSpringLayout.cpp.

References bound_distance(), CLGraphicalObject::getHeight(), CLGraphicalObject::getWidth(), CLGraphicalObject::getX(), and CLGraphicalObject::getY().

Referenced by getPotential().

543 {
544  double tmp;
545  tmp = bound_distance(a.getX() + a.getWidth() / 2, a.getY() + a.getHeight() / 2,
546  b.getX() + b.getWidth() / 2, b.getY() + b.getHeight() / 2, 200);
547 
548  if (tmp < 1) tmp = 1;
549 
550  return /*a.charge*b.charge*/ 1 / tmp; //TODO: reintroduce the charge
551 }
const C_FLOAT64 & getX() const
const C_FLOAT64 & getWidth() const
static double bound_distance(const double &x1, const double &y1, const double &x2, const double &y2, const double &max)
const C_FLOAT64 & getY() const
const C_FLOAT64 & getHeight() const
void CCopasiSpringLayout::randomize ( )

Randomizes the layout

This function produces a random layout. It first shufles around metab glyphs and reaction centers, and finally corrects all ars

Definition at line 905 of file CCopasiSpringLayout.cpp.

References CRandom::createGenerator(), finalizeState(), CMetab::getCompartment(), CLayout::getDimensions(), CModelEntity::getKey(), CLayout::getListOfCompartmentGlyphs(), CLayout::getListOfMetaboliteGlyphs(), CLReactionGlyph::getListOfMetabReferenceGlyphs(), CLayout::getListOfReactionGlyphs(), CLGraphicalObject::getModelObject(), CRandom::getRandomCC(), CRandom::getSystemSeed(), mpLayout, CRandom::mt19937, placeTextGlyphs(), randomlyPlaceGlyphInCompartmentGlyph(), randomlyPlaceGlyphInDimensions(), CLGraphicalObject::setPosition(), and CCopasiVector< T >::size().

Referenced by createLayout(), and CQLayoutThread::randomizeLayout().

906 {
908 
909  size_t i;
910 
911  //compartment glyphs
912 
913  //metab glyphs
914  for (i = 0; i < mpLayout->getListOfMetaboliteGlyphs().size(); ++i)
915  {
916  CLMetabGlyph* pMetabGlyph = mpLayout->getListOfMetaboliteGlyphs()[i];
917  const CMetab* pMetab = dynamic_cast<const CMetab*>(pMetabGlyph->getModelObject());
918 
919  if (!pMetab)
920  continue;
921 
922  //find the compartment glyph
923  const CCompartment* pComp = pMetab->getCompartment();
924 
925  if (!pComp)
926  continue;
927 
928  const CLCompartmentGlyph* pCompGlyph = NULL;
929  size_t j;
930 
931  for (j = 0; j < mpLayout->getListOfCompartmentGlyphs().size(); ++j)
932  if (mpLayout->getListOfCompartmentGlyphs()[j]->getModelObjectKey()
933  == pComp->getKey())
934  {
935  pCompGlyph = mpLayout->getListOfCompartmentGlyphs()[j];
936  break;
937  }
938 
939  if (pCompGlyph)
940  randomlyPlaceGlyphInCompartmentGlyph(pMetabGlyph, pCompGlyph, pRandom);
941  else
942  randomlyPlaceGlyphInDimensions(pMetabGlyph, &mpLayout->getDimensions(), pRandom);
943  }
944 
945  //reaction glyphs
946  for (i = 0; i < mpLayout->getListOfReactionGlyphs().size(); ++i)
947  {
948  CLReactionGlyph* pReactionGlyph = mpLayout->getListOfReactionGlyphs()[i];
949  CLPoint center(0, 0);
950  size_t count;
951 
952  for (count = 0; count < pReactionGlyph->getListOfMetabReferenceGlyphs().size(); ++count)
953  center = center + pReactionGlyph->getListOfMetabReferenceGlyphs()[count]
954  ->getMetabGlyph()->getBoundingBox().getCenter();
955 
956  center = center * (1.0 / pReactionGlyph->getListOfMetabReferenceGlyphs().size());
957  center = center + CLPoint(pRandom->getRandomCC() * 20 - 10, pRandom->getRandomCC() * 20 - 10);
958 
959  pReactionGlyph->setPosition(center);
960 
961  /*if (pCompGlyph)
962  randomlyPlaceGlyphInCompartmentGlyph(pMetabGlyph, pCompGlyph);
963  else
964  randomlyPlaceGlyphInDimensions(pMetabGlyph, &mpCurrentLayout->getDimensions());*/
965  }
966 
968  delete pRandom;
969 
970  finalizeState();
971 }
static unsigned C_INT32 getSystemSeed()
Definition: CRandom.cpp:136
virtual size_t size() const
void randomlyPlaceGlyphInDimensions(CLGraphicalObject *pGl, const CLDimensions *pContainer, CRandom *pRandom)
Definition: CMetab.h:178
const CCopasiVector< CLCompartmentGlyph > & getListOfCompartmentGlyphs() const
Definition: CLayout.h:81
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
Definition: CRandom.cpp:49
virtual C_FLOAT64 getRandomCC()
Definition: CRandom.cpp:235
Definition: CLBase.h:54
virtual const std::string & getKey() const
void placeTextGlyphs(CLayout *pLayout)
const CCopasiVector< CLMetabGlyph > & getListOfMetaboliteGlyphs() const
Definition: CLayout.h:94
void setPosition(const CLPoint &p)
CCopasiObject * getModelObject() const
const CCopasiVector< CLMetabReferenceGlyph > & getListOfMetabReferenceGlyphs() const
void randomlyPlaceGlyphInCompartmentGlyph(CLGraphicalObject *pGl, const CLGraphicalObject *pContainer, CRandom *pRandom)
const CCompartment * getCompartment() const
Definition: CMetab.cpp:222
const CCopasiVector< CLReactionGlyph > & getListOfReactionGlyphs() const
Definition: CLayout.h:107
const CLDimensions & getDimensions() const
Definition: CLayout.h:76
bool CCopasiSpringLayout::setState ( const std::vector< double > &  vars)
virtual

updates the COPASI layout from the state vector. Only the updates that are needed for the calculation of the potential (or for a rough on the fly drawing) are done.

Implements CAbstractLayoutInterface.

Definition at line 315 of file CCopasiSpringLayout.cpp.

References CCopasiSpringLayout::UpdateAction::COMPARTMENT_4V, mUpdateActions, CAbstractLayoutInterface::mVarDescription, CCopasiSpringLayout::UpdateAction::POSITION_2V, and CCopasiSpringLayout::UpdateAction::REACTION_2V.

316 {
317  if (vars.size() < mVarDescription.size())
318  return false;
319 
320  std::vector<UpdateAction>::const_iterator it, itEnd = mUpdateActions.end();
321 
322  for (it = mUpdateActions.begin(); it != itEnd; ++it)
323  {
324  switch (it->mAction)
325  {
327  ((CLCompartmentGlyph*)(it->mpTarget))->setX(vars[it->mIndex1]);
328  ((CLCompartmentGlyph*)(it->mpTarget))->setY(vars[it->mIndex2]);
329  ((CLCompartmentGlyph*)(it->mpTarget))->setWidth(vars[it->mIndex3]);
330  ((CLCompartmentGlyph*)(it->mpTarget))->setHeight(vars[it->mIndex4]);
331  break;
332 
334  ((CLGraphicalObject*)(it->mpTarget))->setX(vars[it->mIndex1]);
335  ((CLGraphicalObject*)(it->mpTarget))->setY(vars[it->mIndex2]);
336  break;
337 
339  ((CLReactionGlyph*)(it->mpTarget))->setX(vars[it->mIndex1]);
340  ((CLReactionGlyph*)(it->mpTarget))->setY(vars[it->mIndex2]);
341  break;
342 
343  default:
344 #ifdef COPASI_DEBUG
345  std::cout << "Unknown Action!!!" << std::endl;
346 #endif
347  break;
348  };
349  }
350 
351  //If we assume that the position of the dependent (text) glyphs can have an influence
352  //on the layout we need to update them here.
353  //Currently we assume that is not the case and the update will be done in finalizeState();
354 
355  return true;
356 }
std::vector< UpdateAction > mUpdateActions
this is the list of all update actions that have to be performed during setState(); ...
std::vector< VariableDescription > mVarDescription

Member Data Documentation

std::map<CLBase*, CLCompartmentGlyph*> CCopasiSpringLayout::mCompartmentMap
protected

this map contains information about the compartment glyph a given glyph is located in

Definition at line 261 of file CCopasiSpringLayout.h.

Referenced by findCompartmentForReactionNode(), getPotential(), and initFromLayout().

std::vector<CoordinateRelation> CCopasiSpringLayout::mFixedRelations
protected

a list of fixed positon relations between objects. Should be constructed in initFromLayout()

Definition at line 275 of file CCopasiSpringLayout.h.

Referenced by finalizeState(), and initFromLayout().

std::vector<double> CCopasiSpringLayout::mInitialState
protected
CLayout* CCopasiSpringLayout::mpLayout
protected
Parameters* CCopasiSpringLayout::mpPar
protected

Definition at line 224 of file CCopasiSpringLayout.h.

Referenced by getPotential(), initFromLayout(), and potEdge().

std::vector<UpdateAction> CCopasiSpringLayout::mUpdateActions
protected

this is the list of all update actions that have to be performed during setState();

Definition at line 258 of file CCopasiSpringLayout.h.

Referenced by addCompartmentVariables(), addPositionVariables(), addReactionVariables(), getUpdateActions(), and setState().


The documentation for this class was generated from the following files: