SUMO - Simulation of Urban MObility
RGBColor.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // A RGB-color definition
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef RGBColor_h
00023 #define RGBColor_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <iostream>
00036 #include <utils/common/UtilExceptions.h>
00037 
00038 
00039 // ===========================================================================
00040 // class definitions
00041 // ===========================================================================
00047 class RGBColor {
00048 public:
00051     RGBColor() ;
00052 
00053 
00059     RGBColor(SUMOReal red, SUMOReal green, SUMOReal blue) ;
00060 
00061 
00064     RGBColor(const RGBColor& col) ;
00065 
00066 
00068     ~RGBColor() ;
00069 
00070 
00071 
00075     SUMOReal red() const {
00076         return myRed;
00077     }
00078 
00079 
00083     SUMOReal green() const {
00084         return myGreen;
00085     }
00086 
00087 
00091     SUMOReal blue() const {
00092         return myBlue;
00093     }
00094 
00095 
00101     void set(SUMOReal r, SUMOReal g, SUMOReal b) ;
00102 
00103 
00109     friend std::ostream& operator<<(std::ostream& os, const RGBColor& col);
00110 
00111 
00112     bool operator==(const RGBColor& c) const;
00113     bool operator!=(const RGBColor& c) const;
00114 
00115 
00120     RGBColor changedBrightness(SUMOReal change);
00121 
00122 
00132     static RGBColor parseColor(const std::string& coldef) throw(EmptyData, NumberFormatException);
00133 
00134 
00148     static RGBColor parseColorReporting(const std::string& coldef, const std::string& objecttype,
00149                                         const char* objectid, bool report, bool& ok) ;
00150 
00151 
00155     static RGBColor getDefaultColor() ;
00156 
00157 
00168     static RGBColor interpolate(const RGBColor& minColor, const RGBColor& maxColor, SUMOReal weight) ;
00169 
00170 
00178     static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v) ;
00179 
00180 
00182     static const std::string DEFAULT_COLOR_STRING;
00183 
00184 
00186     static const RGBColor DEFAULT_COLOR;
00187 
00188 
00189 private:
00191     SUMOReal myRed, myGreen, myBlue;
00192 
00193 };
00194 
00195 
00196 #endif
00197 
00198 /****************************************************************************/
00199 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines