COPASI API  4.16.103
CSlider.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/utilities/CSlider.h,v $
3 // $Revision: 1.16 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/10/31 14:25:58 $
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 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CSlider
24 #define COPASI_CSlider
25 
28 
29 class CSlider : public CCopasiContainer
30 {
31 public:
32  /**
33  * Enum of valid quantitye units
34  */
36 
37  /**
38  * Enum of valid scales
39  */
41 
42  /**
43  * String representation of valid quantity units
44  */
45  static const char * TypeName[];
46 
47  /**
48  * String representation of valid scalings
49  */
50  static const char * ScaleName[];
51 
52  // Operations
53 public:
54  /**
55  * Default constructor
56  * @param const std::string & name (default: "NoName")
57  * @param const CCopasiContainer * pParent (default: NULL)
58  */
59  CSlider(const std::string & name = "Slider",
60  const CCopasiContainer * pParent = NULL);
61 
62  /**
63  * Copy constructor
64  * @param const CSlider & src
65  * @param const CCopasiContainer * pParent (default: NULL)
66  */
67  CSlider(const CSlider & src,
68  const CCopasiContainer * pParent = NULL);
69 
70  /**
71  * Destructor.
72  */
73  ~CSlider();
74 
75  /**
76  * Compile, i.e., find the objects pointed to by the CN.
77  * @param const std::vector< CCopasiContainer * > & listOfContainer
78  * (default: CCopasiContainer::EmptyList)
79  * @return bool success
80  */
81  bool compile(const std::vector< CCopasiContainer * > & listOfContainer = CCopasiContainer::EmptyList);
82 
83  /**
84  * Retrieve the key
85  * @return const std::string & key
86  */
87  const std::string & getKey() const;
88 
89  /**
90  * Set the key of the associated entity
91  * @param const std::string & associatedEntityKey
92  * @return bool succes
93  */
94  bool setAssociatedEntityKey(const std::string & associatedEntityKey);
95 
96  /**
97  * Retrieve the key of the associated entity.
98  * @return const std::string & associatedEntityKey
99  */
100  const std::string & getAssociatedEntityKey() const;
101 
102  /**
103  * Set the slider object.
104  * @param CCopasiObject * pObject
105  * @return bool succes
106  */
107  bool setSliderObject(CCopasiObject * pObject);
108 
109  /**
110  * Set the slider object.
111  * @param const CCopasiObjectName & objectCN
112  * @return bool succes
113  */
114  bool setSliderObject(const CCopasiObjectName & objectCN);
115 
116  /**
117  * Retrieve the slider object.
118  * @return CCopasiObject * pObject
119  */
121 
122  /**
123  * Retrieve the slider object CN.
124  * @return const std::string & sliderObjectCN
125  */
126  const std::string & getSliderObjectCN() const;
127 
128  /**
129  * Set the slider type.
130  * @param const CSlider::Type type
131  * @return bool succes
132  */
133  bool setSliderType(const CSlider::Type type);
134 
135  /**
136  * Retrieve the slider type.
137  * @return const CSlider::Type type
138  */
140 
141  /**
142  * Set the sliders original value.
143  * @param const C_FLOAT64 Value
144  * @param const bool & writeToObject (Default: true)
145  * @return bool succes
146  */
147  bool setOriginalValue(const C_FLOAT64 value);
148 
149  /**
150  * Retrieve the original slider Value.
151  * @return const C_FLOAT64 Value
152  */
153  const C_FLOAT64 & getOriginalValue() const;
154 
155  /**
156  * Set the slider value.
157  * @param const C_FLOAT64 Value
158  * @param const bool & writeToObject (Default: true)
159  * @return bool succes
160  */
161  bool setSliderValue(const C_FLOAT64 value,
162  const bool & writeToObject = true);
163 
164  /**
165  * Sets the value of the slider back to it's original
166  * value.
167  */
168  void resetValue();
169 
170  /**
171  * Retrieve the slider Value.
172  * @return const C_FLOAT64 Value
173  */
174  const C_FLOAT64 & getSliderValue() const;
175 
176  /**
177  * Set the slider minimum value.
178  * @param const C_FLOAT64 minValue
179  * @return bool succes
180  */
181  bool setMinValue(const C_FLOAT64 minValue);
182 
183  /**
184  * Retrieve the slider minimum value.
185  * @return const C_FLOAT64 minValue
186  */
187  const C_FLOAT64 & getMinValue() const;
188 
189  /**
190  * Set the slider maximum value.
191  * @param const C_FLOAT64 maxValue
192  * @return bool succes
193  */
194  bool setMaxValue(const C_FLOAT64 maxValue);
195 
196  /**
197  * Retrieve the slider maximum value.
198  * @return const C_FLOAT64 & maxValue
199  */
200  const C_FLOAT64 & getMaxValue() const;
201 
202  /**
203  * Set the tick number.
204  * @param const unsigned C_INT32 & tickNumber
205  * @return bool succes
206  */
207  bool setTickNumber(const unsigned C_INT32 tickNumber);
208 
209  /**
210  * Retrieve the tick number.
211  * @return const unsigned C_INT32 & tickNumber
212  */
213  unsigned C_INT32 getTickNumber() const;
214 
215  /**
216  * Set the tick factor.
217  * @param const unsigned C_INT32 & tickFactor
218  * @return bool succes
219  */
220  bool setTickFactor(const unsigned C_INT32 tickFactor);
221 
222  /**
223  * Retrieve the tick factor.
224  * @return const unsigned C_INT32 & tickFactor
225  */
226  unsigned C_INT32 getTickFactor() const;
227 
228  /**
229  * Set the scaling for the CSlider.
230  */
231  bool setScaling(Scale scaling);
232 
233  /**
234  * Retrieve the scaling of the slider.
235  * @return Scale scaling
236  */
237  Scale getScaling() const;
238 
239  /**
240  * Reset the minimum and maximum value to defaults. For the minimum this is
241  * half the current value. For the maximum this is twice the current value.
242  */
243  void resetRange();
244 
245  /**
246  * Sets wether the value is to be kept in sync the the objects value.
247  */
248  void setSynced(bool synced);
249 
250  /**
251  * Returns wether the value is to be kept in sync the the objects value.
252  * @return bool isSynced.
253  */
254  bool getSynced() const;
255 
256  /**
257  * Set the CSliders value to the value of the underlying object.
258  */
259  void sync();
260 
261  /**
262  * Set the objects value to the value stored in CSlider.
263  */
264  void writeToObject();
265 
266  /**
267  * Converts the scaling name to the corresponding enum.
268  * @return CSlider::Scale
269  */
270  Scale convertScaleNameToScale(const char* scaleName);
271 
272  /**
273  * Converts the scaling name to the corresponding enum.
274  * @return const char* scaleName
275  */
276  const char* convertScaleToScaleName(Scale scale);
277 
278 
279  /**
280  * Checks whether the object the slider points to actually
281  * exists.
282  * Returns true if it does.
283  */
284  bool isValid() const;
285 
286  // Attributes
287 private:
288  /**
289  * The key of the slider.
290  */
291  std::string mKey;
292 
293  /**
294  * The key of the associated entity of the slider's object.
295  */
296  std::string mAssociatedEntityKey;
297 
298  /**
299  * The slider object pointing to the slider's object afteer compile.
300  */
302 
303  /**
304  * The value type of the slider's object.
305  */
307 
308  /**
309  * The value of the slider-
310  */
312 
313  /**
314  * The original value of the slider-
315  */
317 
318  /**
319  * The minimun value of the slider
320  */
322 
323  /**
324  * The maximum value of the slider
325  */
327 
328  /**
329  * The number of ticks the slider is divided into.
330  */
332 
333  /**
334  * The factor between minor and major ticks.
335  */
337 
338  /**
339  * Wether the CSlider's value is always in sync with its object's value.
340  */
341  bool mSync;
342 
343  /**
344  * The scaling of the slider.
345  */
347 
348  /**
349  * The CN of the object that the slider modifies.
350  */
352 
353  /**
354  * The sequnece of methods to update initial values depending on this sliders
355  * object.
356  */
357  std::vector< Refresh * > mInitialRefreshes;
358 };
359 
360 #endif
bool compile(const std::vector< CCopasiContainer * > &listOfContainer=CCopasiContainer::EmptyList)
Definition: CSlider.cpp:69
C_FLOAT64 mValue
Definition: CSlider.h:311
const char * convertScaleToScaleName(Scale scale)
Definition: CSlider.cpp:396
bool setScaling(Scale scaling)
Definition: CSlider.cpp:374
bool getSynced() const
Definition: CSlider.cpp:86
unsigned C_INT32 mTickNumber
Definition: CSlider.h:331
CSlider(const std::string &name="Slider", const CCopasiContainer *pParent=NULL)
Definition: CSlider.cpp:30
bool setSliderObject(CCopasiObject *pObject)
Definition: CSlider.cpp:104
bool setOriginalValue(const C_FLOAT64 value)
Definition: CSlider.cpp:191
bool setMaxValue(const C_FLOAT64 maxValue)
Definition: CSlider.cpp:323
const std::string & getSliderObjectCN() const
Definition: CSlider.cpp:179
const std::string & getAssociatedEntityKey() const
Definition: CSlider.cpp:101
const std::string & getKey() const
Definition: CSlider.cpp:91
C_FLOAT64 mOriginalValue
Definition: CSlider.h:316
void setSynced(bool synced)
Definition: CSlider.cpp:81
CSlider::Type getSliderType() const
Definition: CSlider.cpp:188
#define C_INT32
Definition: copasi.h:90
bool setTickFactor(const unsigned C_INT32 tickFactor)
Definition: CSlider.cpp:360
static const char * TypeName[]
Definition: CSlider.h:45
Type mSliderType
Definition: CSlider.h:306
bool mSync
Definition: CSlider.h:341
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
std::string mAssociatedEntityKey
Definition: CSlider.h:296
bool isValid() const
Definition: CSlider.cpp:408
bool setAssociatedEntityKey(const std::string &associatedEntityKey)
Definition: CSlider.cpp:94
bool setSliderType(const CSlider::Type type)
Definition: CSlider.cpp:182
static const std::vector< CCopasiContainer * > EmptyList
static const char * ScaleName[]
Definition: CSlider.h:50
void resetValue()
Definition: CSlider.cpp:154
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
void writeToObject()
Definition: CSlider.cpp:265
std::vector< Refresh * > mInitialRefreshes
Definition: CSlider.h:357
const C_FLOAT64 & getOriginalValue() const
Definition: CSlider.cpp:285
Header file of class CCopasiContainer.
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
bool setTickNumber(const unsigned C_INT32 tickNumber)
Definition: CSlider.cpp:351
~CSlider()
Definition: CSlider.cpp:66
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mMinValue
Definition: CSlider.h:321
void sync()
Definition: CSlider.cpp:245
std::string mKey
Definition: CSlider.h:291
bool setMinValue(const C_FLOAT64 minValue)
Definition: CSlider.cpp:295
unsigned C_INT32 mTickFactor
Definition: CSlider.h:336
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
bool setSliderValue(const C_FLOAT64 value, const bool &writeToObject=true)
Definition: CSlider.cpp:215
void resetRange()
Definition: CSlider.cpp:159
unsigned C_INT32 getTickFactor() const
Definition: CSlider.cpp:366
Scale getScaling() const
Definition: CSlider.cpp:369
CRegisteredObjectName mCN
Definition: CSlider.h:351
Scale convertScaleNameToScale(const char *scaleName)
Definition: CSlider.cpp:380
CCopasiObject * getSliderObject()
Definition: CSlider.cpp:176
Scale mScaling
Definition: CSlider.h:346