COPASI API  4.16.103
CLImage.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layout/CLImage.cpp,v $
3 // $Revision: 1.5 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/04/23 15:44:51 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #include <sbml/packages/render/sbml/Image.h>
15 
16 #include "CLImage.h"
17 
20 
21 /**
22  * Constructor.
23  */
26  CCopasiObject("Image", pParent),
27  mX(CLRelAbsVector(0.0, 0.0)),
28  mY(CLRelAbsVector(0.0, 0.0)),
29  mZ(CLRelAbsVector(0.0, 0.0)),
30  mWidth(CLRelAbsVector(0.0, 0.0)),
31  mHeight(CLRelAbsVector(0.0, 0.0)),
32  mHRef(""),
33  mKey("")
34 {
35  this->mKey = CCopasiRootContainer::getKeyFactory()->add("Image", this);
36 }
37 
38 /**
39  * Copy Constructor.
40  */
41 CLImage::CLImage(const CLImage& source, CCopasiContainer* pParent):
42  CLTransformation2D(source),
43  CCopasiObject(source, pParent),
44  mX(source.mX),
45  mY(source.mY),
46  mZ(source.mZ),
47  mWidth(source.mWidth),
48  mHeight(source.mHeight),
49  mHRef(source.mHRef),
50  mKey("")
51 {
52  this->mKey = CCopasiRootContainer::getKeyFactory()->add("Image", this);
53 }
54 
55 /**
56  * Constructor to generate object from the corresponding SBML object.
57  */
58 CLImage::CLImage(const Image& source, CCopasiContainer* pParent):
59  CLTransformation2D(source),
60  CCopasiObject("Image", pParent),
61  mX(source.getX()),
62  mY(source.getY()),
63  mZ(source.getZ()),
64  mWidth(source.getWidth()),
65  mHeight(source.getHeight()),
66  mHRef(source.getImageReference()),
67  mKey("")
68 {
69  this->mKey = CCopasiRootContainer::getKeyFactory()->add("Image", this);
70 }
71 
72 /**
73  * Destructor
74  */
76 {
78 }
79 
80 /**
81  * Sets the dimensions.
82  */
83 void CLImage::setDimensions(const CLRelAbsVector& width, const CLRelAbsVector& height)
84 {
85  this->mWidth = width;
86  this->mHeight = height;
87 }
88 
89 /**
90  * Sets the width.
91  */
93 {
94  this->mWidth = width;
95 }
96 
97 /**
98  * Sets the height.
99  */
101 {
102  this->mHeight = height;
103 }
104 
105 /**
106  * Returns the width.
107  */
109 {
110  return this->mWidth;
111 }
112 
113 /**
114  * Returns the height.
115  */
117 {
118  return this->mHeight;
119 }
120 
121 /**
122  * Sets the reference to the image location.
123  */
124 void CLImage::setImageReference(const std::string& ref)
125 {
126  this->mHRef = ref;
127 }
128 
129 /**
130  * Returns the image reference.
131  */
132 const std::string& CLImage::getImageReference() const
133 {
134  return this->mHRef;
135 }
136 
137 /**
138  * Sets the coordinates.
139  */
141 {
142  this->mX = x;
143  this->mY = y;
144  this->mZ = z;
145 }
146 
147 /**
148  * Sets the x coordinate.
149  */
150 void CLImage::setX(const CLRelAbsVector& coord)
151 {
152  this->mX = coord;
153 }
154 
155 /**
156  * Sets the y coordinate.
157  */
158 void CLImage::setY(const CLRelAbsVector& coord)
159 {
160  this->mY = coord;
161 }
162 
163 /**
164  * Sets the z coordinate.
165  */
166 void CLImage::setZ(const CLRelAbsVector& coord)
167 {
168  this->mZ = coord;
169 }
170 
171 /**
172  * Returns the x coordinate.
173  */
175 {
176  return this->mX;
177 }
178 
179 /**
180  * Returns the y coordinate.
181  */
183 {
184  return this->mY;
185 }
186 
187 /**
188  * Returns the z coordinate.
189  */
191 {
192  return this->mZ;
193 }
194 
195 /**
196  * Returns the x coordinate.
197  */
199 {
200  return this->mX;
201 }
202 
203 /**
204  * Returns the y coordinate.
205  */
207 {
208  return this->mY;
209 }
210 
211 /**
212  * Returns the z coordinate.
213  */
215 {
216  return this->mZ;
217 }
218 
219 /**
220  * Returns true if the image reference has been set.
221  */
223 {
224  std::string space = " \t\n\r";
225  // the string may not be empty and it may not only contain whitespaces
226  return (!this->mHRef.empty() && (this->mHRef.find_first_not_of(space) != std::string::npos));
227 }
228 
229 /**
230  * Returns the key of the color definition.
231  */
232 const std::string& CLImage::getKey() const
233 {
234  return this->mKey;
235 }
236 
237 /**
238  * Converts this object to the corresponding SBML object.
239  */
240 Image* CLImage::toSBML(unsigned int level, unsigned int version) const
241 {
242  Image* pImg = new Image(level, version);
243  this->addSBMLAttributes(pImg);
244  RelAbsVector* pV = this->mX.toSBML();
245  pImg->setX(*pV);
246  delete pV;
247  pV = this->mY.toSBML();
248  pImg->setY(*pV);
249  delete pV;
250  pV = this->mZ.toSBML();
251  pImg->setZ(*pV);
252  delete pV;
253  pV = this->mWidth.toSBML();
254  pImg->setWidth(*pV);
255  delete pV;
256  pV = this->mHeight.toSBML();
257  pImg->setHeight(*pV);
258  delete pV;
259  pImg->setImageReference(this->mHRef);
260  return pImg;
261 }
CLRelAbsVector & getX()
Definition: CLImage.cpp:198
bool remove(const std::string &key)
const std::string & getKey() const
Definition: CLImage.cpp:232
CLImage(CCopasiContainer *pParent=NULL)
Definition: CLImage.cpp:24
CLRelAbsVector mY
Definition: CLImage.h:34
const CLRelAbsVector & getHeight() const
Definition: CLImage.cpp:116
virtual void addSBMLAttributes(Transformation2D *pTransformation) const
CLRelAbsVector & getY()
Definition: CLImage.cpp:206
~CLImage()
Definition: CLImage.cpp:75
void setZ(const CLRelAbsVector &coord)
Definition: CLImage.cpp:166
const std::string & getImageReference() const
Definition: CLImage.cpp:132
std::string mKey
Definition: CLImage.h:43
void setImageReference(const std::string &ref)
Definition: CLImage.cpp:124
RelAbsVector * toSBML() const
void setY(const CLRelAbsVector &coord)
Definition: CLImage.cpp:158
void setWidth(const CLRelAbsVector &width)
Definition: CLImage.cpp:92
Image * toSBML(unsigned int level, unsigned int version) const
Definition: CLImage.cpp:240
std::string add(const std::string &prefix, CCopasiObject *pObject)
CLRelAbsVector mZ
Definition: CLImage.h:35
const CLRelAbsVector & getWidth() const
Definition: CLImage.cpp:108
void setX(const CLRelAbsVector &coord)
Definition: CLImage.cpp:150
CLRelAbsVector & getZ()
Definition: CLImage.cpp:214
static CKeyFactory * getKeyFactory()
bool isSetImageReference() const
Definition: CLImage.cpp:222
CLRelAbsVector mHeight
Definition: CLImage.h:37
void setCoordinates(const CLRelAbsVector &x, const CLRelAbsVector &y, const CLRelAbsVector &z=CLRelAbsVector(0.0, 0.0))
Definition: CLImage.cpp:140
void setHeight(const CLRelAbsVector &height)
Definition: CLImage.cpp:100
CLRelAbsVector mWidth
Definition: CLImage.h:36
void setDimensions(const CLRelAbsVector &width, const CLRelAbsVector &height)
Definition: CLImage.cpp:83
CLRelAbsVector mX
Definition: CLImage.h:33
std::string mHRef
Definition: CLImage.h:38