BALL  1.4.79
colorHSV.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_VIEW_DATATYPE_COLORHSV_H
6 #define BALL_VIEW_DATATYPE_COLORHSV_H
7 
8 #ifndef BALL_COMMON_H
9 # include <BALL/common.h>
10 #endif
11 
12 #ifndef BALL_DATATYPE_STRING_H
13 # include <BALL/DATATYPE/string.h>
14 #endif
15 
16 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H
18 #endif
19 
20 #ifndef BALL_VIEW_DATATYPE_COLORUNITHUE_H
22 #endif
23 
24 #include <iostream>
25 #include <cstdio>
26 
27 namespace BALL
28 {
29  namespace VIEW
30  {
31 
32  class ColorRGBA;
33 
43  {
48  friend class ColorRGBA;
49 
50  public:
51 
53 
54 
57 
62  ColorHSV();
63 
66  ColorHSV(const ColorHSV& color);
67 
70  ColorHSV(const ColorRGBA& color);
71 
85  ColorHSV(const char* value);
86 
97  ColorHSV(const String& value);
98 
105  ColorHSV
106  (const ColorUnitHue& hue,
107  const ColorUnit& saturation,
108  const ColorUnit& value);
109 
111 
114 
117  virtual ~ColorHSV();
118 
126  virtual void clear();
127 
129 
132 
136  operator String () const;
137 
139 
142 
145  void set(const ColorHSV& color);
146 
150  const ColorHSV& operator = (const ColorHSV& color);
151 
155  void set(const ColorRGBA& color);
156 
165  const ColorHSV& operator = (const ColorRGBA& color);
166 
172  void get(ColorRGBA& color) const;
173 
181  void set(const char* value);
182 
191  const ColorHSV& operator = (const char* value);
192 
201  void get(char* value) const;
202 
211  void set(const String& value);
212 
221  const ColorHSV& operator = (const String& value);
222 
229  void get(String& value) const;
230 
233  void swap(ColorHSV& color);
234 
236 
239 
248  void setHue(const ColorUnitHue& hue);
249 
257  ColorUnitHue& getHue();
258 
262  const ColorUnitHue& getHue() const;
263 
267  void setSaturation(const ColorUnit& saturation);
268 
272  ColorUnit& getSaturation();
273 
276  const ColorUnit& getSaturation() const;
277 
280  void setValue(const ColorUnit& value);
281 
284  ColorUnit& getValue();
285 
289  const ColorUnit& getValue() const;
290 
293  void set (const ColorUnitHue& hue, const ColorUnit& saturation, const ColorUnit& value);
294 
297  void get (ColorUnitHue& hue, ColorUnit& saturation, ColorUnit& value) const;
298 
300 
303 
306  bool operator == (const ColorHSV& color) const;
307 
310  bool operator != (const ColorHSV& color) const;
311 
316  bool operator < (const ColorHSV& color) const;
317 
322  bool operator <= (const ColorHSV& color) const;
323 
328  bool operator > (const ColorHSV& color) const;
329 
334  bool operator >= (const ColorHSV& color) const;
335 
337 
340 
347  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
348 
350 
353 
362  friend std::istream& operator >> (std::istream& s, ColorHSV& color);
363 
372  friend std::ostream& operator << (std::ostream& s, const ColorHSV& color);
373 
375 
376  private:
377 
378  void calculateHSV_ (const ColorUnit red, const ColorUnit green, const ColorUnit blue);
379 
380  void calculateRGB_ (ColorUnit& red, ColorUnit& green, ColorUnit& blue) const;
381 
382  // @throw Exception::InvalidRange
383  // @throw Exception::NotInHexFormat
384  void stringToHSV_ (const String& value);
385 
386  ColorUnitHue hue_;
387  ColorUnit saturation_;
388  ColorUnit value_;
389  };
390 
391 # ifndef BALL_NO_INLINE_FUNCTIONS
392 # include <BALL/VIEW/DATATYPE/colorHSV.iC>
393 # endif
394 
395  } // namespace VIEW
396 } // namespace BALL
397 
398 #endif // <BALL/VIEW_DATATYPE_COLORHSV_H
#define BALL_CREATE(name)
Definition: create.h:62
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
BALL_EXPORT bool operator>(const String &s1, const String &s2)
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
BALL_EXPORT bool operator>=(const String &s1, const String &s2)
BALL_EXPORT bool operator==(const String &s1, const String &s2)
BALL_EXPORT bool operator<=(const String &s1, const String &s2)
-*- Mode: C++; tab-width: 2; -*-
Definition: constants.h:12
std::ostream & operator<<(std::ostream &o, const PixelFormat &f)
Definition: pixelFormat.h:209
BALL_EXPORT bool operator<(const String &s1, const String &s2)