00001
00002
00003
00004
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
00024 class ColorHSV;
00025
00033 class BALL_VIEW_EXPORT ColorRGBA
00034 {
00038 friend class ColorHSV;
00039
00040 public:
00041
00042
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);
00099
00101 ColorRGBA(const QColor& color, const ColorUnit& alpha);
00102
00104
00107
00110 ~ColorRGBA();
00111
00120 void clear();
00121
00123
00126
00133 operator String() const;
00134
00136
00139
00143 void set(const ColorRGBA& color);
00144
00148 const ColorRGBA& operator = (const ColorRGBA& color);
00149
00152 void set(const ColorHSV& color);
00153
00157 const ColorRGBA& operator = (const ColorHSV& color);
00158
00161 void get(ColorHSV& color) const;
00162
00170 void set(const char* value)
00171 throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00172
00181 const ColorRGBA& operator = (const char* value)
00182 throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00183
00192 void get(char* value) const;
00193
00200 void set(const String& value)
00201 throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00202
00213 const ColorRGBA& operator = (const String& value)
00214 throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00215
00222 void get(String& value) const;
00223
00225 void get(QColor& color) const;
00226
00231 bool set(const QColor& color);
00232
00234 QColor getQColor() const;
00235
00239 void swap(ColorRGBA& color);
00240
00242
00245
00249 void setRed(const ColorUnit& red_value);
00250
00255 ColorUnit& getRed();
00256
00259 const ColorUnit& getRed() const;
00260
00265 void setGreen(const ColorUnit& green_value);
00266
00271 ColorUnit& getGreen();
00272
00276 const ColorUnit& getGreen() const;
00277
00282 void setBlue(const ColorUnit& blue_value);
00283
00287 ColorUnit& getBlue();
00288
00292 const ColorUnit& getBlue() const;
00293
00298 void setAlpha(const ColorUnit& alpha_value);
00299
00304 ColorUnit& getAlpha();
00305
00309 const ColorUnit& getAlpha() const;
00310
00322 void set
00323 (const ColorUnit& red_value, const ColorUnit& green_value,
00324 const ColorUnit& blue_value, const ColorUnit& alpha_value = (float)1);
00325
00335 void get(ColorUnit& red_value, ColorUnit& green_value,
00336 ColorUnit& blue_value, ColorUnit& alpha_value) const;
00337
00346 void get(ColorUnit& red_value,
00347 ColorUnit& green_value,
00348 ColorUnit& blue_value) const;
00349
00351 ColorRGBA getInverseColor() const;
00352
00354
00357
00361 bool operator == (const ColorRGBA& color) const;
00362
00365 bool operator != (const ColorRGBA& color) const;
00366
00371 bool operator < (const ColorRGBA& color) const;
00372
00377 bool operator <= (const ColorRGBA& color) const;
00378
00383 bool operator > (const ColorRGBA& color) const;
00384
00389 bool operator >= (const ColorRGBA& color) const;
00390
00392
00395
00403 void dump(std::ostream& s = std::cout, Size depth = 0) const;
00404
00406
00409
00418 friend BALL_VIEW_EXPORT std::istream& operator >> (std::istream& s, ColorRGBA& color);
00419
00428 friend BALL_VIEW_EXPORT std::ostream& operator << (std::ostream& s, const ColorRGBA& color);
00429
00431
00432 private:
00433
00434 ColorUnit red_;
00435 ColorUnit green_;
00436 ColorUnit blue_;
00437 ColorUnit alpha_;
00438
00439 void stringToRGBA_(const String& s)
00440 throw(Exception::InvalidRange, ColorUnit::NotInHexFormat);
00441 };
00442
00444 extern ColorRGBA BALL_SELECTED_COLOR;
00445 extern PreciseTime BALL_SELECTED_COLOR_CHANGE_TIME;
00446
00448 #ifdef BALL_COMPILER_MSVC
00449 #include <vector>
00450 template class BALL_VIEW_EXPORT std::vector<ColorRGBA>;
00451 #endif
00452
00453 # ifndef BALL_NO_INLINE_FUNCTIONS
00454 # include <BALL/VIEW/DATATYPE/colorRGBA.iC>
00455 # endif
00456
00457 }
00458 }
00459
00460 #endif // <BALL/VIEW_DATATYPE_COLORRGBA_H