CRgb.h
Go to the documentation of this file.
1 #ifndef icmm_CRgb_included
2 #define icmm_CRgb_included
3 
4 
5 // ACF includes
6 #include <iser/IArchive.h>
7 #include <icmm/TComposedColor.h>
8 
9 
10 namespace icmm
11 {
12 
13 
18 class CRgb: public TComposedColor<3>
19 {
20 public:
22 
24  {
29  };
30 
31  CRgb(double r = 0.0, double g = 0.0, double b = 0.0);
32  CRgb(const CRgb& color);
33 
34  // access to component values
35  double GetRed() const;
36  void SetRed(double value);
37  double GetGreen() const;
38  void SetGreen(double value);
39  double GetBlue() const;
40  void SetBlue(double value);
41 
42  bool Serialize(iser::IArchive& archive);
43 
44  // operators
45  CRgb operator+(const CRgb& color) const;
46  CRgb operator-(const CRgb& color) const;
47  CRgb operator*(const CRgb& color) const;
48  CRgb operator/(const CRgb& color) const;
49 
50  CRgb operator*(double value) const;
51  CRgb operator/(double value) const;
52 
53  CRgb& operator=(const CRgb& color);
54 
55  const CRgb& operator+=(const CRgb& color);
56  const CRgb& operator-=(const CRgb& color);
57  const CRgb& operator*=(const CRgb& color);
58  const CRgb& operator/=(const CRgb& color);
59 
60  const CRgb& operator*=(double value);
61  const CRgb& operator/=(double value);
62 };
63 
64 
65 // inline methods
66 
67 inline CRgb::CRgb(double r, double g, double b)
68 {
69  SetElement(CI_RED, r);
70  SetElement(CI_GREEN, g);
71  SetElement(CI_BLUE, b);
72 }
73 
74 
75 inline CRgb::CRgb(const CRgb& color)
76 : istd::IPolymorphic(),
77  istd::IChangeable(),
78  iser::ISerializable(),
79  BaseClass(color)
80 {
81 }
82 
83 
84 // access to components
85 
86 inline double CRgb::GetRed() const
87 {
88  return GetElement(CI_RED);
89 }
90 
91 
92 inline void CRgb::SetRed(double value)
93 {
94  SetElement(CI_RED, value);
95 }
96 
97 
98 inline double CRgb::GetGreen() const
99 {
100  return GetElement(CI_GREEN);
101 }
102 
103 
104 inline void CRgb::SetGreen(double value)
105 {
106  SetElement(CI_GREEN, value);
107 }
108 
109 
110 inline double CRgb::GetBlue() const
111 {
112  return GetElement(CI_BLUE);
113 }
114 
115 
116 inline void CRgb::SetBlue(double value)
117 {
118  SetElement(CI_BLUE, value);
119 }
120 
121 
122 // operators
123 
124 inline CRgb CRgb::operator+(const CRgb& color) const
125 {
126  CRgb retVal = *this;
127 
128  retVal += color;
129 
130  return retVal;
131 }
132 
133 
134 inline CRgb CRgb::operator-(const CRgb& color) const
135 {
136  CRgb retVal = *this;
137 
138  retVal -= color;
139 
140  return retVal;
141 }
142 
143 
144 inline CRgb CRgb::operator*(const CRgb& color) const
145 {
146  CRgb retVal = *this;
147 
148  retVal *= color;
149 
150  return retVal;
151 }
152 
153 
154 inline CRgb CRgb::operator/(const CRgb& color) const
155 {
156  CRgb retVal = *this;
157 
158  retVal /= color;
159 
160  return retVal;
161 }
162 
163 
164 inline CRgb CRgb::operator*(double value) const
165 {
166  CRgb retVal = *this;
167 
168  retVal *= value;
169 
170  return retVal;
171 }
172 
173 
174 inline CRgb CRgb::operator/(double value) const
175 {
176  CRgb retVal = *this;
177 
178  retVal /= value;
179 
180  return retVal;
181 }
182 
183 
184 inline CRgb& CRgb::operator=(const CRgb& color)
185 {
186  BaseClass::operator=(color);
187 
188  return *this;
189 }
190 
191 
192 inline const CRgb& CRgb::operator+=(const CRgb& color)
193 {
194  BaseClass::operator+=(color);
195 
196  return *this;
197 }
198 
199 
200 inline const CRgb& CRgb::operator-=(const CRgb& color)
201 {
202  BaseClass::operator-=(color);
203 
204  return *this;
205 }
206 
207 
208 inline const CRgb& CRgb::operator*=(const CRgb& color)
209 {
210  BaseClass::operator*=(color);
211 
212  return *this;
213 }
214 
215 
216 inline const CRgb& CRgb::operator/=(const CRgb& color)
217 {
218  BaseClass::operator/=(color);
219 
220  return *this;
221 }
222 
223 
224 inline const CRgb& CRgb::operator*=(double value)
225 {
226  BaseClass::operator*=(value);
227 
228  return *this;
229 }
230 
231 
232 inline const CRgb& CRgb::operator/=(double value)
233 {
234  BaseClass::operator/=(value);
235 
236  return *this;
237 }
238 
239 
240 } // namespace icmm
241 
242 
243 #endif // !icmm_CRgb_included
244 
245 
const TComposedColor< Size > & operator/=(const TComposedColor< Size > &color)
CRgb & operator=(const CRgb &color)
Definition: CRgb.h:184
double GetBlue() const
Definition: CRgb.h:110
CRgb operator/(const CRgb &color) const
Definition: CRgb.h:154
const CRgb & operator*=(const CRgb &color)
Definition: CRgb.h:208
TVector< Size, double > operator-() const
CRgb operator+(const CRgb &color) const
Definition: CRgb.h:124
const CRgb & operator+=(const CRgb &color)
Definition: CRgb.h:192
void SetElement(int i, const double &value)
Set element at specified i.
void SetGreen(double value)
Definition: CRgb.h:104
const CRgb & operator-=(const CRgb &color)
Definition: CRgb.h:200
Generic color implementation.
const TComposedColor< Size > & operator=(const TComposedColor< Size > &color)
Represent input/output persistence archive.
Definition: IArchive.h:30
ComponentIndex
Definition: CRgb.h:23
const TComposedColor< Size > & operator*=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator-=(const TComposedColor< Size > &color)
const CRgb & operator/=(const CRgb &color)
Definition: CRgb.h:216
const double & GetElement(int i) const
Get element at specified i.
CRgb operator*(const CRgb &color) const
Definition: CRgb.h:144
void SetRed(double value)
Definition: CRgb.h:92
const TComposedColor< Size > & operator+=(const TComposedColor< Size > &color)
double GetGreen() const
Definition: CRgb.h:98
double GetRed() const
Definition: CRgb.h:86
TComposedColor< 3 > BaseClass
Definition: CRgb.h:21
bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
CRgb(double r=0.0, double g=0.0, double b=0.0)
Definition: CRgb.h:67
void SetBlue(double value)
Definition: CRgb.h:116
Primitive for representation of RGB color value.
Definition: CRgb.h:18

© 2007-2017 Witold Gantzke and Kirill Lepskiy