SUMO - Simulation of Urban MObility
|
#include <RGBColor.h>
Public Member Functions | |
SUMOReal | blue () const |
Returns the blue-amount of the color. | |
RGBColor | changedBrightness (SUMOReal change) |
Returns a new color with altered brightness. | |
SUMOReal | green () const |
Returns the green-amount of the color. | |
bool | operator!= (const RGBColor &c) const |
bool | operator== (const RGBColor &c) const |
SUMOReal | red () const |
Returns the red-amount of the color. | |
RGBColor () | |
Constructor. | |
RGBColor (SUMOReal red, SUMOReal green, SUMOReal blue) | |
Constructor. | |
RGBColor (const RGBColor &col) | |
Copy constructor. | |
void | set (SUMOReal r, SUMOReal g, SUMOReal b) |
assigns new values | |
~RGBColor () | |
Destructor. | |
Static Public Member Functions | |
static RGBColor | fromHSV (SUMOReal h, SUMOReal s, SUMOReal v) |
Converts the given hsv-triplet to rgb. | |
static RGBColor | getDefaultColor () |
Returns the default color by parsing DEFAULT_COLOR_STRING. | |
static RGBColor | interpolate (const RGBColor &minColor, const RGBColor &maxColor, SUMOReal weight) |
Interpolates between two colors. | |
static RGBColor | parseColor (const std::string &coldef) throw (EmptyData, NumberFormatException) |
Parses a color information. | |
static RGBColor | parseColorReporting (const std::string &coldef, const std::string &objecttype, const char *objectid, bool report, bool &ok) |
Parses a color information. | |
Static Public Attributes | |
static const RGBColor | DEFAULT_COLOR = RGBColor::parseColor(RGBColor::DEFAULT_COLOR_STRING) |
The default color (for vehicle types and vehicles) | |
static const std::string | DEFAULT_COLOR_STRING = "1,1,0" |
The string description of the default color. | |
Private Attributes | |
SUMOReal | myBlue |
SUMOReal | myGreen |
SUMOReal | myRed |
The color amounts. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const RGBColor &col) |
Writes the color to the given stream. |
The definition of a color in the RGB-space. The cube is meant to lie between (0, 0, 0) and (1, 1, 1)
Definition at line 47 of file RGBColor.h.
Constructor.
Definition at line 58 of file RGBColor.cpp.
Referenced by changedBrightness(), fromHSV(), interpolate(), and parseColorReporting().
RGBColor::RGBColor | ( | SUMOReal | red, |
SUMOReal | green, | ||
SUMOReal | blue | ||
) |
Constructor.
[in] | red | The red component's value |
[in] | green | The green component's value |
[in] | blue | The blue component's value |
Definition at line 62 of file RGBColor.cpp.
RGBColor::RGBColor | ( | const RGBColor & | col | ) |
Copy constructor.
Definition at line 66 of file RGBColor.cpp.
Destructor.
Definition at line 70 of file RGBColor.cpp.
SUMOReal RGBColor::blue | ( | ) | const [inline] |
Returns the blue-amount of the color.
Definition at line 91 of file RGBColor.h.
References myBlue.
Referenced by changedBrightness(), GUIDialog_ViewSettings::convert(), GUIPointOfInterest::drawGL(), MFXUtils::getFXColor(), TraCIServerAPI_VehicleType::getVariable(), GUISUMOAbstractView::makeSnapshot(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Vehicle::processGet(), MSVehicleType::saveState(), and GLHelper::setColor().
RGBColor RGBColor::changedBrightness | ( | SUMOReal | change | ) |
Returns a new color with altered brightness.
[in] | change | The absolute change applied to all channels (within bounds) |
Definition at line 107 of file RGBColor.cpp.
References blue(), green(), MAX2(), MIN2(), myBlue, myGreen, myRed, red(), RGBColor(), and SUMOReal.
Referenced by drawAction_drawVehicleAsPoly().
RGBColor RGBColor::fromHSV | ( | SUMOReal | h, |
SUMOReal | s, | ||
SUMOReal | v | ||
) | [static] |
Converts the given hsv-triplet to rgb.
[in] | h | Hue (0-360) |
[in] | s | Saturation (0-1) |
[in] | v | Value (0-1) |
Definition at line 176 of file RGBColor.cpp.
References RGBColor().
Referenced by GUIVehicle::setFunctionalColor().
RGBColor RGBColor::getDefaultColor | ( | ) | [static] |
Returns the default color by parsing DEFAULT_COLOR_STRING.
Definition at line 155 of file RGBColor.cpp.
References DEFAULT_COLOR_STRING, and parseColor().
Referenced by MSRouteHandler::openRoute().
SUMOReal RGBColor::green | ( | ) | const [inline] |
Returns the green-amount of the color.
Definition at line 83 of file RGBColor.h.
References myGreen.
Referenced by changedBrightness(), GUIDialog_ViewSettings::convert(), GUIPointOfInterest::drawGL(), MFXUtils::getFXColor(), TraCIServerAPI_VehicleType::getVariable(), GUISUMOAbstractView::makeSnapshot(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Vehicle::processGet(), MSVehicleType::saveState(), and GLHelper::setColor().
RGBColor RGBColor::interpolate | ( | const RGBColor & | minColor, |
const RGBColor & | maxColor, | ||
SUMOReal | weight | ||
) | [static] |
Interpolates between two colors.
The interpolated color is calculated as a weighted average of the RGB values of minColor and maxColor, giving weight to maxColor and 1-weight to minColor.
[in] | minColor | The color to interpolate from |
[in] | maxColor | The color to interpolate to |
[in] | weight | The weight of the first color |
Definition at line 161 of file RGBColor.cpp.
References myBlue, myGreen, myRed, RGBColor(), and SUMOReal.
Referenced by GUIColorScheme::getColor().
Definition at line 100 of file RGBColor.cpp.
Definition at line 93 of file RGBColor.cpp.
RGBColor RGBColor::parseColor | ( | const std::string & | coldef | ) | throw (EmptyData, NumberFormatException) [static] |
Parses a color information.
It is assumed that the color is stored as "<RED>,<GREEN>,<BLUE>" And each color is represented as a SUMOReal.
[in] | coldef | The color definition to parse |
EmptyData | If the definition has less than three entries |
NumberFormatException | If one of the components is not numeric |
Definition at line 116 of file RGBColor.cpp.
References TplConvert< E >::_2SUMOReal(), StringTokenizer::next(), StringTokenizer::size(), and SUMOReal.
Referenced by getDefaultColor(), PCLoaderVisum::load(), PCLoaderArcView::load(), PCLoaderOSM::loadIfSet(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), PCLoaderXML::myStartElement(), parseColorReporting(), and SUMOVehicleParserHelper::parseCommonAttributes().
RGBColor RGBColor::parseColorReporting | ( | const std::string & | coldef, |
const std::string & | objecttype, | ||
const char * | objectid, | ||
bool | report, | ||
bool & | ok | ||
) | [static] |
Parses a color information.
It is assumed that the color is stored as "<RED>,<GREEN>,<BLUE>" And each color is represented as a SUMOReal.
[in] | coldef | The color definition to parse |
[in] | objecttype | The type of the currently parsed object |
[in] | objectid | The id of the currently parsed object |
[in] | report | Whether errors shall be reported |
[in,out] | ok | Whether parsing was successful |
EmptyData | If the definition has less than three entries |
NumberFormatException | If one of the components is not numeric |
Definition at line 129 of file RGBColor.cpp.
References parseColor(), RGBColor(), UNUSED_PARAMETER, and WRITE_ERROR.
Referenced by NLHandler::addPOI(), NLHandler::addPoly(), SUMOVehicleParserHelper::beginVTypeParsing(), GUISettingsHandler::myStartElement(), MSRouteHandler::openRoute(), GUISettingsHandler::parseTextSettings(), and RORDLoader_SUMOBase::startRoute().
SUMOReal RGBColor::red | ( | ) | const [inline] |
Returns the red-amount of the color.
Definition at line 75 of file RGBColor.h.
References myRed.
Referenced by changedBrightness(), GUIDialog_ViewSettings::convert(), GUIPointOfInterest::drawGL(), MFXUtils::getFXColor(), TraCIServerAPI_VehicleType::getVariable(), GUISUMOAbstractView::makeSnapshot(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Vehicle::processGet(), MSVehicleType::saveState(), and GLHelper::setColor().
void RGBColor::set | ( | SUMOReal | r, |
SUMOReal | g, | ||
SUMOReal | b | ||
) |
assigns new values
[in] | r | The red component's value |
[in] | g | The green component's value |
[in] | b | The blue component's value |
Definition at line 74 of file RGBColor.cpp.
References myBlue, myGreen, and myRed.
Referenced by TraCIServerAPI_Vehicle::processSet().
std::ostream& operator<< | ( | std::ostream & | os, |
const RGBColor & | col | ||
) | [friend] |
Writes the color to the given stream.
[out] | os | The stream to write to |
[in] | col | The color to write |
Definition at line 83 of file RGBColor.cpp.
const RGBColor RGBColor::DEFAULT_COLOR = RGBColor::parseColor(RGBColor::DEFAULT_COLOR_STRING) [static] |
The default color (for vehicle types and vehicles)
Definition at line 186 of file RGBColor.h.
Referenced by TraCIServerAPI_Simulation::commandDistanceRequest(), SUMOVehicleParserHelper::parseCommonAttributes(), and TraCIServerAPI_Route::processSet().
const std::string RGBColor::DEFAULT_COLOR_STRING = "1,1,0" [static] |
The string description of the default color.
Definition at line 182 of file RGBColor.h.
Referenced by getDefaultColor().
SUMOReal RGBColor::myBlue [private] |
Definition at line 191 of file RGBColor.h.
Referenced by blue(), changedBrightness(), interpolate(), operator!=(), operator<<(), operator==(), and set().
SUMOReal RGBColor::myGreen [private] |
Definition at line 191 of file RGBColor.h.
Referenced by changedBrightness(), green(), interpolate(), operator!=(), operator<<(), operator==(), and set().
SUMOReal RGBColor::myRed [private] |
The color amounts.
Definition at line 191 of file RGBColor.h.
Referenced by changedBrightness(), interpolate(), operator!=(), operator<<(), operator==(), red(), and set().