From 4e3a369fcacd4a5e843cf6a4745c8ec9a5427fff Mon Sep 17 00:00:00 2001 From: Jakob Erdmann Date: Thu, 8 May 2014 07:20:38 +0000 Subject: [PATCH] added lane coloring by angle refs #36 (to figure out directions without connection arrows) git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk/sumo@16315 afbd958f-9f77-42d5-a016-97a22340ccf4 --- src/guisim/GUILane.cpp | 30 +++++++++++++++---- src/guisim/GUILane.h | 3 ++ .../gui/settings/GUIVisualizationSettings.cpp | 1 + 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/guisim/GUILane.cpp b/src/guisim/GUILane.cpp index 9a892e6a9cb4..89df93e1a414 100644 --- a/src/guisim/GUILane.cpp +++ b/src/guisim/GUILane.cpp @@ -715,12 +715,6 @@ GUILane::getEdgeLaneNumber() const { } -void -GUILane::setColor(const GUIVisualizationSettings& s) const { - GLHelper::setColor(s.laneColorer.getScheme().getColor(getColorValue(s.laneColorer.getActive()))); -} - - SUMOReal GUILane::getStoredEdgeTravelTime() const { MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage(); @@ -733,6 +727,30 @@ GUILane::getStoredEdgeTravelTime() const { } } + +void +GUILane::setColor(const GUIVisualizationSettings& s) const { + const GUIColorer& c = s.laneColorer; + if (!setFunctionalColor(c.getActive())) { + GLHelper::setColor(c.getScheme().getColor(getColorValue(c.getActive()))); + } +} + + +bool +GUILane::setFunctionalColor(size_t activeScheme) const { + switch (activeScheme) { + case 18: { + SUMOReal hue = RAD2DEG(myShape.beginEndAngle()) + 180; // [0-360] + GLHelper::setColor(RGBColor::fromHSV(hue, 1., 1.)); + return true; + } + default: + return false; + } +} + + SUMOReal GUILane::getColorValue(size_t activeScheme) const { switch (activeScheme) { diff --git a/src/guisim/GUILane.h b/src/guisim/GUILane.h index 5dbf43a18ab5..233d43b31fc8 100644 --- a/src/guisim/GUILane.h +++ b/src/guisim/GUILane.h @@ -253,6 +253,9 @@ class GUILane : public MSLane, public GUIGlObject { /// @brief gets the color value according to the current scheme index SUMOReal getColorValue(size_t activeScheme) const; + /// @brief sets the color according to the current scheme index and some lane function + bool setFunctionalColor(size_t activeScheme) const; + /// @brief sets the color according to the currente settings void setColor(const GUIVisualizationSettings& s) const; diff --git a/src/utils/gui/settings/GUIVisualizationSettings.cpp b/src/utils/gui/settings/GUIVisualizationSettings.cpp index 7b63043750b7..6a86300ab536 100644 --- a/src/utils/gui/settings/GUIVisualizationSettings.cpp +++ b/src/utils/gui/settings/GUIVisualizationSettings.cpp @@ -150,6 +150,7 @@ GUIVisualizationSettings::GUIVisualizationSettings() scheme.addColor(RGBColor::GREEN, (SUMOReal)2.0); scheme.addColor(RGBColor::BLUE, (SUMOReal)4.0); laneColorer.addScheme(scheme); + laneColorer.addScheme(GUIColorScheme("by angle", RGBColor::YELLOW, "", true)); /// add vehicle coloring schemes