![]() |
Eclipse SUMO - Simulation of Urban MObility
|
#include <RGBColor.h>
Public Member Functions | |
unsigned char | alpha () const |
Returns the alpha-amount of the color. More... | |
unsigned char | blue () const |
Returns the blue-amount of the color. More... | |
RGBColor | changedBrightness (int change, int toChange=3) const |
Returns a new color with altered brightness. More... | |
unsigned char | green () const |
Returns the green-amount of the color. More... | |
RGBColor | invertedColor () const |
obtain inverted of current RGBColor More... | |
bool | operator!= (const RGBColor &c) const |
bool | operator== (const RGBColor &c) const |
unsigned char | red () const |
Returns the red-amount of the color. More... | |
RGBColor () | |
Constructor. More... | |
RGBColor (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255) | |
Constructor. More... | |
void | set (unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
assigns new values More... | |
void | setAlpha (unsigned char alpha) |
Sets a new alpha value. More... | |
Static Public Member Functions | |
static RGBColor | fromHSV (double h, double s, double v) |
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb.htm. More... | |
static std::mt19937 * | getColorRNG () |
static RGBColor | interpolate (const RGBColor &minColor, const RGBColor &maxColor, double weight) |
Interpolates between two colors. More... | |
static RGBColor | parseColor (std::string coldef) |
Parses a color information. More... | |
static RGBColor | parseColorReporting (const std::string &coldef, const std::string &objecttype, const char *objectid, bool report, bool &ok) |
Parses a color information. More... | |
static RGBColor | randomHue (double s=1, double v=1) |
Return color with random hue. More... | |
Static Public Attributes | |
static const RGBColor | DEFAULT_COLOR = RGBColor::YELLOW |
The default color (for vehicle types and vehicles) More... | |
static const std::string | DEFAULT_COLOR_STRING = toString(RGBColor::DEFAULT_COLOR) |
The string description of the default color. More... | |
static const RGBColor | RED = RGBColor(255, 0, 0, 255) |
named colors More... | |
static const RGBColor | GREEN = RGBColor(0, 255, 0, 255) |
static const RGBColor | BLUE = RGBColor(0, 0, 255, 255) |
static const RGBColor | YELLOW = RGBColor(255, 255, 0, 255) |
static const RGBColor | CYAN = RGBColor(0, 255, 255, 255) |
static const RGBColor | MAGENTA = RGBColor(255, 0, 255, 255) |
static const RGBColor | ORANGE = RGBColor(255, 128, 0, 255) |
static const RGBColor | WHITE = RGBColor(255, 255, 255, 255) |
static const RGBColor | BLACK = RGBColor(0, 0, 0, 255) |
static const RGBColor | GREY = RGBColor(128, 128, 128, 255) |
static const RGBColor | INVISIBLE = RGBColor(0, 0, 0, 0) |
Private Attributes | |
unsigned char | myAlpha |
unsigned char | myBlue |
unsigned char | myGreen |
unsigned char | myRed |
The color amounts. More... | |
Static Private Attributes | |
static std::mt19937 | myRNG |
A random number generator to generate random colors independent of other randomness. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const RGBColor &col) |
Writes the color to the given stream. More... | |
The definition of a color in the RGB-space with an alpha channel. The cube is meant to lie between (0, 0, 0) and (255, 255, 255)
Definition at line 36 of file RGBColor.h.
RGBColor::RGBColor | ( | ) |
Constructor.
Definition at line 62 of file RGBColor.cpp.
Referenced by fromHSV(), interpolate(), invertedColor(), parseColor(), and parseColorReporting().
RGBColor::RGBColor | ( | unsigned char | red, |
unsigned char | green, | ||
unsigned char | blue, | ||
unsigned char | alpha = 255 |
||
) |
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 66 of file RGBColor.cpp.
|
inline |
Returns the alpha-amount of the color.
Definition at line 73 of file RGBColor.h.
References myAlpha.
Referenced by GNEEdge::drawEdgeGeometryPoints(), GNEEdge::drawEdgeName(), GUIEdge::drawGL(), GUIJunctionWrapper::drawGL(), GUILane::drawGL(), GNEJunction::drawGL(), GNELane::drawGL(), GLHelper::drawText(), GLHelper::drawTextBox(), MFXUtils::getFXColor(), GUISUMOAbstractView::makeSnapshot(), libsumo::Helper::makeTraCIColor(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), setAlpha(), and GLHelper::setColor().
|
inline |
Returns the blue-amount of the color.
Definition at line 66 of file RGBColor.h.
References myBlue.
Referenced by changedBrightness(), GLHelper::drawText(), GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), MFXUtils::getFXColor(), GUISUMOAbstractView::makeSnapshot(), libsumo::Helper::makeTraCIColor(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), and GLHelper::setColor().
RGBColor RGBColor::changedBrightness | ( | int | change, |
int | toChange = 3 |
||
) | const |
Returns a new color with altered brightness.
[in] | change | The absolute change applied to all channels (within bounds) |
[in] | change | The number of colors to change |
Definition at line 145 of file RGBColor.cpp.
References blue(), changedBrightness(), green(), MAX2(), MIN2(), myAlpha, myBlue, myGreen, myRed, and red().
Referenced by changedBrightness(), GUIBasePersonHelper::drawAction_drawAsPoly(), GUIVehicle::drawAction_drawCarriageClass(), GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(), GNEGeometry::HierarchicalConnections::drawConnection(), GNEEdge::drawEdgeGeometryPoints(), GUIBusStop::drawGL(), GUILane::drawGL(), GNEBusStop::drawGL(), GNEChargingStation::drawGL(), GNEContainerStop::drawGL(), GNEDetectorE1::drawGL(), GNEDetectorE1Instant::drawGL(), GNEDetectorE2::drawGL(), GNEParkingArea::drawGL(), GNEPoly::drawGL(), GNERerouterSymbol::drawGL(), GNERouteProbe::drawGL(), GNETAZ::drawGL(), GNEVaporizer::drawGL(), GNEVariableSpeedSignSymbol::drawGL(), GNEConnection::drawGL(), GNECrossing::drawGL(), GNEJunction::drawGL(), GUIPerson::drawGLAdditional(), GUIBaseVehicle::drawRoute(), GNELane::drawStartEndShapePoints(), and GNEAdditionalFrame::E2MultilaneLaneSelector::drawTemporalE2Multilane().
|
static |
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb.htm.
[in] | h | Hue (0-360) |
[in] | s | Saturation (0-1) |
[in] | v | Value (0-1) |
Definition at line 300 of file RGBColor.cpp.
References RGBColor().
Referenced by GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), parseColor(), randomHue(), GNEVehicle::setColor(), GUILane::setFunctionalColor(), GUIContainer::setFunctionalColor(), GUIPerson::setFunctionalColor(), GUIBaseVehicle::setFunctionalColor(), and GNELane::setFunctionalColor().
|
inlinestatic |
Definition at line 103 of file RGBColor.h.
References myRNG.
Referenced by GUILane::setFunctionalColor().
|
inline |
Returns the green-amount of the color.
Definition at line 59 of file RGBColor.h.
References myGreen.
Referenced by changedBrightness(), GLHelper::drawText(), GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), MFXUtils::getFXColor(), GUISUMOAbstractView::makeSnapshot(), libsumo::Helper::makeTraCIColor(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), and GLHelper::setColor().
|
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 284 of file RGBColor.cpp.
References myAlpha, myBlue, myGreen, myRed, and RGBColor().
Referenced by GUISUMOAbstractView::displayColorLegend(), and GUIPropertyScheme< T >::interpolate().
RGBColor RGBColor::invertedColor | ( | ) | const |
obtain inverted of current RGBColor
Definition at line 134 of file RGBColor.cpp.
References myAlpha, myBlue, myGreen, myRed, and RGBColor().
Referenced by GNEPoly::drawGL(), and GNETAZ::drawGL().
bool RGBColor::operator!= | ( | const RGBColor & | c | ) | const |
bool RGBColor::operator== | ( | const RGBColor & | c | ) | const |
|
static |
Parses a color information.
It is assumed that the color is stored as "<RED>,<GREEN>,<BLUE>" and each color is represented as a double. Alternatively the color can be stored as "<RED>,<GREEN>,<BLUE>,<ALPHA>" and each color is represented as an unsigned byte.
[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 168 of file RGBColor.cpp.
References BLACK, BLUE, CYAN, fromHSV(), StringTokenizer::getVector(), GREEN, GREY, StringUtils::hexToInt(), INVISIBLE, MAGENTA, myRNG, ORANGE, RandHelper::rand(), RED, RGBColor(), StringUtils::toDouble(), StringUtils::toInt(), WHITE, and YELLOW.
Referenced by PCTypeMap::add(), NLHandler::addDistrict(), GNEPolygonFrame::addPOI(), GNEPolygonFrame::addPOILane(), GNEPolygonFrame::addPolygon(), SUMOSAXAttributesImpl_Cached::getColor(), SUMOSAXAttributesImpl_Xerces::getColor(), PCLoaderArcView::load(), PCLoaderVisum::load(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), PCLoaderXML::myStartElement(), GNEFrameAttributesModuls::AttributesEditorRow::onCmdOpenAttributeDialog(), GNEFrameAttributesModuls::AttributesCreatorRow::onCmdSelectColorButton(), GNETAZFrame::TAZParameters::onCmdSetColorAttribute(), GNEVehicleTypeDialog::VTypeAtributes::VTypeAttributeRow::openColorDialog(), parseColorReporting(), PCTypeMap::PCTypeMap(), and GUILane::setFunctionalColor().
|
static |
Parses a color information.
It is assumed that the color is stored as "<RED>,<GREEN>,<BLUE>" and each color is represented as a double. Alternatively the color can be stored as "<RED>,<GREEN>,<BLUE>,<ALPHA>" and each color is represented as an unsigned byte.
[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 258 of file RGBColor.cpp.
References parseColor(), RGBColor(), UNUSED_PARAMETER, and WRITE_ERROR.
Referenced by GUISettingsHandler::myStartElement(), and GUISettingsHandler::parseTextSettings().
|
static |
Return color with random hue.
[in] | s | Saturation (0-1) |
[in] | v | Value (0-1) |
Definition at line 329 of file RGBColor.cpp.
References fromHSV(), myRNG, and RandHelper::rand().
Referenced by GLHelper::debugVertices().
|
inline |
Returns the red-amount of the color.
Definition at line 52 of file RGBColor.h.
References myRed.
Referenced by changedBrightness(), GLHelper::drawText(), GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), MFXUtils::getFXColor(), GUISUMOAbstractView::makeSnapshot(), libsumo::Helper::makeTraCIColor(), GUISUMOAbstractView::onConfigure(), GUISUMOAbstractView::paintGL(), and GLHelper::setColor().
void RGBColor::set | ( | unsigned char | r, |
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a | ||
) |
|
inline |
Sets a new alpha value.
[in] | alpha | The new value to use |
Definition at line 88 of file RGBColor.h.
References alpha(), and myAlpha.
Referenced by GNEViewNet::drawTemporalJunction(), and Shape::setShapeAlpha().
|
friend |
Writes the color to the given stream.
[out] | os | The stream to write to |
[in] | col | The color to write |
Definition at line 79 of file RGBColor.cpp.
Definition at line 188 of file RGBColor.h.
Referenced by GNEInternalLane::colorForLinksState(), GUISUMOAbstractView::displayColorLegend(), GUISUMOAbstractView::displayLegend(), GNECalibrator::drawCalibratorSymbol(), GNEGenericData::drawFilteredAttribute(), GNEVehicle::drawFlowLabel(), GUICalibrator::drawGL(), GUIOverheadWire::drawGL(), GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(), GNEDetectorE1::drawGL(), GNEDetectorE1Instant::drawGL(), GNEDetectorE2::drawGL(), GNERerouterSymbol::drawGL(), GNEVariableSpeedSignSymbol::drawGL(), GNEEdgeData::drawPartialGL(), GNEEdgeRelData::drawPartialGL(), GNEViewNet::drawTemporalJunction(), GNEViewNetHelper::TestingMode::drawTestingElements(), GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), GLHelper::getDottedcontourColors(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_Vissim::NIImporter_Vissim(), GNEFrameAttributesModuls::AttributesEditorRow::onCmdOpenAttributeDialog(), GUIParam_PopupMenuInterface::onCmdOpenTracker(), GUIParameterTableWindow::onLeftBtnPress(), GNEVehicleTypeDialog::VTypeAtributes::VTypeAttributeRow::openColorDialog(), parseColor(), and GUISUMOAbstractView::showToolTipFor().
Definition at line 182 of file RGBColor.h.
Referenced by AGActivityTripWriter::AGActivityTripWriter(), GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GNEGenericData::drawAttribute(), GUIOverheadWire::drawGL(), GNEViewNet::drawTemporalDrawShape(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), parseColor(), RODFDetectorCon::saveAsPOIs(), GNEVehicle::setColor(), GUIBaseVehicle::setFunctionalColor(), and NBSign::writeAsPOI().
Definition at line 184 of file RGBColor.h.
Referenced by GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GNERouteHandler::buildFlowEmbeddedRoute(), GNERouteHandler::buildVehicleEmbeddedRoute(), GNEVehicle::drawFlowLabel(), GUIOverheadWire::drawGL(), GNEViewNet::drawLaneCandidates(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_Vissim::NIImporter_Vissim(), and parseColor().
|
static |
The default color (for vehicle types and vehicles)
Definition at line 194 of file RGBColor.h.
Referenced by MSRoute::getColor(), SUMOVehicleParserHelper::parseCommonAttributes(), MSBaseVehicle::replaceRouteEdges(), MSTriggeredRerouter::rerouteParkingArea(), GNEVehicle::setColor(), and GUIBaseVehicle::setFunctionalColor().
|
static |
The string description of the default color.
Definition at line 197 of file RGBColor.h.
Definition at line 181 of file RGBColor.h.
Referenced by AGActivityTripWriter::AGActivityTripWriter(), GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GUIOverheadWire::drawGL(), GUIBaseVehicle::drawLinkItem(), GNEViewNet::drawTemporalDrawShape(), MSActuatedTrafficLightLogic::gapControl(), GNEEdgeRelData::getColor(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_Vissim::NIImporter_Vissim(), GUIApplicationWindow::onCmdGaming(), parseColor(), RODFDetectorCon::saveAsPOIs(), GNEJunction::setColor(), GNELane::setLaneColor(), and MSActuatedTrafficLightLogic::trySwitch().
Definition at line 189 of file RGBColor.h.
Referenced by GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(), GNEVehicle::drawFlowLabel(), GNEDetectorE3::drawGL(), GNEVehicle::drawStackLabel(), GNEAdditionalFrame::E2MultilaneLaneSelector::drawTemporalE2Multilane(), GNEFrameModuls::PathCreator::drawTemporalRoute(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_Vissim::NIImporter_Vissim(), parseColor(), and NBSign::writeAsPOI().
Definition at line 190 of file RGBColor.h.
Referenced by GLHelper::drawTextAtEnd(), GLHelper::drawTextSettings(), and parseColor().
Definition at line 185 of file RGBColor.h.
Referenced by GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GLHelper::drawBoundary(), GUIOverheadWire::drawGL(), GNEViewNetHelper::TestingMode::drawTestingElements(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_Vissim::NIImporter_Vissim(), and parseColor().
|
private |
Definition at line 201 of file RGBColor.h.
Referenced by alpha(), changedBrightness(), interpolate(), invertedColor(), operator!=(), operator==(), set(), and setAlpha().
|
private |
Definition at line 201 of file RGBColor.h.
Referenced by blue(), changedBrightness(), interpolate(), invertedColor(), operator!=(), operator==(), and set().
|
private |
Definition at line 201 of file RGBColor.h.
Referenced by changedBrightness(), green(), interpolate(), invertedColor(), operator!=(), operator==(), and set().
|
private |
The color amounts.
Definition at line 201 of file RGBColor.h.
Referenced by changedBrightness(), interpolate(), invertedColor(), operator!=(), operator==(), red(), and set().
|
staticprivate |
A random number generator to generate random colors independent of other randomness.
Definition at line 204 of file RGBColor.h.
Referenced by getColorRNG(), parseColor(), and randomHue().
Definition at line 186 of file RGBColor.h.
Referenced by GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GUIOverheadWire::drawGL(), GNEPOI::drawGL(), GNEAdditionalFrame::E2MultilaneLaneSelector::drawTemporalE2Multilane(), GNEFrameModuls::PathCreator::drawTemporalRoute(), GNETAZRelData::getColor(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), and parseColor().
named colors
Definition at line 180 of file RGBColor.h.
Referenced by AGActivityTripWriter::AGActivityTripWriter(), GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GUISUMOAbstractView::drawFPS(), GUIOverheadWire::drawGL(), GNERerouter::drawGL(), GNEVariableSpeedSignSymbol::drawGL(), GNEViewNet::drawLaneCandidates(), GNEAdditional::drawPartialGL(), GNEDemandElement::drawPersonPlanPartialJunction(), GNEViewNet::drawTemporalDrawShape(), GNEAdditionalFrame::E2MultilaneLaneSelector::drawTemporalE2Multilane(), GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), MSActuatedTrafficLightLogic::gapControl(), GNEEdgeData::getColor(), GNEAdditionalHandler::GNEAdditionalHandler(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_Vissim::NIImporter_Vissim(), GUIApplicationWindow::onCmdGaming(), parseColor(), RODFDetectorCon::saveAsPOIs(), GNEVehicle::setColor(), GUIBaseVehicle::setFunctionalColor(), and NBSign::writeAsPOI().
Definition at line 187 of file RGBColor.h.
Referenced by GNEConnectorFrame::ConnectionLegend::ConnectionLegend(), GUISUMOAbstractView::displayColorLegend(), GNELane::drawArrows(), GNEEdge::drawEdgeGeometryPoints(), GNEDetectorE1::drawGL(), GNEDetectorE1Instant::drawGL(), GNERouteProbe::drawGL(), GNEVaporizer::drawGL(), GNEVariableSpeedSign::drawGL(), GNELane::drawMarkings(), GNEVehicle::drawStackLabel(), GNELane::drawStartEndShapePoints(), GNEViewNetHelper::TestingMode::drawTestingElements(), GUITLLogicPhasesTrackerWindow::drawValues(), GLHelper::getDottedcontourColors(), GNECrossingFrame::GNECrossingFrame(), NIImporter_Vissim::NIImporter_Vissim(), parseColor(), GNEFrameModuls::PathLegend::PathLegend(), GNEProhibitionFrame::ProhibitionLegend::ProhibitionLegend(), GNEVehicle::setColor(), GUIBaseVehicle::setFunctionalColor(), and GNETAZFrame::TAZEdgesGraphic::TAZEdgesGraphic().
Definition at line 183 of file RGBColor.h.
Referenced by SUMOVehicleParserHelper::beginVTypeParsing(), GUIViewTraffic::buildColorRainbow(), GNEViewNet::buildColorRainbow(), GUIOverheadWire::drawGL(), GNEVariableSpeedSignSymbol::drawGL(), GUIVisualizationSettings::initNeteditDefaults(), GUIVisualizationSettings::initSumoGuiDefaults(), NIImporter_OpenDrive::loadNetwork(), NIImporter_Vissim::NIImporter_Vissim(), parseColor(), GNERouteHandler::transformToRouteFlow(), GNERouteHandler::transformToVehicle(), and NBSign::writeAsPOI().