COPASI API  4.16.103
CLColorDefinition.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layout/CLColorDefinition.h,v $
3 // $Revision: 1.4 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/09/30 16:35:21 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 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 #ifndef CLColorDefinition_H__
15 #define CLColorDefinition_H__
16 
17 #include <string>
18 
19 #include "copasi/layout/CLBase.h"
21 
22 class ColorDefinition;
23 class CCopasiContainer;
24 
25 class CLColorDefinition : public CLBase, public CCopasiObject
26 {
27 private:
28  // preent the compiler from generating the assignment operator
30 
31 protected:
32  // id is inherited from SBase
33  unsigned char mRed;
34  unsigned char mGreen;
35  unsigned char mBlue;
36  unsigned char mAlpha;
37 
38  /**
39  * The color definition needs a key.
40  */
41  std::string mKey;
42 
43  /**
44  * The color definition needs an id in addition to the key.
45  * The id corresponds to the id in the SBML render extension and it does not have to
46  * be globally unique. As a matter of fact, it is sometimes needed that color definitions of
47  * different render information have the same id.
48  */
49  std::string mId;
50 
51 public:
52  /**
53  * Contructor which sets the ColorDefinition to completely opaque
54  * black.
55  */
56  CLColorDefinition(CCopasiContainer* pParent = NULL);
57 
58  /**
59  * Constructor which sets the ColorDefinition to the given RGBA values.
60  */
61  CLColorDefinition(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255, CCopasiContainer* pParent = NULL);
62 
63  /**
64  * Copy Contructor
65  */
66  CLColorDefinition(const CLColorDefinition& source, CCopasiContainer* pParent = NULL);
67 
68  /**
69  * Constructor to generate object from the corresponding SBML object.
70  */
71  CLColorDefinition(const ColorDefinition& source, CCopasiContainer* pParent = NULL);
72 
73  virtual ~CLColorDefinition();
74 
75  /**
76  * Returns the red color component.
77  */
78  unsigned char getRed() const;
79 
80  /**
81  * Returns the green color component.
82  */
83  unsigned char getGreen() const;
84 
85  /**
86  * Returns the blue color component.
87  */
88  unsigned char getBlue() const;
89 
90  /**
91  * Returns the alpha color component.
92  */
93  unsigned char getAlpha() const;
94 
95  /**
96  * Sets the red color component.
97  */
98  void setRed(unsigned char c);
99 
100  /**
101  * Sets the green color component.
102  */
103  void setGreen(unsigned char c);
104 
105  /**
106  * Sets the blue color component.
107  */
108  void setBlue(unsigned char c);
109 
110  /**
111  * Sets alpha red color component.
112  */
113  void setAlpha(unsigned char c);
114 
115  /**
116  * Sets the red green, blue and alpha color component.
117  * The alpha value is optional and defaults to 255 if not given.
118  */
119  void setRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255);
120 
121  /**
122  * Sets the color value from a given string.
123  * If the string is not a valid value string, the color value is set to
124  * black and false is returned.
125  */
126  bool setColorValue(const std::string& valueString);
127 
128  /**
129  * Creates a string the represents the current color value.
130  */
131  std::string createValueString() const;
132 
133  /**
134  * Returns the key of the color definition.
135  */
136  const std::string& getKey() const;
137 
138  /**
139  * Converts this object to the corresponding SBML object.
140  */
141  ColorDefinition* toSBML(unsigned int level, unsigned int version) const;
142 
143  /**
144  * Returns the id of the object.
145  */
146  const std::string& getId() const;
147 
148  /**
149  * Sets the id of the object.
150  */
151  void setId(const std::string& id);
152 };
153 
154 #endif /* CLColorDefinition_H__ */
void setBlue(unsigned char c)
void setRed(unsigned char c)
unsigned char mAlpha
const std::string & getKey() const
bool setColorValue(const std::string &valueString)
unsigned char getBlue() const
unsigned char mRed
CLColorDefinition(CCopasiContainer *pParent=NULL)
unsigned char mGreen
unsigned char getGreen() const
void setRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Definition: CLBase.h:33
unsigned char mBlue
unsigned char getRed() const
void setId(const std::string &id)
unsigned char getAlpha() const
void setAlpha(unsigned char c)
std::string createValueString() const
CLColorDefinition & operator=(const CLColorDefinition &source)
const std::string & getId() const
void setGreen(unsigned char c)
ColorDefinition * toSBML(unsigned int level, unsigned int version) const