BALL  1.4.1
colorHSV.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 
00005 #ifndef BALL_VIEW_DATATYPE_COLORHSV_H
00006 #define BALL_VIEW_DATATYPE_COLORHSV_H
00007 
00008 #ifndef BALL_COMMON_H
00009 # include <BALL/common.h>
00010 #endif
00011 
00012 #ifndef BALL_DATATYPE_STRING_H
00013 # include <BALL/DATATYPE/string.h>
00014 #endif
00015 
00016 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H
00017 # include <BALL/VIEW/DATATYPE/colorUnit.h>
00018 #endif
00019 
00020 #ifndef BALL_VIEW_DATATYPE_COLORUNITHUE_H
00021 # include <BALL/VIEW/DATATYPE/colorUnitHue.h>
00022 #endif
00023 
00024 #include <iostream>
00025 #include <stdio.h>
00026 
00027 namespace BALL 
00028 {
00029   namespace VIEW 
00030   {
00031 
00032     class ColorRGBA;
00033 
00042     class BALL_VIEW_EXPORT ColorHSV
00043     {
00048       friend class ColorRGBA;
00049 
00050       public:
00051 
00052       BALL_CREATE(ColorHSV)
00053 
00054       
00057 
00062       ColorHSV();
00063 
00066       ColorHSV(const ColorHSV& color);
00067 
00070       ColorHSV(const ColorRGBA& color);
00071 
00085       ColorHSV(const char* value);
00086 
00097       ColorHSV(const String& value);
00098 
00105       ColorHSV
00106         (const ColorUnitHue& hue,
00107          const ColorUnit& saturation,
00108          const ColorUnit& value);
00109 
00111 
00114 
00117       virtual ~ColorHSV();
00118 
00126       virtual void clear();
00127 
00129 
00132 
00136       operator String () const;
00137 
00139 
00142 
00145       void set(const ColorHSV& color);
00146 
00150       const ColorHSV& operator = (const ColorHSV& color);
00151 
00155       void set(const ColorRGBA& color);
00156 
00165       const ColorHSV& operator = (const ColorRGBA& color);
00166 
00172       void get(ColorRGBA& color) const;
00173 
00181       void set(const char* value);
00182 
00191       const ColorHSV& operator = (const char* value);
00192 
00201       void get(char* value) const;
00202 
00211       void set(const String& value);
00212 
00221       const ColorHSV& operator = (const String& value);
00222 
00229       void get(String& value) const;
00230 
00233       void swap(ColorHSV& color);
00234 
00236 
00239 
00248       void setHue(const ColorUnitHue& hue);
00249 
00257       ColorUnitHue& getHue();
00258 
00262       const ColorUnitHue& getHue() const;
00263 
00267       void setSaturation(const ColorUnit& saturation);
00268 
00272       ColorUnit& getSaturation();
00273 
00276       const ColorUnit& getSaturation() const;
00277 
00280       void setValue(const ColorUnit& value);
00281 
00284       ColorUnit& getValue();
00285 
00289       const ColorUnit& getValue() const;
00290 
00293       void set (const ColorUnitHue& hue, const ColorUnit& saturation, const ColorUnit& value);
00294 
00297       void get (ColorUnitHue& hue, ColorUnit& saturation, ColorUnit& value) const;
00298 
00300 
00303 
00306       bool operator == (const ColorHSV& color) const;
00307 
00310       bool operator != (const ColorHSV& color) const;
00311 
00316       bool operator < (const ColorHSV& color) const;
00317 
00322       bool operator <= (const ColorHSV& color) const;
00323 
00328       bool operator > (const ColorHSV& color) const;
00329 
00334       bool operator >= (const ColorHSV& color) const;
00335 
00337 
00340   
00347       virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00348 
00350 
00353 
00362       friend std::istream& operator >> (std::istream& s, ColorHSV& color);
00363 
00372       friend std::ostream& operator << (std::ostream& s, const ColorHSV& color);
00373 
00375 
00376       private:
00377 
00378       void calculateHSV_ (const ColorUnit red, const ColorUnit green, const ColorUnit blue);
00379 
00380       void calculateRGB_ (ColorUnit& red, ColorUnit& green, ColorUnit& blue) const;
00381 
00382       // @throw Exception::InvalidRange 
00383       // @throw Exception::NotInHexFormat
00384       void stringToHSV_ (const String& value);
00385 
00386       ColorUnitHue  hue_;
00387       ColorUnit     saturation_;
00388       ColorUnit     value_;
00389     };
00390 
00391 #   ifndef BALL_NO_INLINE_FUNCTIONS
00392 #     include <BALL/VIEW/DATATYPE/colorHSV.iC>
00393 #   endif
00394       
00395   } // namespace VIEW
00396 } // namespace BALL
00397 
00398 #endif // <BALL/VIEW_DATATYPE_COLORHSV_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines