colorRGBA.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: colorRGBA.h,v 1.21.16.1 2007/03/25 21:25:40 oliver Exp $
00005 //
00006 
00007 #ifndef BALL_VIEW_DATATYPE_COLORRGBA_H
00008 #define BALL_VIEW_DATATYPE_COLORRGBA_H
00009 
00010 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H
00011 # include <BALL/VIEW/DATATYPE/colorUnit.h>
00012 #endif
00013 
00014 #ifndef BALL_CONCEPT_TIMESTAMP_H
00015  #include <BALL/CONCEPT/timeStamp.h>
00016 #endif
00017 
00018 class QColor;
00019 namespace BALL 
00020 {
00021   namespace VIEW 
00022   {
00023     // forward declarations 
00024     class ColorHSV;
00025 
00033     class BALL_VIEW_EXPORT ColorRGBA
00034     {
00038       friend class ColorHSV;
00039 
00040       public:
00041 
00042 //      BALL_CREATE(ColorRGBA)
00043 
00047 
00051       ColorRGBA();
00052 
00055       ColorRGBA(const ColorRGBA& color);
00056 
00060       ColorRGBA(const ColorHSV& color);
00061 
00073       ColorRGBA(const char* value)
00074         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00075 
00083       ColorRGBA(const String& value)
00084         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00085 
00093       ColorRGBA
00094         (const ColorUnit& red_value, const ColorUnit& green_value,
00095          const ColorUnit& blue_value, const ColorUnit& alpha_value = (float)1);
00096 
00098       ColorRGBA(const QColor& color, const ColorUnit& alpha = (float)1);
00099 
00101 
00104 
00107       ~ColorRGBA();
00108 
00117       void clear();
00118 
00120 
00123 
00130       operator String() const;
00131 
00133 
00136 
00140       void set(const ColorRGBA& color);
00141 
00145       const ColorRGBA& operator = (const ColorRGBA& color);
00146 
00149       void set(const ColorHSV& color);
00150 
00154       const ColorRGBA& operator = (const ColorHSV& color);
00155 
00158       void get(ColorHSV& color) const;
00159 
00167       void set(const char* value)
00168         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00169 
00178       const ColorRGBA& operator = (const char* value)
00179         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00180 
00189       void get(char* value) const;
00190 
00197       void set(const String& value)
00198         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00199 
00210       const ColorRGBA& operator = (const String& value)
00211         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00212 
00219       void get(String& value) const;
00220 
00222       void get(QColor& color) const;
00223 
00228       bool set(const QColor& color);
00229 
00231       QColor getQColor() const;
00232 
00236       void swap(ColorRGBA& color);
00237 
00239 
00242 
00246       void setRed(const ColorUnit& red_value);
00247 
00252       ColorUnit& getRed();
00253 
00256       const ColorUnit& getRed() const;
00257 
00262       void setGreen(const ColorUnit& green_value);
00263 
00268       ColorUnit& getGreen();
00269 
00273       const ColorUnit& getGreen() const;
00274 
00279       void setBlue(const ColorUnit& blue_value);
00280 
00284       ColorUnit& getBlue();
00285 
00289       const ColorUnit& getBlue() const;
00290 
00295       void setAlpha(const ColorUnit& alpha_value);
00296 
00301       ColorUnit& getAlpha();
00302 
00306       const ColorUnit& getAlpha() const;
00307 
00319       void set
00320         (const ColorUnit& red_value, const ColorUnit& green_value,
00321          const ColorUnit& blue_value, const ColorUnit& alpha_value = (float)1);
00322 
00332       void get(ColorUnit& red_value, ColorUnit& green_value,
00333                ColorUnit& blue_value, ColorUnit& alpha_value) const;
00334 
00343       void get(ColorUnit& red_value,
00344                ColorUnit& green_value,
00345                ColorUnit& blue_value) const;
00346 
00348       ColorRGBA getInverseColor() const;
00349        
00351 
00354 
00358       bool operator == (const ColorRGBA& color) const;
00359 
00362       bool operator !=  (const ColorRGBA& color) const;
00363 
00368       bool operator < (const ColorRGBA& color) const;
00369 
00374       bool operator <= (const ColorRGBA& color) const;
00375 
00380       bool operator > (const ColorRGBA& color) const;
00381 
00386       bool operator >= (const ColorRGBA& color) const;
00387       
00389 
00392 
00400       void dump(std::ostream& s = std::cout, Size depth = 0) const;
00401       
00403 
00406 
00415       friend std::istream& operator >> (std::istream& s, ColorRGBA& color);
00416 
00425       friend std::ostream& operator << (std::ostream& s, const ColorRGBA& color);
00426 
00428 
00429       private:
00430 
00431       ColorUnit red_;
00432       ColorUnit green_;
00433       ColorUnit blue_;
00434       ColorUnit alpha_;
00435 
00436       void stringToRGBA_(const String& s)
00437         throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00438     };
00439 
00441     extern ColorRGBA        BALL_SELECTED_COLOR;
00442     extern PreciseTime      BALL_SELECTED_COLOR_CHANGE_TIME;
00443 
00445 #ifdef BALL_COMPILER_MSVC
00446 #include <vector>
00447 template class BALL_VIEW_EXPORT std::vector<ColorRGBA>;
00448 #endif
00449 
00450 #   ifndef BALL_NO_INLINE_FUNCTIONS
00451 #     include <BALL/VIEW/DATATYPE/colorRGBA.iC>
00452 #   endif
00453       
00454   } // namespace VIEW
00455 } // namespace BALL
00456 
00457 #endif // <BALL/VIEW_DATATYPE_COLORRGBA_H