00001
00002
00013 #ifndef _Color_H_
00014 #define _Color_H_
00015
00016 #include "pattern/libhippo.h"
00017
00018 #include <map>
00019 #include <string>
00020 #include <vector>
00021
00022 namespace hippodraw {
00023
00037 class MDL_HIPPOPLOT_API Color
00038 {
00039
00040 public:
00041
00051 enum Value { red, green, blue, yellow, orange, cyan, magenta,
00052 black, darkgray, lightgray, white };
00053
00054 private:
00055
00058 typedef std::map < std::string, Color > ColorMapByName_t;
00059
00062 static ColorMapByName_t s_color_by_name;
00063
00066 static std::vector < std::string > s_color_names;
00067
00069 int m_red;
00070
00072 int m_green;
00073
00075 int m_blue;
00076
00079 static void initColorByNameMap ();
00080
00081 public:
00082
00086 explicit Color ( int red = 0, int green = 0, int blue = 0 );
00087
00090 explicit Color ( Color::Value value );
00091
00097 explicit Color ( const std::string & name );
00098
00101 static bool isValid ( const std::string & name );
00102
00105 static void addColor ( const char * name, const Color & color );
00106
00109 static const std::vector < std::string > & colorNames ();
00110
00115 void setColor ( const std::string & );
00116
00118 void setColor ( int red = 0, int green = 0, int blue = 0 );
00119
00122 void setColor ( Color::Value value );
00123
00124 int getRed () const;
00125
00126 int getGreen () const;
00127
00128 int getBlue () const;
00129
00133 static Color::Value getColor();
00134
00137 static int colorIndex;
00138
00139 bool operator==(Color c);
00140
00141 };
00142
00143 }
00144
00145 #endif // _Color_H_