|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A RGB-color definition 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef RGBColor_h 00020 #define RGBColor_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <iostream> 00033 #include <utils/common/UtilExceptions.h> 00034 00035 00036 // =========================================================================== 00037 // class definitions 00038 // =========================================================================== 00044 class RGBColor { 00045 public: 00048 RGBColor() throw(); 00049 00050 00056 RGBColor(SUMOReal red, SUMOReal green, SUMOReal blue) throw(); 00057 00058 00061 RGBColor(const RGBColor& col) throw(); 00062 00063 00065 ~RGBColor() throw(); 00066 00067 00068 00072 SUMOReal red() const throw() { 00073 return myRed; 00074 } 00075 00076 00080 SUMOReal green() const throw() { 00081 return myGreen; 00082 } 00083 00084 00088 SUMOReal blue() const throw() { 00089 return myBlue; 00090 } 00091 00092 00098 void set(SUMOReal r, SUMOReal g, SUMOReal b) throw(); 00099 00100 00106 friend std::ostream& operator<<(std::ostream& os, const RGBColor& col); 00107 00108 00109 bool operator==(const RGBColor& c) const; 00110 bool operator!=(const RGBColor& c) const; 00111 00112 00117 RGBColor changedBrightness(SUMOReal change); 00118 00119 00129 static RGBColor parseColor(const std::string& coldef) throw(EmptyData, NumberFormatException); 00130 00131 00145 static RGBColor parseColorReporting(const std::string& coldef, const std::string& objecttype, 00146 const char* objectid, bool report, bool& ok) throw(); 00147 00148 00152 static RGBColor getDefaultColor() throw(); 00153 00154 00165 static RGBColor interpolate(const RGBColor& minColor, const RGBColor& maxColor, SUMOReal weight) throw(); 00166 00167 00175 static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v) throw(); 00176 00177 00179 static const std::string DEFAULT_COLOR_STRING; 00180 00181 00183 static const RGBColor DEFAULT_COLOR; 00184 00185 00186 private: 00188 SUMOReal myRed, myGreen, myBlue; 00189 00190 }; 00191 00192 00193 #endif 00194 00195 /****************************************************************************/ 00196