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

© 2007-2017 Witold Gantzke and Kirill Lepskiy