CHsv.h
Go to the documentation of this file.
1 #ifndef icmm_CHsv_included
2 #define icmm_CHsv_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 CHsv: public TComposedColor<3>
19 {
20 public:
22 
24  {
29  };
30 
31  CHsv(double h = 0.0, double s = 0.0, double v = 0.0);
32  CHsv(const CHsv& color);
33  CHsv(const imath::CVarVector& vector);
34 
35  // access to component values
36  double GetHue() const;
37  void SetHue(double value);
38  double GetSaturation() const;
39  void SetSaturation(double value);
40  double GetValue() const;
41  void SetValue(double value);
42 
43  bool Serialize(iser::IArchive& archive);
44 
45  // operators
46  CHsv operator+(const CHsv& color) const;
47  CHsv operator-(const CHsv& color) const;
48  CHsv operator*(const CHsv& color) const;
49  CHsv operator/(const CHsv& color) const;
50 
51  CHsv operator*(double value) const;
52  CHsv operator/(double value) const;
53 
54  CHsv& operator=(const CHsv& color);
55 
56  const CHsv& operator+=(const CHsv& color);
57  const CHsv& operator-=(const CHsv& color);
58  const CHsv& operator*=(const CHsv& color);
59  const CHsv& operator/=(const CHsv& color);
60 
61  const CHsv& operator*=(double value);
62  const CHsv& operator/=(double value);
63 };
64 
65 
66 // inline methods
67 
68 inline CHsv::CHsv(double h, double s, double v)
69 {
70  SetElement(CI_HUE, h);
72  SetElement(CI_VALUE, v);
73 }
74 
75 
76 inline CHsv::CHsv(const CHsv& color)
77 : istd::IPolymorphic(),
78  istd::IChangeable(),
79  iser::ISerializable(),
80  BaseClass(color)
81 {
82 }
83 
84 
85 inline CHsv::CHsv(const imath::CVarVector& vector)
86 : BaseClass(vector)
87 {
88 }
89 
90 
91 // access to components
92 
93 inline double CHsv::GetHue() const
94 {
95  return GetElement(CI_HUE);
96 }
97 
98 
99 inline void CHsv::SetHue(double value)
100 {
101  SetElement(CI_HUE, value);
102 }
103 
104 
105 inline double CHsv::GetSaturation() const
106 {
107  return GetElement(CI_SATURATION);
108 }
109 
110 
111 inline void CHsv::SetSaturation(double value)
112 {
113  SetElement(CI_SATURATION, value);
114 }
115 
116 
117 inline double CHsv::GetValue() const
118 {
119  return GetElement(CI_VALUE);
120 }
121 
122 
123 inline void CHsv::SetValue(double value)
124 {
125  SetElement(CI_VALUE, value);
126 }
127 
128 
129 
130 // operators
131 
132 inline CHsv& CHsv::operator=(const CHsv& color)
133 {
134  BaseClass::operator=(color);
135 
136  return *this;
137 }
138 
139 
140 inline const CHsv& CHsv::operator+=(const CHsv& color)
141 {
142  BaseClass::operator+=(color);
143 
144  return *this;
145 }
146 
147 
148 inline const CHsv& CHsv::operator-=(const CHsv& color)
149 {
150  BaseClass::operator-=(color);
151 
152  return *this;
153 }
154 
155 
156 inline const CHsv& CHsv::operator*=(const CHsv& color)
157 {
158  BaseClass::operator*=(color);
159 
160  return *this;
161 }
162 
163 
164 inline const CHsv& CHsv::operator/=(const CHsv& color)
165 {
166  BaseClass::operator/=(color);
167 
168  return *this;
169 }
170 
171 
172 inline const CHsv& CHsv::operator*=(double value)
173 {
174  BaseClass::operator*=(value);
175 
176  return *this;
177 }
178 
179 
180 inline const CHsv& CHsv::operator/=(double value)
181 {
182  BaseClass::operator/=(value);
183 
184  return *this;
185 }
186 
187 
188 } // namespace icmm
189 
190 
191 #endif // !icmm_CHsv_included
192 
193 
CHsv operator*(const CHsv &color) const
const TComposedColor< Size > & operator/=(const TComposedColor< Size > &color)
CHsv & operator=(const CHsv &color)
Definition: CHsv.h:132
double GetSaturation() const
Definition: CHsv.h:105
void SetHue(double value)
Definition: CHsv.h:99
double GetHue() const
Definition: CHsv.h:93
const CHsv & operator+=(const CHsv &color)
Definition: CHsv.h:140
TVector< Size, double > operator-() const
double GetValue() const
Definition: CHsv.h:117
void SetElement(int i, const double &value)
Set element at specified i.
CHsv operator+(const CHsv &color) const
ComponentIndex
Definition: CHsv.h:23
CHsv(double h=0.0, double s=0.0, double v=0.0)
Definition: CHsv.h:68
void SetSaturation(double value)
Definition: CHsv.h:111
Primitive for representation of HSV color value.
Definition: CHsv.h:18
Generic color implementation.
TComposedColor< 3 > BaseClass
Definition: CHsv.h:21
const TComposedColor< Size > & operator=(const TComposedColor< Size > &color)
const CHsv & operator*=(const CHsv &color)
Definition: CHsv.h:156
const CHsv & operator/=(const CHsv &color)
Definition: CHsv.h:164
Represent input/output persistence archive.
Definition: IArchive.h:30
void SetValue(double value)
Definition: CHsv.h:123
const TComposedColor< Size > & operator*=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator-=(const TComposedColor< Size > &color)
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.
Simple implementation of variable-size vector.
Definition: CVarVector.h:34
const TComposedColor< Size > & operator+=(const TComposedColor< Size > &color)
CHsv operator/(const CHsv &color) const
const CHsv & operator-=(const CHsv &color)
Definition: CHsv.h:148

© 2007-2017 Witold Gantzke and Kirill Lepskiy