SUMO - Simulation of Urban MObility

RGBColor Class Reference

#include <RGBColor.h>

Inheritance diagram for RGBColor:
PointOfInterest GUIPointOfInterest

Public Member Functions

SUMOReal blue () const throw ()
 Returns the blue-amount of the color.
RGBColor changedBrightness (SUMOReal change)
 Returns a new color with altered brightness.
SUMOReal green () const throw ()
 Returns the green-amount of the color.
bool operator!= (const RGBColor &c) const
bool operator== (const RGBColor &c) const
SUMOReal red () const throw ()
 Returns the red-amount of the color.
 RGBColor (const RGBColor &col) throw ()
 Copy constructor.
 RGBColor () throw ()
 Constructor.
 RGBColor (SUMOReal red, SUMOReal green, SUMOReal blue) throw ()
 Constructor.
void set (SUMOReal r, SUMOReal g, SUMOReal b) throw ()
 assigns new values
 ~RGBColor () throw ()
 Destructor.

Static Public Member Functions

static RGBColor fromHSV (SUMOReal h, SUMOReal s, SUMOReal v) throw ()
 Converts the given hsv-triplet to rgb.
static RGBColor getDefaultColor () throw ()
 Returns the default color by parsing DEFAULT_COLOR_STRING.
static RGBColor interpolate (const RGBColor &minColor, const RGBColor &maxColor, SUMOReal weight) throw ()
 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) throw ()
 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.

Detailed Description

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 44 of file RGBColor.h.


Constructor & Destructor Documentation

RGBColor::RGBColor ( ) throw ()

Constructor.

Definition at line 54 of file RGBColor.cpp.

Referenced by changedBrightness().

RGBColor::RGBColor ( SUMOReal  red,
SUMOReal  green,
SUMOReal  blue 
) throw ()

Constructor.

Parameters:
[in]redThe red component's value
[in]greenThe green component's value
[in]blueThe blue component's value

Definition at line 58 of file RGBColor.cpp.

RGBColor::RGBColor ( const RGBColor &  col) throw ()

Copy constructor.

Definition at line 62 of file RGBColor.cpp.

RGBColor::~RGBColor ( ) throw ()

Destructor.

Definition at line 66 of file RGBColor.cpp.


Member Function Documentation

RGBColor RGBColor::changedBrightness ( SUMOReal  change)

Returns a new color with altered brightness.

Parameters:
[in]changeThe absolute change applied to all channels (within bounds)
Returns:
The new color

Definition at line 103 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 
) throw () [static]

Converts the given hsv-triplet to rgb.

Parameters:
[in]hHue (0-360)
[in]sSaturation (0-1)
[in]vValue (0-1)
Returns:
The color as RGB
Author:
Alvy Ray Smith (http://www.alvyray.com/default.htm)

Definition at line 172 of file RGBColor.cpp.

Referenced by GUIVehicle::setFunctionalColor().

RGBColor RGBColor::getDefaultColor ( ) throw () [static]

Returns the default color by parsing DEFAULT_COLOR_STRING.

Returns:
The default color

Definition at line 151 of file RGBColor.cpp.

References DEFAULT_COLOR_STRING, and parseColor().

Referenced by MSRouteHandler::openRoute().

RGBColor RGBColor::interpolate ( const RGBColor &  minColor,
const RGBColor &  maxColor,
SUMOReal  weight 
) throw () [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.

Parameters:
[in]minColorThe color to interpolate from
[in]maxColorThe color to interpolate to
[in]weightThe weight of the first color
Returns:
The interpolated color

Definition at line 157 of file RGBColor.cpp.

References SUMOReal.

Referenced by GUIColorScheme::getColor().

bool RGBColor::operator!= ( const RGBColor &  c) const

Definition at line 96 of file RGBColor.cpp.

References myBlue, myGreen, and myRed.

bool RGBColor::operator== ( const RGBColor &  c) const

Definition at line 89 of file RGBColor.cpp.

References myBlue, myGreen, and myRed.

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.

Parameters:
[in]coldefThe color definition to parse
Returns:
The parsed color
Exceptions:
EmptyDataIf the definition has less than three entries
NumberFormatExceptionIf one of the components is not numeric

Definition at line 112 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(), and SUMOVehicleParserHelper::parseCommonAttributes().

RGBColor RGBColor::parseColorReporting ( const std::string &  coldef,
const std::string &  objecttype,
const char *  objectid,
bool  report,
bool &  ok 
) throw () [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.

Parameters:
[in]coldefThe color definition to parse
[in]objecttypeThe type of the currently parsed object
[in]objectidThe id of the currently parsed object
[in]reportWhether errors shall be reported
[in,out]okWhether parsing was successful
Returns:
The parsed color
Exceptions:
EmptyDataIf the definition has less than three entries
NumberFormatExceptionIf one of the components is not numeric

Definition at line 125 of file RGBColor.cpp.

References UNUSED_PARAMETER, and WRITE_ERROR.

Referenced by NLHandler::addPOI(), NLHandler::addPoly(), SUMOVehicleParserHelper::beginVTypeParsing(), GUISettingsHandler::myStartElement(), MSRouteHandler::openRoute(), GUISettingsHandler::parseTextSettings(), and RORDLoader_SUMOBase::startRoute().

void RGBColor::set ( SUMOReal  r,
SUMOReal  g,
SUMOReal  b 
) throw ()

assigns new values

Parameters:
[in]rThe red component's value
[in]gThe green component's value
[in]bThe blue component's value

Definition at line 70 of file RGBColor.cpp.

Referenced by TraCIServerAPI_Vehicle::processSet().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const RGBColor &  col 
) [friend]

Writes the color to the given stream.

Parameters:
[out]osThe stream to write to
[in]colThe color to write
Returns:
The stream

Definition at line 79 of file RGBColor.cpp.


Field Documentation

const RGBColor RGBColor::DEFAULT_COLOR = RGBColor::parseColor(RGBColor::DEFAULT_COLOR_STRING) [static]

The default color (for vehicle types and vehicles)

Definition at line 183 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 179 of file RGBColor.h.

Referenced by getDefaultColor().

SUMOReal RGBColor::myBlue [private]

Definition at line 188 of file RGBColor.h.

Referenced by blue(), changedBrightness(), operator!=(), operator<<(), and operator==().

SUMOReal RGBColor::myGreen [private]

Definition at line 188 of file RGBColor.h.

Referenced by changedBrightness(), green(), operator!=(), operator<<(), and operator==().

SUMOReal RGBColor::myRed [private]

The color amounts.

Definition at line 188 of file RGBColor.h.

Referenced by changedBrightness(), operator!=(), operator<<(), operator==(), and red().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines