COPASI API  4.16.103
CLabel.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layoutUI/CLabel.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/12/13 19:49:57 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 #include "CLabel.h"
20 
21 #include "copasi.h"
22 
24 
26  : CLTextGlyph()
27 {
29 }
30 
32  : CLTextGlyph(tg)
33 {
35 }
36 
38  : CLTextGlyph(l)
39 {
41 }
42 
44 {
45  orig_x = this->getX();
46  orig_y = this->getY();
47  orig_width = this->getWidth();
48  orig_height = this->getHeight();
49 }
50 
51 // scale original values (not the current position/dimensions)
52 void CLabel::scale(const double & scaleFactor)
53 {
54  this->setX(this->orig_x * scaleFactor);
55  this->setY(this->orig_y * scaleFactor);
56  this->setWidth(this->orig_width * scaleFactor);
57  this->setHeight(this->orig_height * scaleFactor);
58 }
59 
60 // set height of mBBox to new value given by the only parameter and scale width of box
61 // so that ration is preserved
62 void CLabel::adaptToHeight(const double & h)
63 {
64  C_FLOAT64 scaleFactor = h / mBBox.getDimensions().getHeight();
65  C_FLOAT64 w = mBBox.getDimensions().getWidth() * scaleFactor;
67 }
68 
69 void CLabel::scalePosition(const double & z)
70 {
71  this->mBBox.getPosition().setX(this->mBBox.getPosition().getX() * z);
72  this->mBBox.getPosition().setY(this->mBBox.getPosition().getY() * z);
73 }
74 /**
75  * Since labels are not part of the model, we can't use the new method for
76  * getting the text but have to fall back to the old
77  * behavior.
78  * Hopefully I can get rid of this implementation sonner than later.
79  */
80 std::string CLabel::getText() const
81 {
82  if (mIsTextSet)
83  {
84  return mText;
85  }
86  else
87  {
89 
90  if (pObject)
91  {
92  return pObject->getObjectName();
93  }
94  else
95  {
96  return "unset";
97  }
98  }
99 }
100 
101 
const C_FLOAT64 & getWidth() const
Definition: CLBase.h:211
std::string mModelObjectKey
void setX(const C_FLOAT64 &x)
Definition: CLBase.h:91
const std::string & getObjectName() const
C_FLOAT64 orig_width
Definition: CLabel.h:32
void initOrigValues()
Definition: CLabel.cpp:43
CCopasiObject * get(const std::string &key)
const C_FLOAT64 & getX() const
void setY(const C_FLOAT64 &y)
CLabel()
Definition: CLabel.cpp:25
void setY(const C_FLOAT64 &y)
Definition: CLBase.h:92
bool mIsTextSet
Definition: CLGlyphs.h:126
void adaptToHeight(const double &h)
Definition: CLabel.cpp:62
const CLDimensions & getDimensions() const
Definition: CLBase.h:266
const C_FLOAT64 & getX() const
Definition: CLBase.h:83
void setDimensions(const CLDimensions &d)
Definition: CLBase.h:273
CLBoundingBox mBBox
const CLPoint & getPosition() const
Definition: CLBase.h:265
C_FLOAT64 orig_height
Definition: CLabel.h:33
virtual std::string getText() const
Definition: CLabel.cpp:80
const C_FLOAT64 & getWidth() const
void setHeight(const C_FLOAT64 &h)
const C_FLOAT64 & getY() const
Definition: CLBase.h:84
const C_FLOAT64 & getY() const
C_FLOAT64 orig_y
Definition: CLabel.h:31
static CKeyFactory * getKeyFactory()
Definition: CLabel.h:27
const C_FLOAT64 & getHeight() const
Definition: CLBase.h:212
#define C_FLOAT64
Definition: copasi.h:92
virtual void scale(const double &scaleFactor)
Definition: CLabel.cpp:52
void scalePosition(const double &hz)
Definition: CLabel.cpp:69
std::string mText
Definition: CLGlyphs.h:127
void setWidth(const C_FLOAT64 &w)
const C_FLOAT64 & getHeight() const
void setX(const C_FLOAT64 &x)
C_FLOAT64 orig_x
Definition: CLabel.h:30