LCOV - code coverage report
Current view: top level - src/guisim - GUILane.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 53.9 % 942 508
Test Date: 2026-10-12 15:53:19 Functions: 69.5 % 59 41

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    GUILane.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    Sept 2002
      19              : ///
      20              : // Representation of a lane in the micro simulation (gui-version)
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <string>
      25              : #include <utility>
      26              : #include <utils/foxtools/fxheader.h>
      27              : #include <utils/geom/GeomHelper.h>
      28              : #include <utils/geom/Position.h>
      29              : #include <microsim/logging/FunctionBinding.h>
      30              : #include <utils/options/OptionsCont.h>
      31              : #include <utils/common/MsgHandler.h>
      32              : #include <utils/common/StdDefs.h>
      33              : #include <utils/geom/GeomHelper.h>
      34              : #include <utils/gui/div/GLHelper.h>
      35              : #include <utils/gui/div/GUIParameterTableWindow.h>
      36              : #include <utils/gui/div/GUIGlobalSelection.h>
      37              : #include <utils/gui/globjects/GLIncludes.h>
      38              : #include <utils/gui/globjects/GUIPolygon.h>
      39              : #include <utils/gui/images/VClassIcons.h>
      40              : #include <utils/gui/windows/GUISUMOAbstractView.h>
      41              : #include <utils/gui/windows/GUIAppEnum.h>
      42              : #include <gui/GUIGlobals.h>
      43              : #include <microsim/MSGlobals.h>
      44              : #include <microsim/MSLane.h>
      45              : #include <microsim/MSLink.h>
      46              : #include <microsim/MSVehicleControl.h>
      47              : #include <microsim/MSInsertionControl.h>
      48              : #include <microsim/MSVehicleTransfer.h>
      49              : #include <microsim/MSNet.h>
      50              : #include <microsim/MSEdgeWeightsStorage.h>
      51              : #include <microsim/MSParkingArea.h>
      52              : #include <microsim/devices/MSDevice_Routing.h>
      53              : #include <microsim/traffic_lights/MSRailSignal.h>
      54              : #include <microsim/traffic_lights/MSDriveWay.h>
      55              : #include <mesosim/MELoop.h>
      56              : #include <mesosim/MESegment.h>
      57              : #include "GUILane.h"
      58              : #include "GUIEdge.h"
      59              : #include "GUIVehicle.h"
      60              : #include "GUINet.h"
      61              : #include <utils/gui/div/GUIDesigns.h>
      62              : 
      63              : #include <osgview/GUIOSGHeader.h>
      64              : 
      65              : #define RENDERING_BUFFER 10
      66              : 
      67              : //#define GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
      68              : //#define GUILane_DEBUG_DRAW_CROSSING_OUTLINE
      69              : 
      70              : // ===========================================================================
      71              : // static member declaration
      72              : // ===========================================================================
      73              : const RGBColor GUILane::MESO_USE_LANE_COLOR(0, 0, 0, 0);
      74              : GUIVisualizationSettings* GUILane::myCachedGUISettings(nullptr);
      75              : 
      76              : 
      77              : // ===========================================================================
      78              : // method definitions
      79              : // ===========================================================================
      80       448126 : GUILane::GUILane(const std::string& id, double maxSpeed, double friction, double length,
      81              :                  MSEdge* const edge, int numericalID,
      82              :                  const PositionVector& shape, double width,
      83              :                  SVCPermissions permissions,
      84              :                  SVCPermissions changeLeft, SVCPermissions changeRight,
      85              :                  int index, bool isRampAccel,
      86              :                  const std::string& type,
      87       448126 :                  const PositionVector& outlineShape) :
      88              :     MSLane(id, maxSpeed, friction, length, edge, numericalID, shape, width, permissions, changeLeft, changeRight, index, isRampAccel, type, outlineShape),
      89              :     GUIGlObject(GLO_LANE, id, GUIIconSubSys::getIcon(GUIIcon::LANE)),
      90       448126 :     myParkingAreas(nullptr),
      91       448126 :     myTesselation(nullptr),
      92              : #ifdef HAVE_OSG
      93       448126 :     myGeom(0),
      94              : #endif
      95       448126 :     myAmClosed(false),
      96       448126 :     myLengthGeometryFactor2(myLengthGeometryFactor),
      97       448126 :     myLock(true) {
      98       448126 :     initRotations(myShape, myShapeRotations, myShapeLengths, myShapeColors);
      99              :     //
     100       448126 :     myHalfLaneWidth = myWidth / 2.;
     101       448126 :     myQuarterLaneWidth = myWidth / 4.;
     102       448126 : }
     103              : 
     104              : 
     105       894214 : GUILane::~GUILane() {
     106              :     // just to quit cleanly on a failure
     107       447107 :     if (myLock.locked()) {
     108            0 :         myLock.unlock();
     109              :     }
     110       447107 :     delete myParkingAreas;
     111       447107 :     delete myTesselation;
     112       894214 : }
     113              : 
     114              : 
     115              : void
     116       161695 : GUILane::updateMesoGUISegments() {
     117              : #ifdef _DEBUG
     118              :     const double origLength = myShape.length();
     119              : #endif
     120       323390 :     myShape = splitAtSegments(myShape);
     121              :     assert(fabs(myShape.length() - origLength) < POSITION_EPS);
     122              :     assert(myShapeSegments.size() == myShape.size());
     123       161695 :     initRotations(myShape, myShapeRotations, myShapeLengths, myShapeColors);
     124       161695 : }
     125              : 
     126              : 
     127              : void
     128       609821 : GUILane::initRotations(const PositionVector& shape,
     129              :                        std::vector<double>& rotations,
     130              :                        std::vector<double>& lengths,
     131              :                        std::vector<RGBColor>& colors) {
     132              :     rotations.clear();
     133              :     lengths.clear();
     134              :     colors.clear();
     135       609821 :     rotations.reserve(shape.size() - 1);
     136       609821 :     lengths.reserve(shape.size() - 1);
     137       609821 :     colors.reserve(shape.size() - 1);
     138       609821 :     int e = (int) shape.size() - 1;
     139      2036307 :     for (int i = 0; i < e; ++i) {
     140      1426486 :         const Position& f = shape[i];
     141      1426486 :         const Position& s = shape[i + 1];
     142      1426486 :         lengths.push_back(f.distanceTo2D(s));
     143      1426486 :         rotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
     144              :     }
     145       609821 : }
     146              : 
     147              : 
     148              : void
     149            0 : GUILane::addSecondaryShape(const PositionVector& shape) {
     150              :     myShape2 = shape;
     151            0 :     initRotations(myShape2, myShapeRotations2, myShapeLengths2, myShapeColors2);
     152            0 :     myLengthGeometryFactor2 = MAX2(POSITION_EPS, myShape2.length()) / myLength;
     153            0 : }
     154              : 
     155              : 
     156              : // ------ Vehicle insertion ------
     157              : void
     158       510792 : GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
     159              :                             const MSLane::VehCont::iterator& at,
     160              :                             MSMoveReminder::Notification notification) {
     161       510792 :     FXMutexLock locker(myLock);
     162       510792 :     MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
     163       510792 : }
     164              : 
     165              : 
     166              : // ------ Access to vehicles ------
     167              : const MSLane::VehCont&
     168    131870940 : GUILane::getVehiclesSecure() const {
     169    131870940 :     myLock.lock();
     170    131870940 :     return myVehicles;
     171              : }
     172              : 
     173              : 
     174              : void
     175    131870940 : GUILane::releaseVehicles() const {
     176    131870940 :     myLock.unlock();
     177    131870940 : }
     178              : 
     179              : 
     180              : void
     181     15364054 : GUILane::planMovements(const SUMOTime t) {
     182     15364054 :     FXMutexLock locker(myLock);
     183     15364054 :     MSLane::planMovements(t);
     184     15364054 : }
     185              : 
     186              : void
     187     15364054 : GUILane::setJunctionApproaches() const {
     188     15364054 :     FXMutexLock locker(myLock);
     189     15364054 :     MSLane::setJunctionApproaches();
     190     15364054 : }
     191              : 
     192              : 
     193              : void
     194     15364054 : GUILane::executeMovements(const SUMOTime t) {
     195     15364054 :     FXMutexLock locker(myLock);
     196     15364054 :     MSLane::executeMovements(t);
     197     15364053 : }
     198              : 
     199              : 
     200              : MSVehicle*
     201         6125 : GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
     202         6125 :     FXMutexLock locker(myLock);
     203        12250 :     return MSLane::removeVehicle(remVehicle, notification, notify);
     204              : }
     205              : 
     206              : 
     207              : void
     208         2582 : GUILane::removeParking(MSBaseVehicle* remVehicle) {
     209         2582 :     FXMutexLock locker(myLock);
     210         5164 :     return MSLane::removeParking(remVehicle);
     211              : }
     212              : 
     213              : 
     214              : void
     215     11346657 : GUILane::swapAfterLaneChange(SUMOTime t) {
     216     11346657 :     FXMutexLock locker(myLock);
     217     11346657 :     MSLane::swapAfterLaneChange(t);
     218     11346657 : }
     219              : 
     220              : 
     221              : void
     222      4335598 : GUILane::integrateNewVehicles() {
     223      4335598 :     FXMutexLock locker(myLock);
     224      4335598 :     MSLane::integrateNewVehicles();
     225      4335598 : }
     226              : 
     227              : 
     228              : void
     229     16792585 : GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
     230     16792585 :     FXMutexLock locker(myLock);
     231     16792585 :     MSLane::detectCollisions(timestep, stage);
     232     16792585 : }
     233              : 
     234              : 
     235              : double
     236      2889187 : GUILane::setPartialOccupation(MSVehicle* v) {
     237      2889187 :     FXMutexLock locker(myLock);
     238      5778374 :     return MSLane::setPartialOccupation(v);
     239              : }
     240              : 
     241              : 
     242              : void
     243      2889198 : GUILane::resetPartialOccupation(MSVehicle* v) {
     244      2889198 :     FXMutexLock locker(myLock);
     245      2889198 :     MSLane::resetPartialOccupation(v);
     246      2889198 : }
     247              : 
     248              : 
     249              : // ------ Drawing methods ------
     250              : void
     251            0 : GUILane::drawLinkNo(const GUIVisualizationSettings& s) const {
     252            0 :     int noLinks = (int)myLinks.size();
     253            0 :     if (noLinks == 0) {
     254              :         return;
     255              :     }
     256              :     // draw all links
     257            0 :     if (isCrossing()) {
     258              :         // draw indices at the start and end of the crossing
     259            0 :         const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
     260            0 :         PositionVector shape = getShape(s.secondaryShape);
     261            0 :         shape.extrapolate(0.5); // draw on top of the walking area
     262            0 :         GLHelper::drawTextAtEnd(toString(link->getIndex()), shape, 0, s.drawLinkJunctionIndex, s.scale);
     263            0 :         GLHelper::drawTextAtEnd(toString(link->getIndex()), shape.reverse(), 0, s.drawLinkJunctionIndex, s.scale);
     264              :         return;
     265            0 :     }
     266              :     // draw all links
     267            0 :     double w = myWidth / (double) noLinks;
     268            0 :     double x1 = myHalfLaneWidth;
     269            0 :     for (int i = noLinks; --i >= 0;) {
     270            0 :         double x2 = x1 - (double)(w / 2.);
     271            0 :         GLHelper::drawTextAtEnd(toString(myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i]->getIndex()), getShape(s.secondaryShape), x2, s.drawLinkJunctionIndex, s.scale);
     272            0 :         x1 -= w;
     273              :     }
     274              : }
     275              : 
     276              : 
     277              : void
     278            0 : GUILane::drawTLSLinkNo(const GUIVisualizationSettings& s, const GUINet& net) const {
     279            0 :     int noLinks = (int)myLinks.size();
     280            0 :     if (noLinks == 0) {
     281              :         return;
     282              :     }
     283            0 :     if (isCrossing()) {
     284              :         // draw indices at the start and end of the crossing
     285            0 :         const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
     286            0 :         int linkNo = net.getLinkTLIndex(link);
     287              :         // maybe the reverse link is controlled separately
     288            0 :         int linkNo2 = net.getLinkTLIndex(myLinks.front());
     289              :         // otherwise, use the same index as the forward link
     290            0 :         if (linkNo2 < 0) {
     291            0 :             linkNo2 = linkNo;
     292              :         }
     293            0 :         if (linkNo >= 0) {
     294            0 :             PositionVector shape = getShape(s.secondaryShape);
     295            0 :             shape.extrapolate(0.5); // draw on top of the walking area
     296            0 :             GLHelper::drawTextAtEnd(toString(linkNo2), shape, 0, s.drawLinkTLIndex, s.scale);
     297            0 :             GLHelper::drawTextAtEnd(toString(linkNo), shape.reverse(), 0, s.drawLinkTLIndex, s.scale);
     298            0 :         }
     299              :         return;
     300              :     }
     301              :     // draw all links
     302            0 :     double w = myWidth / (double) noLinks;
     303            0 :     double x1 = myHalfLaneWidth;
     304            0 :     for (int i = noLinks; --i >= 0;) {
     305            0 :         double x2 = x1 - (double)(w / 2.);
     306            0 :         int linkNo = net.getLinkTLIndex(myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i]);
     307            0 :         if (linkNo < 0) {
     308            0 :             continue;
     309              :         }
     310            0 :         GLHelper::drawTextAtEnd(toString(linkNo), getShape(s.secondaryShape), x2, s.drawLinkTLIndex, s.scale);
     311            0 :         x1 -= w;
     312              :     }
     313              : }
     314              : 
     315              : 
     316              : void
     317       367331 : GUILane::drawLinkRules(const GUIVisualizationSettings& s, const GUINet& net) const {
     318       367331 :     int noLinks = (int)myLinks.size();
     319       367331 :     const PositionVector& shape = getShape(s.secondaryShape);
     320       367331 :     if (noLinks == 0) {
     321       149578 :         drawLinkRule(s, net, nullptr, shape, 0, 0);
     322       149578 :         return;
     323              :     }
     324       217753 :     if (isCrossing()) {
     325              :         // draw rules at the start and end of the crossing
     326         7662 :         const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
     327         7662 :         const MSLink* link2 = myLinks.front();
     328         7662 :         if (link2->getTLLogic() == nullptr) {
     329              :             link2 = link;
     330              :         }
     331              :         PositionVector tmp = shape;
     332         7662 :         tmp.extrapolate(0.5); // draw on top of the walking area
     333         7662 :         drawLinkRule(s, net, link2, tmp, 0, myWidth);
     334         7662 :         drawLinkRule(s, net, link, tmp.reverse(), 0, myWidth);
     335              :         return;
     336         7662 :     }
     337              :     // draw all links
     338       210091 :     const double isRailSignal = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL;
     339       210091 :     double w = myWidth / (double) noLinks;
     340       210091 :     if (isRailSignal && noLinks > 1 && myLinks.back()->isTurnaround() && s.showRails) {
     341          764 :         w = myWidth / (double)(noLinks - 1);
     342              :     }
     343       210091 :     double x1 = isRailSignal && myIndex == 0 ? -myWidth * 0.5 : 0;
     344       474750 :     for (int i = 0; i < noLinks; ++i) {
     345       264659 :         double x2 = x1 + w;
     346       264659 :         drawLinkRule(s, net, myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i], shape, x1, x2);
     347              :         x1 = x2;
     348              :     }
     349              :     // draw stopOffset for passenger cars
     350       210091 :     if (myLaneStopOffset.isDefined() && (myLaneStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
     351          306 :         const double stopOffsetPassenger = myLaneStopOffset.getOffset();
     352              :         const Position& end = shape.back();
     353          306 :         const Position& f = shape[-2];
     354          306 :         const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
     355          306 :         GLHelper::setColor(s.getLinkColor(LINKSTATE_MAJOR));
     356          306 :         GLHelper::pushMatrix();
     357          306 :         glTranslated(end.x(), end.y(), 0);
     358          306 :         glRotated(rot, 0, 0, 1);
     359          306 :         glTranslated(0, stopOffsetPassenger, 0);
     360          306 :         glBegin(GL_QUADS);
     361          306 :         glVertex2d(-myHalfLaneWidth, 0.0);
     362          306 :         glVertex2d(-myHalfLaneWidth, 0.2);
     363          306 :         glVertex2d(myHalfLaneWidth, 0.2);
     364          306 :         glVertex2d(myHalfLaneWidth, 0.0);
     365          306 :         glEnd();
     366          306 :         GLHelper::popMatrix();
     367              :     }
     368              : }
     369              : 
     370              : 
     371              : void
     372       429561 : GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link, const PositionVector& shape, double x1, double x2) const {
     373              :     const Position& end = shape.back();
     374       429561 :     const Position& f = shape[-2];
     375       429561 :     const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
     376       429561 :     if (link == nullptr) {
     377       149578 :         if (static_cast<GUIEdge*>(myEdge)->showDeadEnd()) {
     378           91 :             GLHelper::setColor(GUIVisualizationColorSettings::SUMO_color_DEADEND_SHOW);
     379              :         } else {
     380       149487 :             GLHelper::setColor(GUIVisualizationSettings::getLinkColor(LINKSTATE_DEADEND));
     381              :         }
     382       149578 :         GLHelper::pushMatrix();
     383       149578 :         glTranslated(end.x(), end.y(), 0);
     384       149578 :         glRotated(rot, 0, 0, 1);
     385       149578 :         glBegin(GL_QUADS);
     386       149578 :         glVertex2d(-myHalfLaneWidth, 0.0);
     387       149578 :         glVertex2d(-myHalfLaneWidth, 0.5);
     388       149578 :         glVertex2d(myHalfLaneWidth, 0.5);
     389       149578 :         glVertex2d(myHalfLaneWidth, 0.0);
     390       149578 :         glEnd();
     391       149578 :         GLHelper::popMatrix();
     392              :     } else {
     393       279983 :         GLHelper::pushMatrix();
     394       279983 :         glTranslated(end.x(), end.y(), 0);
     395       279983 :         glRotated(rot, 0, 0, 1);
     396              :         // select glID
     397              : 
     398       279983 :         switch (link->getState()) {
     399           16 :             case LINKSTATE_ALLWAY_STOP:
     400              :             case LINKSTATE_STOP: {
     401              :                 // might be a traffic light link
     402           16 :                 int tlID = net.getLinkTLID(link);
     403           32 :                 GLHelper::pushName(tlID != 0 ? tlID : getGlID());
     404           16 :                 break;
     405              :             }
     406        54222 :             case LINKSTATE_TL_GREEN_MAJOR:
     407              :             case LINKSTATE_TL_GREEN_MINOR:
     408              :             case LINKSTATE_TL_RED:
     409              :             case LINKSTATE_TL_REDYELLOW:
     410              :             case LINKSTATE_TL_YELLOW_MAJOR:
     411              :             case LINKSTATE_TL_YELLOW_MINOR:
     412              :             case LINKSTATE_TL_OFF_BLINKING:
     413              :             case LINKSTATE_TL_OFF_NOSIGNAL:
     414        54222 :                 GLHelper::pushName(net.getLinkTLID(link));
     415        54222 :                 break;
     416       225745 :             case LINKSTATE_MAJOR:
     417              :             case LINKSTATE_MINOR:
     418              :             case LINKSTATE_EQUAL:
     419              :             default:
     420       225745 :                 GLHelper::pushName(getGlID());
     421       225745 :                 break;
     422              :         }
     423       279983 :         GLHelper::setColor(GUIVisualizationSettings::getLinkColor(link->getState(), s.realisticLinkRules));
     424       279983 :         if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
     425              :             // the white bar should be the default for most railway
     426              :             // links and looks ugly so we do not draw it
     427       277082 :             double scale = isInternal() ? 0.5 : 1;
     428       554164 :             if (myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL) {
     429         7940 :                 scale *= MAX2(s.laneWidthExaggeration, s.junctionSize.getExaggeration(s, this, 10));
     430              :             }
     431       277082 :             glScaled(scale, scale, 1);
     432       277082 :             glBegin(GL_QUADS);
     433       277082 :             glVertex2d(x1 - myHalfLaneWidth, 0.0);
     434       277082 :             glVertex2d(x1 - myHalfLaneWidth, 0.5);
     435       277082 :             glVertex2d(x2 - myHalfLaneWidth, 0.5);
     436       277082 :             glVertex2d(x2 - myHalfLaneWidth, 0.0);
     437       277082 :             glEnd();
     438       277082 :             if (s.gaming && link->haveGreen()) {
     439              :                 const MSLane* lane = link->getLane();
     440              :                 // exaggerate green signals for railway game
     441            0 :                 if (isRailway(lane->getPermissions())) {
     442            0 :                     GLHelper::drawFilledCircle(lane->getWidth() / 2., 8, 90, 270);
     443              :                 }
     444              :             }
     445              :         }
     446       279983 :         GLHelper::popName();
     447       279983 :         GLHelper::popMatrix();
     448              :     }
     449       429561 : }
     450              : 
     451              : void
     452       319438 : GUILane::drawArrows(const GUIVisualizationSettings& s, const RGBColor& color) const {
     453       319438 :     if (myLinks.size() == 0) {
     454       146221 :         return;
     455              :     }
     456       173217 :     const RGBColor laneCol = color.isValid() ? color : setColor(s);
     457              :     // draw all links
     458       173217 :     const Position& end = getShape(s.secondaryShape).back();
     459       173217 :     const Position& f = getShape(s.secondaryShape)[-2];
     460       173217 :     const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
     461       173217 :     GLHelper::pushMatrix();
     462       173217 :     GLHelper::setColor(laneCol.getContrastingColor());
     463       173217 :     glTranslated(end.x(), end.y(), 0);
     464       173217 :     glRotated(rot, 0, 0, 1);
     465       173217 :     if (myWidth < SUMO_const_laneWidth) {
     466         3280 :         glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
     467              :     }
     468       399998 :     for (const MSLink* const link : myLinks) {
     469              :         LinkDirection dir = link->getDirection();
     470              :         LinkState state = link->getState();
     471       226781 :         if (state == LINKSTATE_DEADEND || dir == LinkDirection::NODIR) {
     472            0 :             continue;
     473              :         }
     474       226781 :         switch (dir) {
     475              :             case LinkDirection::STRAIGHT:
     476       152536 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
     477       152536 :                 GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
     478       152536 :                 break;
     479              :             case LinkDirection::TURN:
     480         6656 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
     481         6656 :                 GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
     482         6656 :                 GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
     483         6656 :                 GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
     484         6656 :                 break;
     485              :             case LinkDirection::TURN_LEFTHAND:
     486            0 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
     487            0 :                 GLHelper::drawBoxLine(Position(0, 2.5), -90, .5, .05);
     488            0 :                 GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
     489            0 :                 GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
     490            0 :                 break;
     491              :             case LinkDirection::LEFT:
     492        25534 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
     493        25534 :                 GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
     494        25534 :                 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
     495        25534 :                 break;
     496              :             case LinkDirection::RIGHT:
     497        30411 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
     498        30411 :                 GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
     499        30411 :                 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
     500        30411 :                 break;
     501              :             case LinkDirection::PARTLEFT:
     502          223 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
     503          223 :                 GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
     504          223 :                 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
     505          223 :                 break;
     506              :             case LinkDirection::PARTRIGHT:
     507        11421 :                 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
     508        11421 :                 GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
     509        11421 :                 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
     510        11421 :                 break;
     511              :             default:
     512              :                 break;
     513              :         }
     514              :     }
     515       173217 :     GLHelper::popMatrix();
     516              : }
     517              : 
     518              : 
     519              : void
     520            0 : GUILane::drawLane2LaneConnections(double exaggeration, bool s2) const {
     521              :     Position centroid;
     522            0 :     if (exaggeration > 1) {
     523            0 :         centroid = myEdge->getToJunction()->getShape().getCentroid();
     524              :     }
     525            0 :     for (const MSLink* const link : myLinks) {
     526            0 :         const GUILane* connected = dynamic_cast<GUILane*>(link->getLane());
     527            0 :         if (connected == nullptr) {
     528            0 :             continue;
     529              :         }
     530            0 :         GLHelper::setColor(GUIVisualizationSettings::getLinkColor(link->getState()));
     531            0 :         glBegin(GL_LINES);
     532            0 :         Position p1 = myEdge->isWalkingArea() ? getShape(s2).getCentroid() : getShape(s2)[-1];
     533            0 :         Position p2 = connected->isWalkingArea() ? connected->getShape(s2).getCentroid() : connected->getShape(s2)[0];
     534            0 :         if (exaggeration > 1) {
     535            0 :             p1 = centroid + ((p1 - centroid) * exaggeration);
     536            0 :             p2 = centroid + ((p2 - centroid) * exaggeration);
     537              :         }
     538            0 :         glVertex2d(p1.x(), p1.y());
     539            0 :         glVertex2d(p2.x(), p2.y());
     540            0 :         glEnd();
     541            0 :         GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
     542              :     }
     543            0 : }
     544              : 
     545              : 
     546              : void
     547     45907925 : GUILane::drawGL(const GUIVisualizationSettings& s) const {
     548     45907925 :     GLHelper::pushMatrix();
     549     45907925 :     GLHelper::pushName(getGlID());
     550     45907925 :     const bool s2 = s.secondaryShape;
     551     45907925 :     double exaggeration = s.laneWidthExaggeration;
     552     45907925 :     if (MSGlobals::gUseMesoSim) {
     553      8720924 :         GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
     554      8720924 :         exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s, s.edgeScaler.getActive()));
     555              :     } else {
     556     37187001 :         exaggeration *= s.laneScaler.getScheme().getColor(getScaleValue(s, s.laneScaler.getActive(), s2));
     557              :     }
     558              :     // set lane color
     559     45907925 :     const RGBColor color = setColor(s);
     560              :     // recognize full transparency and simply don't draw
     561     45907925 :     if (color.alpha() != 0 && s.scale * exaggeration > s.laneMinSize) {
     562              : 
     563     45736072 :         const bool isCrossing = myEdge->isCrossing();
     564              :         const bool isWalkingArea = myEdge->isWalkingArea();
     565     45736072 :         const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
     566     45736072 :         const PositionVector& baseShape = getShape(s2);
     567     45736072 :         const bool hasRailSignal = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL;
     568     45736072 :         if (s.trueZ) {
     569          284 :             glTranslated(0, 0, baseShape.getMinZ());
     570              :         } else {
     571     45735788 :             if (isCrossing) {
     572              :                 // draw internal lanes on top of junctions
     573       163470 :                 glTranslated(0, 0, GLO_JUNCTION + 0.1);
     574     45572318 :             } else if (isWalkingArea) {
     575              :                 // draw internal lanes on top of junctions
     576       531071 :                 glTranslated(0, 0, GLO_JUNCTION + 0.3);
     577     45041247 :             } else if (isWaterway(myPermissions)) {
     578              :                 // draw waterways below normal roads
     579          432 :                 glTranslated(0, 0, getType() - 0.2);
     580     45040815 :             } else if (myPermissions == SVC_SUBWAY) {
     581              :                 // draw subways further below
     582            0 :                 glTranslated(0, 0, getType() - 0.4);
     583              :             } else {
     584     45040815 :                 glTranslated(0, 0, getType());
     585              :             }
     586              :         }
     587     45736072 :         auto& shapeColors = getShapeColors(s2);
     588     45736072 :         if (MSGlobals::gUseMesoSim) {
     589              :             shapeColors.clear();
     590      8629971 :             const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
     591      8629971 :             if (segmentColors.size() > 0) {
     592              :                 // apply segment specific shape colors
     593              :                 //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
     594            0 :                 for (int ii = 0; ii < (int)baseShape.size() - 1; ++ii) {
     595            0 :                     shapeColors.push_back(segmentColors[myShapeSegments[ii]]);
     596              :                 }
     597              :             }
     598              :         }
     599              : 
     600              :         // scale tls-controlled lane2lane-arrows along with their junction shapes
     601              :         double junctionExaggeration = 1;
     602              :         if (!isInternal
     603     18139316 :                 && myEdge->getToJunction()->getType() <= SumoXMLNodeType::RAIL_CROSSING
     604     50593212 :                 && (s.junctionSize.constantSize || s.junctionSize.exaggeration > 1)) {
     605            0 :             junctionExaggeration = MAX2(1.001, s.junctionSize.getExaggeration(s, this, 4));
     606              :         }
     607              :         // draw lane
     608              :         // check whether it is not too small
     609     45736072 :         if (s.scale * exaggeration < 1. && junctionExaggeration == 1 && s.junctionSize.minSize != 0) {
     610     27556550 :             if (!isInternal || hasRailSignal) {
     611     11591218 :                 if (shapeColors.size() > 0) {
     612            0 :                     GLHelper::drawLine(baseShape, shapeColors);
     613              :                 } else {
     614     11591218 :                     GLHelper::drawLine(baseShape);
     615              :                 }
     616              :             }
     617     27556550 :             GLHelper::popMatrix();
     618              : 
     619              :         } else {
     620              : 
     621     18179522 :             GUINet* net = (GUINet*) MSNet::getInstance();
     622              :             bool mustDrawMarkings = false;
     623     18179522 :             bool hiddenBidi = getBidiLane() != nullptr && myEdge->getNumericalID() > myEdge->getBidiEdge()->getNumericalID();
     624     18179522 :             const bool detailZoom = s.scale * exaggeration > 5;
     625     18179522 :             const bool drawDetails = (detailZoom || s.junctionSize.minSize == 0 || hasRailSignal);
     626     18179522 :             const bool drawRails = drawAsRailway(s);
     627     18179522 :             const bool spreadSuperposed = s.spreadSuperposed && myBidiLane != nullptr;
     628     18179522 :             if (hiddenBidi && !spreadSuperposed) {
     629              :                 // do not draw shape
     630        38634 :                 mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions) && neighLaneNotBidi();
     631     18140888 :             } else if (drawRails) {
     632              :                 // draw as railway: assume standard gauge of 1435mm when lane width is not set
     633              :                 // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
     634              :                 // assume crosstie length of 181% gauge (2600mm for standard gauge)
     635              :                 PositionVector shape = baseShape;
     636        40007 :                 const double width = myWidth;
     637        40007 :                 double halfGauge = 0.5 * (width == SUMO_const_laneWidth ?  1.4350 : width) * exaggeration;
     638        40007 :                 if (spreadSuperposed) {
     639              :                     try {
     640            0 :                         shape.move2side(halfGauge * 0.8);
     641            0 :                     } catch (InvalidArgument&) {}
     642            0 :                     halfGauge *= 0.4;
     643              :                 }
     644        40007 :                 const double halfInnerFeetWidth = halfGauge - 0.039 * exaggeration;
     645        40007 :                 const double halfRailWidth = detailZoom ? (halfInnerFeetWidth + 0.15 * exaggeration) : SUMO_const_halfLaneWidth * exaggeration;
     646        40007 :                 const double halfCrossTieWidth = halfGauge * 1.81;
     647        40007 :                 if (shapeColors.size() > 0) {
     648            0 :                     GLHelper::drawBoxLines(shape, getShapeRotations(s2), getShapeLengths(s2), getShapeColors(s2), halfRailWidth);
     649              :                 } else {
     650        40007 :                     GLHelper::drawBoxLines(shape, getShapeRotations(s2), getShapeLengths(s2), halfRailWidth);
     651              :                 }
     652              :                 // Draw white on top with reduced width (the area between the two tracks)
     653        40007 :                 if (detailZoom) {
     654         1936 :                     glColor3d(1, 1, 1);
     655         1936 :                     glTranslated(0, 0, .1);
     656         1936 :                     GLHelper::drawBoxLines(shape, getShapeRotations(s2), getShapeLengths(s2), halfInnerFeetWidth);
     657         1936 :                     setColor(s);
     658         1936 :                     GLHelper::drawCrossTies(shape, getShapeRotations(s2), getShapeLengths(s2), 0.26 * exaggeration, 0.6 * exaggeration,
     659         1936 :                                             halfCrossTieWidth, 0, s.forceDrawForRectangleSelection);
     660              :                 }
     661     18140888 :             } else if (isCrossing) {
     662       161242 :                 if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
     663        84152 :                     glTranslated(0, 0, .2);
     664        84152 :                     GLHelper::drawCrossTies(baseShape, getShapeRotations(s2), getShapeLengths(s2), 0.5, 1.0, getWidth() * 0.5,
     665        84152 :                                             0, s.drawForRectangleSelection);
     666              : #ifdef GUILane_DEBUG_DRAW_CROSSING_OUTLINE
     667              :                     if (myOutlineShape != nullptr) {
     668              :                         GLHelper::setColor(RGBColor::BLUE);
     669              :                         glTranslated(0, 0, 0.4);
     670              :                         GLHelper::drawBoxLines(*myOutlineShape, 0.1);
     671              :                         glTranslated(0, 0, -0.4);
     672              :                         if (s.geometryIndices.show(this)) {
     673              :                             GLHelper::debugVertices(*myOutlineShape, s.geometryIndices, s.scale);
     674              :                         }
     675              :                     }
     676              : #endif
     677        84152 :                     glTranslated(0, 0, -.2);
     678              :                 }
     679     17939639 :             } else if (isWalkingArea) {
     680       519974 :                 if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
     681       329879 :                     glTranslated(0, 0, .2);
     682       329879 :                     if (myTesselation == nullptr) {
     683         6554 :                         myTesselation = new TesselatedPolygon(getID(), "", RGBColor::MAGENTA, PositionVector(), false, true, 0);
     684              :                     }
     685       329879 :                     myTesselation->drawTesselation(baseShape);
     686       329879 :                     glTranslated(0, 0, -.2);
     687       329879 :                     if (s.geometryIndices.show(this)) {
     688            0 :                         GLHelper::debugVertices(baseShape, s.geometryIndices, s.scale);
     689              :                     }
     690              :                 }
     691              :             } else {
     692              :                 // we draw the lanes with reduced width so that the lane markings below are visible
     693              :                 // (this avoids artifacts at geometry corners without having to
     694              :                 // compute lane-marking intersection points)
     695     17419665 :                 double halfWidth = isInternal ? myQuarterLaneWidth : (myHalfLaneWidth - SUMO_const_laneMarkWidth / 2);
     696     17419665 :                 mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions) && !isAirway(myPermissions);
     697     17419665 :                 const int cornerDetail = drawDetails && !isInternal ? (s.drawForRectangleSelection ? 4 : MIN2(32, (int)(s.scale * exaggeration))) : 0;
     698     34839330 :                 double offset = halfWidth * MAX2(0., (exaggeration - 1)) * (MSGlobals::gLefthand ? -1 : 1);
     699     17419665 :                 if (spreadSuperposed) {
     700        77728 :                     offset += halfWidth * 0.5 * (MSGlobals::gLefthand ? -1 : 1);
     701        77728 :                     halfWidth *= 0.4; // create visible gap
     702              :                 }
     703     17419665 :                 if (shapeColors.size() > 0) {
     704            0 :                     GLHelper::drawBoxLines(baseShape, getShapeRotations(s2), getShapeLengths(s2), shapeColors, halfWidth * exaggeration, cornerDetail, offset);
     705              :                 } else {
     706     17419665 :                     GLHelper::drawBoxLines(baseShape, getShapeRotations(s2), getShapeLengths(s2), halfWidth * exaggeration, cornerDetail, offset);
     707              :                 }
     708              :             }
     709     18179522 :             GLHelper::popMatrix();
     710              : #ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
     711              :             if (myEdge->isInternal() && gSelected.isSelected(getType(), getGlID())) {
     712              :                 debugDrawFoeIntersections();
     713              :             }
     714              : #endif
     715     18179522 :             if (s.geometryIndices.show(this)) {
     716            0 :                 GLHelper::debugVertices(baseShape, s.geometryIndices, s.scale);
     717              :             }
     718              :             // draw details
     719     18179522 :             if ((!isInternal || isCrossing || !s.drawJunctionShape) && (drawDetails || junctionExaggeration > 1)) {
     720       367331 :                 GLHelper::pushMatrix();
     721       367331 :                 glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
     722       367331 :                 glTranslated(0, 0, .5);
     723       367331 :                 if (drawDetails) {
     724       367331 :                     if (s.showLaneDirection) {
     725            0 :                         if (drawRails) {
     726              :                             // improve visibility of superposed rail edges
     727            0 :                             GLHelper::setColor(setColor(s).changedBrightness(100));
     728              :                         } else {
     729            0 :                             glColor3d(0.3, 0.3, 0.3);
     730              :                         }
     731            0 :                         if (!isCrossing || s.drawCrossingsAndWalkingareas) {
     732            0 :                             drawDirectionIndicators(exaggeration, spreadSuperposed, s.secondaryShape);
     733              :                         }
     734              :                     }
     735              :                     if (!isInternal || isCrossing
     736              :                             // controlled internal junction
     737       367331 :                             || (getLinkCont().size() != 0 && getLinkCont()[0]->isInternalJunctionLink() && getLinkCont()[0]->getTLLogic() != nullptr)) {
     738       367331 :                         if (MSGlobals::gLateralResolution > 0 && s.showSublanes && !hiddenBidi && (myPermissions & ~(SVC_PEDESTRIAN | SVC_RAIL_CLASSES)) != 0) {
     739              :                             // draw sublane-borders
     740       113211 :                             const double offsetSign = MSGlobals::gLefthand ? -1 : 1;
     741       113211 :                             GLHelper::setColor(color.changedBrightness(51));
     742       633772 :                             for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
     743       520561 :                                 GLHelper::drawBoxLines(baseShape, getShapeRotations(s2), getShapeLengths(s2), 0.01, 0, -offset * offsetSign);
     744              :                             }
     745              :                         }
     746       367331 :                         if (MSGlobals::gUseMesoSim && mySegmentStartIndex.size() > 0 && (myPermissions & ~SVC_PEDESTRIAN) != 0) {
     747              :                             // draw segment borders
     748        32977 :                             GLHelper::setColor(color.changedBrightness(51));
     749        66807 :                             for (int i : mySegmentStartIndex) {
     750        33830 :                                 if (shapeColors.size() > 0) {
     751            0 :                                     GLHelper::setColor(shapeColors[i].changedBrightness(51));
     752              :                                 }
     753        33830 :                                 GLHelper::drawBoxLine(baseShape[i], getShapeRotations(s2)[i] + 90, myWidth / 3, 0.2, 0);
     754        33830 :                                 GLHelper::drawBoxLine(baseShape[i], getShapeRotations(s2)[i] - 90, myWidth / 3, 0.2, 0);
     755              :                             }
     756              :                         }
     757       367331 :                         if (s.showLinkDecals && !drawRails && !drawAsWaterway(s) && myPermissions != SVC_PEDESTRIAN) {
     758       319438 :                             drawArrows(s, color);
     759              :                         }
     760       367331 :                         glTranslated(0, 0, 1000);
     761       367331 :                         if (s.drawLinkJunctionIndex.show(nullptr)) {
     762            0 :                             drawLinkNo(s);
     763              :                         }
     764       367331 :                         if (s.drawLinkTLIndex.show(nullptr)) {
     765            0 :                             drawTLSLinkNo(s, *net);
     766              :                         }
     767       367331 :                         glTranslated(0, 0, -1000);
     768              :                     }
     769       367331 :                     glTranslated(0, 0, .1);
     770              :                 }
     771       367331 :                 if ((drawDetails || junctionExaggeration > 1) && s.showLane2Lane) {
     772              :                     //  draw from end of first to the begin of second but respect junction scaling
     773            0 :                     drawLane2LaneConnections(junctionExaggeration, s.secondaryShape);
     774              :                 }
     775       367331 :                 GLHelper::popMatrix();
     776              :                 // make sure link rules are drawn so tls can be selected via right-click
     777       367331 :                 if (s.showLinkRules && drawDetails && !isWalkingArea &&
     778       367331 :                         (!myEdge->isInternal() || (getLinkCont().size() > 0 && getLinkCont()[0]->isInternalJunctionLink()))) {
     779       367331 :                     GLHelper::pushMatrix();
     780       367331 :                     glTranslated(0, 0, GLO_SHAPE); // must draw on top of junction shape and additionals
     781       367331 :                     drawLinkRules(s, *net);
     782       367331 :                     GLHelper::popMatrix();
     783              :                 }
     784              :             }
     785     18179522 :             if (mustDrawMarkings && drawDetails && s.laneShowBorders) { // needs matrix reset
     786       309977 :                 drawMarkings(s, exaggeration, color);
     787              :             }
     788       288230 :             if (drawDetails && isInternal && s.showBikeMarkings && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi
     789         2352 :                     && MSGlobals::gUsingInternalLanes
     790     18181874 :                     && getNormalSuccessorLane()->getPermissions() == SVC_BICYCLE && getNormalPredecessorLane()->getPermissions() == SVC_BICYCLE) {
     791          645 :                 drawBikeMarkings(color);
     792              :             }
     793       288230 :             if (drawDetails && isInternal && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi && myIndex > 0
     794     18223435 :                     && !(myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER) && allowsChangingRight(SVC_PASSENGER))) {
     795              :                 // draw lane changing prohibitions on junction
     796           12 :                 drawJunctionChangeProhibitions(color);
     797              :             }
     798              :         }
     799              :     } else {
     800       171853 :         GLHelper::popMatrix();
     801              :     }
     802              :     // draw vehicles
     803     45907925 :     if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
     804              :         // retrieve vehicles from lane; disallow simulation
     805     18351363 :         const MSLane::VehCont& vehicles = getVehiclesSecure();
     806     30789598 :         for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
     807     12438235 :             if ((*v)->getLane() == this) {
     808     12438235 :                 static_cast<const GUIVehicle*>(*v)->drawGL(s);
     809              :             } // else: this is the shadow during a continuous lane change
     810              :         }
     811              :         // draw long partial vehicles (#14342)
     812              :         // must prevent concurrent access via MSVehicle::cleanupFurtherLanes to avoid crash (#18271)
     813     18351363 :         myPartialOccupatorMutex.lock();
     814     19093651 :         for (const MSVehicle* veh : myPartialVehicles) {
     815       742288 :             if (veh->getLength() > RENDERING_BUFFER) {
     816              :                 // potential double rendering taken into account
     817        15637 :                 static_cast<const GUIVehicle*>(veh)->drawGL(s);
     818              :             }
     819              :         }
     820     18351363 :         myPartialOccupatorMutex.unlock();
     821              :         // draw parking vehicles
     822     18374946 :         for (const MSBaseVehicle* const v : myParkingVehicles) {
     823        23583 :             dynamic_cast<const GUIBaseVehicle*>(v)->drawGL(s);
     824              :         }
     825              :         // allow lane simulation
     826     18351363 :         releaseVehicles();
     827              :     }
     828     45907925 :     GLHelper::popName();
     829     45907925 : }
     830              : 
     831              : bool
     832        22451 : GUILane::neighLaneNotBidi() const {
     833        22451 :     const MSLane* right = getParallelLane(-1, false);
     834        22451 :     if (right && right->getBidiLane() == nullptr) {
     835              :         return true;
     836              :     }
     837         8309 :     const MSLane* left = getParallelLane(1, false);
     838         8309 :     if (left && left->getBidiLane() == nullptr) {
     839              :         return true;
     840              :     }
     841              :     return false;
     842              : }
     843              : 
     844              : void
     845       309977 : GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale, const RGBColor& color) const {
     846       309977 :     GLHelper::pushMatrix();
     847       309977 :     glTranslated(0, 0, GLO_EDGE);
     848       309977 :     setColor(s);
     849              :     // optionally draw inverse markings
     850       309977 :     const bool s2 = s.secondaryShape;
     851       309977 :     if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
     852              :         const bool cl = myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER);
     853              :         const bool cr = allowsChangingRight(SVC_PASSENGER);
     854        95045 :         GLHelper::drawInverseMarkings(getShape(s2), getShapeRotations(s2), getShapeLengths(s2), 3, 6, myHalfLaneWidth, cl, cr, MSGlobals::gLefthand, scale);
     855              :     }
     856              :     // draw boundings and markings
     857       309977 :     const RGBColor laneCol = color.isValid() ? color : setColor(s);
     858       309977 :     GLHelper::setColor(laneCol.getContrastingColor());
     859       619954 :     GLHelper::drawBoxLines(
     860       309977 :         getShape(s2),
     861              :         getShapeRotations(s2),
     862              :         getShapeLengths(s2),
     863       309977 :         (myHalfLaneWidth + SUMO_const_laneMarkWidth) * scale);
     864       309977 :     GLHelper::popMatrix();
     865       309977 : }
     866              : 
     867              : 
     868              : void
     869          645 : GUILane::drawBikeMarkings(const RGBColor& color) const {
     870              :     // draw bike lane markings onto the intersection
     871          645 :     GLHelper::setColor(color.isValid() ? color.getContrastingColor() : RGBColor::WHITE);
     872              :     /// fixme
     873              :     const bool s2 = false;
     874          645 :     const int e = (int) getShape(s2).size() - 1;
     875              :     const double markWidth = 0.1;
     876          645 :     const double mw = myHalfLaneWidth;
     877         2082 :     for (int i = 0; i < e; ++i) {
     878         1437 :         GLHelper::pushMatrix();
     879         1437 :         glTranslated(getShape(s2)[i].x(), getShape(s2)[i].y(), GLO_JUNCTION + 0.4);
     880         1437 :         glRotated(getShapeRotations(s2)[i], 0, 0, 1);
     881        11958 :         for (double t = 0; t < getShapeLengths(s2)[i]; t += 0.5) {
     882              :             // left and right marking
     883        31563 :             for (int side = -1; side <= 1; side += 2) {
     884        21042 :                 glBegin(GL_QUADS);
     885        21042 :                 glVertex2d(side * mw, -t);
     886        21042 :                 glVertex2d(side * mw, -t - 0.35);
     887        21042 :                 glVertex2d(side * (mw + markWidth), -t - 0.35);
     888        21042 :                 glVertex2d(side * (mw + markWidth), -t);
     889        21042 :                 glEnd();
     890              :             }
     891              :         }
     892         1437 :         GLHelper::popMatrix();
     893              :     }
     894          645 : }
     895              : 
     896              : 
     897              : void
     898           12 : GUILane::drawJunctionChangeProhibitions(const RGBColor& color) const {
     899              :     // fixme
     900              :     const bool s2 = false;
     901              :     // draw markings
     902           12 :     if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
     903           12 :         GLHelper::setColor(color.isValid() ? color.getContrastingColor() : RGBColor::WHITE);
     904           12 :         const bool cl = myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER);
     905              :         const bool cr = allowsChangingRight(SVC_PASSENGER);
     906              :         // solid line marking
     907              :         double mw, mw2;
     908              :         // optional broken line marking
     909              :         double mw3, mw4;
     910           12 :         if (!cl && !cr) {
     911              :             // draw a single solid line
     912            2 :             mw = myHalfLaneWidth + SUMO_const_laneMarkWidth * 0.4;
     913            2 :             mw2 = myHalfLaneWidth - SUMO_const_laneMarkWidth * 0.4;
     914              :             mw3 = myHalfLaneWidth;
     915              :             mw4 = myHalfLaneWidth;
     916              :         } else {
     917              :             // draw one solid and one broken line
     918           10 :             if (cl) {
     919            4 :                 mw = myHalfLaneWidth - SUMO_const_laneMarkWidth * 0.2;
     920            4 :                 mw2 = myHalfLaneWidth - SUMO_const_laneMarkWidth * 0.6;
     921            4 :                 mw3 = myHalfLaneWidth + SUMO_const_laneMarkWidth * 0.2;
     922            4 :                 mw4 = myHalfLaneWidth + SUMO_const_laneMarkWidth * 0.6;
     923              :             } else {
     924            6 :                 mw = myHalfLaneWidth + SUMO_const_laneMarkWidth * 0.2;
     925            6 :                 mw2 = myHalfLaneWidth + SUMO_const_laneMarkWidth * 0.6;
     926            6 :                 mw3 = myHalfLaneWidth - SUMO_const_laneMarkWidth * 0.2;
     927            6 :                 mw4 = myHalfLaneWidth - SUMO_const_laneMarkWidth * 0.6;
     928              :             }
     929              :         }
     930           12 :         if (MSGlobals::gLefthand) {
     931            0 :             mw *= -1;
     932            0 :             mw2 *= -1;
     933              :         }
     934           12 :         int e = (int) getShape(s2).size() - 1;
     935           24 :         for (int i = 0; i < e; ++i) {
     936           12 :             GLHelper::pushMatrix();
     937           12 :             glTranslated(getShape(s2)[i].x(), getShape(s2)[i].y(), GLO_JUNCTION + 0.4);
     938           12 :             glRotated(getShapeRotations(s2)[i], 0, 0, 1);
     939          252 :             for (double t = 0; t < getShapeLengths(s2)[i]; t += 6) {
     940          240 :                 const double lengthSolid = MIN2(6.0, getShapeLengths(s2)[i] - t);
     941          240 :                 glBegin(GL_QUADS);
     942          240 :                 glVertex2d(-mw, -t);
     943          240 :                 glVertex2d(-mw, -t - lengthSolid);
     944          240 :                 glVertex2d(-mw2, -t - lengthSolid);
     945          240 :                 glVertex2d(-mw2, -t);
     946          240 :                 glEnd();
     947          240 :                 if (cl || cr) {
     948          200 :                     const double lengthBroken = MIN2(3.0, getShapeLengths(s2)[i] - t);
     949          200 :                     glBegin(GL_QUADS);
     950          200 :                     glVertex2d(-mw3, -t);
     951          200 :                     glVertex2d(-mw3, -t - lengthBroken);
     952          200 :                     glVertex2d(-mw4, -t - lengthBroken);
     953          200 :                     glVertex2d(-mw4, -t);
     954          200 :                     glEnd();
     955              :                 }
     956              :             }
     957           12 :             GLHelper::popMatrix();
     958              :         }
     959              :     }
     960           12 : }
     961              : 
     962              : void
     963            0 : GUILane::drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const {
     964            0 :     GLHelper::pushMatrix();
     965            0 :     glTranslated(0, 0, GLO_EDGE);
     966            0 :     int e = (int) getShape(s2).size() - 1;
     967            0 :     const double widthFactor = spreadSuperposed ? 0.4 : 1;
     968            0 :     const double w = MAX2(POSITION_EPS, myWidth * widthFactor);
     969            0 :     const double w2 = MAX2(POSITION_EPS, myHalfLaneWidth * widthFactor);
     970            0 :     const double w4 = MAX2(POSITION_EPS, myQuarterLaneWidth * widthFactor);
     971            0 :     const double sideOffset = spreadSuperposed ? w * -0.5 : 0;
     972            0 :     for (int i = 0; i < e; ++i) {
     973            0 :         GLHelper::pushMatrix();
     974            0 :         glTranslated(getShape(s2)[i].x(), getShape(s2)[i].y(), 0.1);
     975            0 :         glRotated(getShapeRotations(s2)[i], 0, 0, 1);
     976            0 :         for (double t = 0; t < getShapeLengths(s2)[i]; t += w) {
     977            0 :             const double length = MIN2(w2, getShapeLengths(s2)[i] - t) * exaggeration;
     978            0 :             glBegin(GL_TRIANGLES);
     979            0 :             glVertex2d(sideOffset, -t - length);
     980            0 :             glVertex2d(sideOffset - w4 * exaggeration, -t);
     981            0 :             glVertex2d(sideOffset + w4 * exaggeration, -t);
     982            0 :             glEnd();
     983              :         }
     984            0 :         GLHelper::popMatrix();
     985              :     }
     986            0 :     GLHelper::popMatrix();
     987            0 : }
     988              : 
     989              : 
     990              : void
     991            0 : GUILane::debugDrawFoeIntersections() const {
     992            0 :     GLHelper::pushMatrix();
     993            0 :     glTranslated(0, 0, 5);
     994            0 :     glColor3d(1.0, 0.3, 0.3);
     995              :     const double orthoLength = 0.5;
     996            0 :     const MSLink* link = getLinkCont().front();
     997              :     const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
     998              :     const auto& conflicts = link->getConflicts();
     999            0 :     if (foeLanes.size() == conflicts.size()) {
    1000            0 :         for (int i = 0; i < (int)foeLanes.size(); ++i) {
    1001            0 :             const MSLane* l = foeLanes[i];
    1002            0 :             Position pos = l->geometryPositionAtOffset(l->getLength() - conflicts[i].lengthBehindCrossing);
    1003            0 :             PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
    1004            0 :             if (ortho.length() < orthoLength) {
    1005            0 :                 ortho.extrapolate(orthoLength - ortho.length(), false, true);
    1006              :             }
    1007            0 :             GLHelper::drawLine(ortho);
    1008              :             //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - conflicts[i].lengthBehindCrossing << " pos=" << pos << "\n";
    1009            0 :         }
    1010              :     }
    1011            0 :     GLHelper::popMatrix();
    1012            0 : }
    1013              : 
    1014              : 
    1015              : // ------ inherited from GUIGlObject
    1016              : GUIGLObjectPopupMenu*
    1017            0 : GUILane::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
    1018            0 :     GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
    1019            0 :     buildPopupHeader(ret, app);
    1020            0 :     buildCenterPopupEntry(ret);
    1021              :     //
    1022            0 :     GUIDesigns::buildFXMenuCommand(ret, TL("Copy edge name to clipboard"), nullptr, ret, MID_COPY_EDGE_NAME);
    1023            0 :     buildNameCopyPopupEntry(ret);
    1024            0 :     buildSelectionPopupEntry(ret);
    1025              :     //
    1026            0 :     buildShowParamsPopupEntry(ret, false);
    1027            0 :     const PositionVector& baseShape = getShape(parent.getVisualisationSettings().secondaryShape);
    1028            0 :     const double pos = interpolateGeometryPosToLanePos(baseShape.nearest_offset_to_point25D(parent.getPositionInformation()));
    1029            0 :     const double height = baseShape.positionAtOffset(pos).z();
    1030            0 :     GUIDesigns::buildFXMenuCommand(ret, (TL("pos: ") + toString(pos) + " " + TL("height: ") + toString(height)).c_str(), nullptr, nullptr, 0);
    1031            0 :     if (getEdge().hasDistance()) {
    1032            0 :         GUIDesigns::buildFXMenuCommand(ret, ("distance: " + toString(getEdge().getDistanceAt(pos))).c_str(), nullptr, nullptr, 0);
    1033              :     }
    1034            0 :     new FXMenuSeparator(ret);
    1035            0 :     buildPositionCopyEntry(ret, app);
    1036            0 :     new FXMenuSeparator(ret);
    1037            0 :     if (myAmClosed) {
    1038            0 :         if (myPermissionChanges.empty()) {
    1039            0 :             GUIDesigns::buildFXMenuCommand(ret, TL("Reopen lane"), nullptr, &parent, MID_CLOSE_LANE);
    1040            0 :             GUIDesigns::buildFXMenuCommand(ret, TL("Reopen edge"), nullptr, &parent, MID_CLOSE_EDGE);
    1041              :         } else {
    1042            0 :             GUIDesigns::buildFXMenuCommand(ret, TL("Reopen lane (override rerouter)"), nullptr, &parent, MID_CLOSE_LANE);
    1043            0 :             GUIDesigns::buildFXMenuCommand(ret, TL("Reopen edge (override rerouter)"), nullptr, &parent, MID_CLOSE_EDGE);
    1044              :         }
    1045              :     } else {
    1046            0 :         GUIDesigns::buildFXMenuCommand(ret, TL("Close lane"), nullptr, &parent, MID_CLOSE_LANE);
    1047            0 :         GUIDesigns::buildFXMenuCommand(ret, TL("Close edge"), nullptr, &parent, MID_CLOSE_EDGE);
    1048              :     }
    1049            0 :     GUIDesigns::buildFXMenuCommand(ret, TL("Add rerouter"), nullptr, &parent, MID_ADD_REROUTER);
    1050            0 :     new FXMenuSeparator(ret);
    1051              :     // reachability menu
    1052            0 :     FXMenuPane* reachableByClass = new FXMenuPane(ret);
    1053            0 :     ret->insertMenuPaneChild(reachableByClass);
    1054            0 :     new FXMenuCascade(ret, TL("Select reachable"), GUIIconSubSys::getIcon(GUIIcon::FLAG), reachableByClass);
    1055            0 :     for (auto i : SumoVehicleClassStrings.getStrings()) {
    1056            0 :         GUIDesigns::buildFXMenuCommand(reachableByClass, i.c_str(), VClassIcons::getVClassIcon(SumoVehicleClassStrings.get(i)), &parent, MID_REACHABILITY);
    1057            0 :     }
    1058            0 :     return ret;
    1059              : }
    1060              : 
    1061              : 
    1062              : GUIParameterTableWindow*
    1063            0 : GUILane::getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& view) {
    1064            0 :     myCachedGUISettings = view.editVisualisationSettings();
    1065            0 :     GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
    1066              :     // add items
    1067            0 :     ret->mkItem(TL("allowed speed [m/s]"), false, getSpeedLimit());
    1068            0 :     const std::map<SUMOVehicleClass, double>* restrictions = MSNet::getInstance()->getRestrictions(myEdge->getEdgeType());
    1069            0 :     if (restrictions != nullptr) {
    1070            0 :         for (const auto& elem : *restrictions) {
    1071            0 :             ret->mkItem((std::string("   ") + TL("allowed speed [m/s]") + std::string(": ") + toString(elem.first)).c_str(), false, elem.second);
    1072              :         }
    1073              :     }
    1074            0 :     ret->mkItem(TL("length [m]"), false, myLength);
    1075            0 :     ret->mkItem(TL("width [m]"), false, myWidth);
    1076            0 :     ret->mkItem(TL("street name"), false, myEdge->getStreetName());
    1077            0 :     ret->mkItem(TL("stored travel time [s]"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
    1078            0 :     ret->mkItem(TL("loaded weight"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
    1079            0 :     ret->mkItem(TL("routing speed [m/s]"), true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
    1080            0 :     ret->mkItem(TL("lane friction coefficient [%]"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getFrictionCoefficient));
    1081            0 :     ret->mkItem(TL("time penalty [s]"), true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getTimePenalty));
    1082            0 :     ret->mkItem(TL("brutto occupancy [%]"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
    1083            0 :     ret->mkItem(TL("netto occupancy [%]"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
    1084            0 :     ret->mkItem(TL("pending insertions [#]"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getPendingEmits));
    1085            0 :     ret->mkItem(TL("edge type"), false, myEdge->getEdgeType());
    1086            0 :     ret->mkItem(TL("routing type"), false, myEdge->getRoutingType());
    1087            0 :     ret->mkItem(TL("type"), false, myLaneType);
    1088            0 :     ret->mkItem(TL("priority"), false, myEdge->getPriority());
    1089            0 :     ret->mkItem(TL("distance [km]"), false, myEdge->getDistance() / 1000);
    1090            0 :     ret->mkItem(TL("allowed vehicle class"), false, StringUtils::wrapText(getVehicleClassNames(myPermissions), 60));
    1091            0 :     ret->mkItem(TL("disallowed vehicle class"), false, StringUtils::wrapText(getVehicleClassNames(~myPermissions), 60));
    1092            0 :     ret->mkItem(TL("permission code"), false, myPermissions);
    1093            0 :     ret->mkItem(TL("color value"), true, new FunctionBinding<GUILane, double>(this, &GUILane::getColorValueForTracker));
    1094            0 :     if (myBidiLane != nullptr) {
    1095            0 :         ret->mkItem(TL("bidi-lane"), false, myBidiLane->getID());
    1096              :     }
    1097              :     // info for blocked departDriveWay
    1098            0 :     for (auto item : getParametersMap()) {
    1099            0 :         if (StringUtils::startsWith(item.first, "insertionBlocked:")) {
    1100            0 :             const MSDriveWay* dw = MSDriveWay::retrieveDepartDriveWay(myEdge, item.second);
    1101            0 :             if (dw != nullptr) {
    1102            0 :                 ret->mkItem(("blocking " + dw->getID()).c_str(), false, toString(MSRailSignal::getBlockingVehicles(dw)));
    1103            0 :                 ret->mkItem(("driveWays blocking " + dw->getID()).c_str(), false, toString(MSRailSignal::getBlockingDriveWays(dw)));
    1104              :             }
    1105              :         }
    1106              :     }
    1107              : 
    1108            0 :     for (const auto& kv : myEdge->getParametersMap()) {
    1109            0 :         ret->mkItem(("edgeParam:" + kv.first).c_str(), false, kv.second);
    1110              :     }
    1111            0 :     ret->checkFont(myEdge->getStreetName());
    1112            0 :     ret->closeBuilding();
    1113            0 :     return ret;
    1114              : }
    1115              : 
    1116              : 
    1117              : Boundary
    1118            0 : GUILane::getCenteringBoundary() const {
    1119            0 :     const PositionVector& shape = GUIGlobals::gSecondaryShape && myShape2.size() > 0 ? myShape2 : myShape;
    1120            0 :     Boundary b;
    1121            0 :     b.add(shape[0]);
    1122            0 :     b.add(shape[-1]);
    1123            0 :     b.grow(RENDERING_BUFFER);
    1124              :     // ensure that vehicles and persons on the side are drawn even if the edge
    1125              :     // is outside the view
    1126            0 :     return b;
    1127              : }
    1128              : 
    1129              : 
    1130              : const PositionVector&
    1131     98216056 : GUILane::getShape(bool secondary) const {
    1132     98216056 :     return secondary && myShape2.size() > 0 ? myShape2 : myShape;
    1133              : }
    1134              : 
    1135              : 
    1136              : const std::vector<double>&
    1137     18542388 : GUILane::getShapeRotations(bool secondary) const {
    1138     18542388 :     return secondary && myShapeRotations2.size() > 0 ? myShapeRotations2 : myShapeRotations;
    1139              : }
    1140              : 
    1141              : 
    1142              : const std::vector<double>&
    1143     18485929 : GUILane::getShapeLengths(bool secondary) const {
    1144     18485929 :     return secondary && myShapeLengths2.size() > 0 ? myShapeLengths2 : myShapeLengths;
    1145              : }
    1146              : 
    1147              : 
    1148              : std::vector<RGBColor>&
    1149     91982953 : GUILane::getShapeColors(bool secondary) const {
    1150     91982953 :     return secondary && myShapeColors2.size() > 0 ? myShapeColors2 : myShapeColors;
    1151              : }
    1152              : 
    1153              : 
    1154              : double
    1155            0 : GUILane::firstWaitingTime() const {
    1156            0 :     return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
    1157              : }
    1158              : 
    1159              : 
    1160              : double
    1161            0 : GUILane::getEdgeLaneNumber() const {
    1162            0 :     return (double) myEdge->getLanes().size();
    1163              : }
    1164              : 
    1165              : 
    1166              : double
    1167            0 : GUILane::getStoredEdgeTravelTime() const {
    1168            0 :     MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage();
    1169            0 :     if (!ews.knowsTravelTime(myEdge)) {
    1170              :         return -1;
    1171              :     } else {
    1172            0 :         double value(0);
    1173            0 :         ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
    1174            0 :         return value;
    1175              :     }
    1176              : }
    1177              : 
    1178              : 
    1179              : double
    1180            0 : GUILane::getLoadedEdgeWeight() const {
    1181            0 :     MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage();
    1182            0 :     if (!ews.knowsEffort(myEdge)) {
    1183              :         return -1;
    1184              :     } else {
    1185            0 :         double value(-1);
    1186            0 :         ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
    1187            0 :         return value;
    1188              :     }
    1189              : }
    1190              : 
    1191              : 
    1192              : double
    1193            0 : GUILane::getColorValueWithFunctional(const GUIVisualizationSettings& s, int activeScheme) const {
    1194            0 :     switch (activeScheme) {
    1195            0 :         case 18: {
    1196            0 :             return GeomHelper::naviDegree(getShape(s.secondaryShape).beginEndAngle()); // [0-360]
    1197              :         }
    1198            0 :         default:
    1199            0 :             return getColorValue(s, activeScheme);
    1200              :     }
    1201              : 
    1202              : }
    1203              : 
    1204              : 
    1205              : RGBColor
    1206     46410583 : GUILane::setColor(const GUIVisualizationSettings& s) const {
    1207              :     // setting and retrieving the color does not work in OSGView so we return it explicitliy
    1208     46410583 :     RGBColor col;
    1209     46410583 :     if (MSGlobals::gUseMesoSim && static_cast<const GUIEdge*>(myEdge)->getMesoColor() != MESO_USE_LANE_COLOR) {
    1210        47117 :         col = static_cast<const GUIEdge*>(myEdge)->getMesoColor();
    1211              :     } else {
    1212     46363466 :         const GUIColorer& c = s.laneColorer;
    1213     46363466 :         if (!setFunctionalColor(c, col) && !setMultiColor(s, c, col)) {
    1214     46246881 :             col = c.getScheme().getColor(getColorValue(s, c.getActive()));
    1215              :         }
    1216              :     }
    1217     46410583 :     GLHelper::setColor(col);
    1218     46410583 :     return col;
    1219              : }
    1220              : 
    1221              : 
    1222              : bool
    1223     52948330 : GUILane::setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme) const {
    1224     52948330 :     if (activeScheme < 0) {
    1225              :         activeScheme = c.getActive();
    1226              :     }
    1227     52948330 :     switch (activeScheme) {
    1228     52939034 :         case 0:
    1229     52939034 :             if (myEdge->isCrossing()) {
    1230              :                 // determine priority to decide color
    1231       163702 :                 const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
    1232       163702 :                 if (link->havePriority() || link->getTLLogic() != nullptr) {
    1233        55829 :                     col = RGBColor(230, 230, 230);
    1234              :                 } else {
    1235       107873 :                     col = RGBColor(26, 26, 26);
    1236              :                 }
    1237       163702 :                 GLHelper::setColor(col);
    1238       163702 :                 return true;
    1239              :             } else {
    1240              :                 return false;
    1241              :             }
    1242            0 :         case 18: {
    1243            0 :             double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
    1244            0 :             col = RGBColor::fromHSV(hue, 1., 1.);
    1245            0 :             GLHelper::setColor(col);
    1246            0 :             return true;
    1247              :         }
    1248              :         case 30: { // taz color
    1249            0 :             col = c.getScheme().getColor(0);
    1250              :             std::vector<RGBColor> tazColors;
    1251            0 :             for (MSEdge* e : myEdge->getPredecessors()) {
    1252            0 :                 if (e->isTazConnector() && e->hasParameter("tazColor")) {
    1253            0 :                     tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
    1254              :                 }
    1255              :             }
    1256            0 :             for (MSEdge* e : myEdge->getSuccessors()) {
    1257            0 :                 if (e->isTazConnector() && e->hasParameter("tazColor")) {
    1258            0 :                     tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
    1259              :                 }
    1260              :             }
    1261            0 :             if (tazColors.size() > 0) {
    1262            0 :                 int randColor = RandHelper::rand((int)tazColors.size(), RGBColor::getColorRNG());
    1263            0 :                 col = tazColors[randColor];
    1264              :             }
    1265            0 :             GLHelper::setColor(col);
    1266              :             return true;
    1267            0 :         }
    1268              :         default:
    1269              :             return false;
    1270              :     }
    1271              : }
    1272              : 
    1273              : 
    1274              : bool
    1275     46246881 : GUILane::setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const {
    1276              :     const int activeScheme = c.getActive();
    1277     46246881 :     auto& shapeColors = getShapeColors(s.secondaryShape);
    1278     46246881 :     const PositionVector& shape = getShape(s.secondaryShape);
    1279              :     shapeColors.clear();
    1280     46246881 :     switch (activeScheme) {
    1281            0 :         case 22: // color by height at segment start
    1282            0 :             for (PositionVector::const_iterator ii = shape.begin(); ii != shape.end() - 1; ++ii) {
    1283            0 :                 shapeColors.push_back(c.getScheme().getColor(ii->z()));
    1284              :             }
    1285              :             // osg fallback (edge height at start)
    1286            0 :             col = c.getScheme().getColor(getColorValue(s, 21));
    1287            0 :             return true;
    1288              :         case 24: // color by inclination  at segment start
    1289            0 :             for (int ii = 1; ii < (int)shape.size(); ++ii) {
    1290            0 :                 const double inc = (shape[ii].z() - shape[ii - 1].z()) / MAX2(POSITION_EPS, shape[ii].distanceTo2D(shape[ii - 1]));
    1291            0 :                 shapeColors.push_back(c.getScheme().getColor(inc));
    1292              :             }
    1293            0 :             col = c.getScheme().getColor(getColorValue(s, 23));
    1294            0 :             return true;
    1295              :         default:
    1296              :             return false;
    1297              :     }
    1298              : }
    1299              : 
    1300              : double
    1301            0 : GUILane::getColorValueForTracker() const {
    1302            0 :     if (myCachedGUISettings != nullptr) {
    1303              :         const GUIVisualizationSettings& s = *myCachedGUISettings;
    1304              :         const GUIColorer& c = s.laneColorer;
    1305            0 :         double val = getColorValueWithFunctional(s, c.getActive());
    1306            0 :         if (val == GUIVisualizationSettings::MISSING_DATA) {
    1307              :             // blowing up the dialog or plot isn't helpful. At least 0 may be understood as neutral
    1308              :             return 0;
    1309              :         } else {
    1310              :             return val;
    1311              :         }
    1312              :     } else {
    1313              :         return 0;
    1314              :     }
    1315              : }
    1316              : 
    1317              : 
    1318              : double
    1319     46246881 : GUILane::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
    1320     46246881 :     switch (activeScheme) {
    1321     46237585 :         case 0:
    1322     46237585 :             switch (myPermissions) {
    1323              :                 case SVC_PEDESTRIAN:
    1324              :                     return 1;
    1325              :                 case SVC_BICYCLE:
    1326              :                     return 2;
    1327       176272 :                 case 0:
    1328              :                     // forbidden road or green verge
    1329       176272 :                     return myEdge->getPermissions() == 0 ? 10 : 3;
    1330          602 :                 case SVC_SHIP:
    1331          602 :                     return 4;
    1332         2236 :                 case SVC_AUTHORITY:
    1333         2236 :                     return 8;
    1334            0 :                 case SVC_AIRCRAFT:
    1335              :                 case SVC_DRONE:
    1336            0 :                     return 11;
    1337              :                 default:
    1338              :                     break;
    1339              :             }
    1340     44427526 :             if (myEdge->isTazConnector()) {
    1341              :                 return 9;
    1342     44427526 :             } else if (isRailway(myPermissions)) {
    1343              :                 return 5;
    1344     44190172 :             } else if ((myPermissions & SVC_PASSENGER) != 0) {
    1345     44102464 :                 if ((myPermissions & (SVC_RAIL_CLASSES & ~SVC_RAIL_FAST)) != 0 && (myPermissions & SVC_SHIP) == 0) {
    1346              :                     return 6;
    1347              :                 } else {
    1348              :                     return 0;
    1349              :                 }
    1350              :             } else {
    1351        87708 :                 if ((myPermissions & SVC_RAIL_CLASSES) != 0 && (myPermissions & SVC_SHIP) == 0) {
    1352              :                     return 6;
    1353              :                 } else {
    1354        87487 :                     return 7;
    1355              :                 }
    1356              :             }
    1357         9296 :         case 1:
    1358         9296 :             return isLaneOrEdgeSelected();
    1359            0 :         case 2:
    1360            0 :             return (double)myPermissions;
    1361            0 :         case 3:
    1362            0 :             return getSpeedLimit();
    1363            0 :         case 4:
    1364            0 :             return getBruttoOccupancy();
    1365            0 :         case 5:
    1366            0 :             return getNettoOccupancy();
    1367            0 :         case 6:
    1368            0 :             return firstWaitingTime();
    1369            0 :         case 7:
    1370            0 :             return getEdgeLaneNumber();
    1371            0 :         case 8:
    1372            0 :             return getEmissions<PollutantsInterface::CO2>() / myLength;
    1373            0 :         case 9:
    1374            0 :             return getEmissions<PollutantsInterface::CO>() / myLength;
    1375            0 :         case 10:
    1376            0 :             return getEmissions<PollutantsInterface::PM_X>() / myLength;
    1377            0 :         case 11:
    1378            0 :             return getEmissions<PollutantsInterface::NO_X>() / myLength;
    1379            0 :         case 12:
    1380            0 :             return getEmissions<PollutantsInterface::HC>() / myLength;
    1381            0 :         case 13:
    1382            0 :             return getEmissions<PollutantsInterface::FUEL>() / myLength;
    1383            0 :         case 14:
    1384            0 :             return getHarmonoise_NoiseEmissions();
    1385            0 :         case 15: {
    1386            0 :             return getStoredEdgeTravelTime();
    1387              :         }
    1388            0 :         case 16: {
    1389            0 :             MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage();
    1390            0 :             if (!ews.knowsTravelTime(myEdge)) {
    1391              :                 return -1;
    1392              :             } else {
    1393            0 :                 double value(0);
    1394            0 :                 ews.retrieveExistingTravelTime(myEdge, 0, value);
    1395            0 :                 return 100 * myLength / value / getSpeedLimit();
    1396              :             }
    1397              :         }
    1398            0 :         case 17: {
    1399              :             // geometrical length has no meaning for walkingAreas since it describes the outer boundary
    1400            0 :             return myEdge->isWalkingArea() ? 1 :  1 / getLengthGeometryFactor(s.secondaryShape);
    1401              :         }
    1402            0 :         case 19: {
    1403            0 :             return getLoadedEdgeWeight();
    1404              :         }
    1405            0 :         case 20: {
    1406            0 :             return myEdge->getPriority();
    1407              :         }
    1408            0 :         case 21: {
    1409              :             // color by z of first shape point
    1410            0 :             return getShape(s.secondaryShape)[0].z();
    1411              :         }
    1412            0 :         case 23: {
    1413              :             // color by incline
    1414            0 :             return (getShape(s.secondaryShape)[-1].z() - getShape(s.secondaryShape)[0].z()) / getLength();
    1415              :         }
    1416            0 :         case 25: {
    1417              :             // color by average speed
    1418            0 :             return getMeanSpeed();
    1419              :         }
    1420            0 :         case 26: {
    1421              :             // color by average relative speed
    1422            0 :             return getMeanSpeed() / myMaxSpeed;
    1423              :         }
    1424            0 :         case 27: {
    1425              :             // color by routing device assumed speed
    1426            0 :             return myEdge->getRoutingSpeed();
    1427              :         }
    1428            0 :         case 28:
    1429            0 :             return getEmissions<PollutantsInterface::ELEC>() / myLength;
    1430            0 :         case 29:
    1431            0 :             return getPendingEmits();
    1432            0 :         case 31: {
    1433              :             // by numerical edge param value
    1434            0 :             if (myEdge->hasParameter(s.edgeParam)) {
    1435              :                 try {
    1436            0 :                     return StringUtils::toDouble(myEdge->getParameter(s.edgeParam, "0"));
    1437            0 :                 } catch (NumberFormatException&) {
    1438              :                     try {
    1439            0 :                         return StringUtils::toBool(myEdge->getParameter(s.edgeParam, "0"));
    1440            0 :                     } catch (BoolFormatException&) {
    1441            0 :                         return GUIVisualizationSettings::MISSING_DATA;
    1442            0 :                     }
    1443            0 :                 }
    1444              :             } else {
    1445            0 :                 return GUIVisualizationSettings::MISSING_DATA;
    1446              :             }
    1447              :         }
    1448            0 :         case 32: {
    1449              :             // by numerical lane param value
    1450            0 :             if (hasParameter(s.laneParam)) {
    1451              :                 try {
    1452            0 :                     return StringUtils::toDouble(getParameter(s.laneParam, "0"));
    1453            0 :                 } catch (NumberFormatException&) {
    1454              :                     try {
    1455            0 :                         return StringUtils::toBool(getParameter(s.laneParam, "0"));
    1456            0 :                     } catch (BoolFormatException&) {
    1457            0 :                         return GUIVisualizationSettings::MISSING_DATA;
    1458            0 :                     }
    1459            0 :                 }
    1460              :             } else {
    1461            0 :                 return GUIVisualizationSettings::MISSING_DATA;
    1462              :             }
    1463              :         }
    1464            0 :         case 33: {
    1465              :             // by edge data value
    1466            0 :             return GUINet::getGUIInstance()->getEdgeData(myEdge, s.edgeData);
    1467              :         }
    1468            0 :         case 34: {
    1469            0 :             return myEdge->getDistance();
    1470              :         }
    1471            0 :         case 35: {
    1472            0 :             return fabs(myEdge->getDistance());
    1473              :         }
    1474            0 :         case 36: {
    1475            0 :             return myReachability;
    1476              :         }
    1477            0 :         case 37: {
    1478            0 :             return myRNGIndex % MSGlobals::gNumSimThreads;
    1479              :         }
    1480            0 :         case 38: {
    1481            0 :             if (myParkingAreas == nullptr) {
    1482              :                 // init
    1483            0 :                 myParkingAreas = new std::vector<MSParkingArea*>();
    1484            0 :                 for (auto& item : MSNet::getInstance()->getStoppingPlaces(SUMO_TAG_PARKING_AREA)) {
    1485            0 :                     if (&item.second->getLane().getEdge() == myEdge) {
    1486            0 :                         myParkingAreas->push_back(dynamic_cast<MSParkingArea*>(item.second));
    1487              :                     }
    1488              :                 }
    1489              :             }
    1490              :             int capacity = 0;
    1491            0 :             for (MSParkingArea* pa : *myParkingAreas) {
    1492            0 :                 capacity += pa->getCapacity() - pa->getOccupancy();
    1493              :             }
    1494            0 :             return capacity;
    1495              :         }
    1496            0 :         case 39: {
    1497              :             // by live edge data value
    1498            0 :             return GUINet::getGUIInstance()->getMeanData(this, s.edgeDataID, s.edgeData);
    1499              :         }
    1500              :     }
    1501              :     return 0;
    1502              : }
    1503              : 
    1504              : 
    1505              : double
    1506     37187001 : GUILane::getScaleValue(const GUIVisualizationSettings& s, int activeScheme, bool s2) const {
    1507     37187001 :     switch (activeScheme) {
    1508              :         case 0:
    1509              :             return 0;
    1510            0 :         case 1:
    1511            0 :             return isLaneOrEdgeSelected();
    1512            0 :         case 2:
    1513            0 :             return getSpeedLimit();
    1514            0 :         case 3:
    1515            0 :             return getBruttoOccupancy();
    1516            0 :         case 4:
    1517            0 :             return getNettoOccupancy();
    1518            0 :         case 5:
    1519            0 :             return firstWaitingTime();
    1520            0 :         case 6:
    1521            0 :             return getEdgeLaneNumber();
    1522            0 :         case 7:
    1523            0 :             return getEmissions<PollutantsInterface::CO2>() / myLength;
    1524            0 :         case 8:
    1525            0 :             return getEmissions<PollutantsInterface::CO>() / myLength;
    1526            0 :         case 9:
    1527            0 :             return getEmissions<PollutantsInterface::PM_X>() / myLength;
    1528            0 :         case 10:
    1529            0 :             return getEmissions<PollutantsInterface::NO_X>() / myLength;
    1530            0 :         case 11:
    1531            0 :             return getEmissions<PollutantsInterface::HC>() / myLength;
    1532            0 :         case 12:
    1533            0 :             return getEmissions<PollutantsInterface::FUEL>() / myLength;
    1534            0 :         case 13:
    1535            0 :             return getHarmonoise_NoiseEmissions();
    1536            0 :         case 14: {
    1537            0 :             return getStoredEdgeTravelTime();
    1538              :         }
    1539            0 :         case 15: {
    1540            0 :             MSEdgeWeightsStorage& ews = MSNet::getInstance()->getWeightsStorage();
    1541            0 :             if (!ews.knowsTravelTime(myEdge)) {
    1542              :                 return -1;
    1543              :             } else {
    1544            0 :                 double value(0);
    1545            0 :                 ews.retrieveExistingTravelTime(myEdge, 0, value);
    1546            0 :                 return 100 * myLength / value / getSpeedLimit();
    1547              :             }
    1548              :         }
    1549            0 :         case 16: {
    1550            0 :             return 1 / getLengthGeometryFactor(s2);
    1551              :         }
    1552            0 :         case 17: {
    1553            0 :             return getLoadedEdgeWeight();
    1554              :         }
    1555            0 :         case 18: {
    1556            0 :             return myEdge->getPriority();
    1557              :         }
    1558            0 :         case 19: {
    1559              :             // scale by average speed
    1560            0 :             return getMeanSpeed();
    1561              :         }
    1562            0 :         case 20: {
    1563              :             // scale by average relative speed
    1564            0 :             return getMeanSpeed() / myMaxSpeed;
    1565              :         }
    1566            0 :         case 21:
    1567            0 :             return getEmissions<PollutantsInterface::ELEC>() / myLength;
    1568            0 :         case 22:
    1569            0 :             return MSNet::getInstance()->getInsertionControl().getPendingEmits(this);
    1570            0 :         case 23:
    1571              :             // by edge data value
    1572            0 :             return GUINet::getGUIInstance()->getEdgeData(myEdge, s.edgeDataScaling);
    1573              :     }
    1574              :     return 0;
    1575              : }
    1576              : 
    1577              : 
    1578              : bool
    1579     18459505 : GUILane::drawAsRailway(const GUIVisualizationSettings& s) const {
    1580     18459505 :     return isRailway(myPermissions) && ((myPermissions & SVC_BUS) == 0) && s.showRails;
    1581              : }
    1582              : 
    1583              : 
    1584              : bool
    1585       634184 : GUILane::drawAsWaterway(const GUIVisualizationSettings& s) const {
    1586       634184 :     return isWaterway(myPermissions) && s.showRails; // reusing the showRails setting
    1587              : }
    1588              : 
    1589              : 
    1590              : #ifdef HAVE_OSG
    1591              : void
    1592       190745 : GUILane::updateColor(const GUIVisualizationSettings& s) {
    1593       190745 :     if (myGeom == 0) {
    1594              :         // not drawn
    1595            0 :         return;
    1596              :     }
    1597       190745 :     const RGBColor col = setColor(s);
    1598       190745 :     osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
    1599       190745 :     (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
    1600       190745 :     myGeom->setColorArray(colors);
    1601              : }
    1602              : #endif
    1603              : 
    1604              : 
    1605              : void
    1606            0 : GUILane::closeTraffic(bool rebuildAllowed) {
    1607            0 :     MSGlobals::gCheckRoutes = false;
    1608            0 :     if (myAmClosed) {
    1609              :         myPermissionChanges.clear(); // reset rerouters
    1610            0 :         resetPermissions(CHANGE_PERMISSIONS_GUI);
    1611              :     } else {
    1612            0 :         setPermissions(SVC_AUTHORITY, CHANGE_PERMISSIONS_GUI);
    1613              :     }
    1614            0 :     myAmClosed = !myAmClosed;
    1615            0 :     if (rebuildAllowed) {
    1616            0 :         getEdge().rebuildAllowedLanes();
    1617              :     }
    1618            0 : }
    1619              : 
    1620              : 
    1621              : PositionVector
    1622       161695 : GUILane::splitAtSegments(const PositionVector& shape) {
    1623              :     assert(MSGlobals::gUseMesoSim);
    1624       161695 :     const MESegment::MesoEdgeType& edgeType = MSNet::getInstance()->getMesoType(getEdge().getEdgeType());
    1625       161695 :     int no = MELoop::numSegmentsFor(myLength, edgeType.edgeLength);
    1626       161695 :     const double slength = myLength / no;
    1627              :     PositionVector result = shape;
    1628              :     double offset = 0;
    1629       498776 :     for (int i = 0; i < no; ++i) {
    1630       337081 :         offset += slength;
    1631       337081 :         Position pos = shape.positionAtOffset(interpolateLanePosToGeometryPos(offset));
    1632       337081 :         int index = result.indexOfClosest(pos);
    1633       337081 :         if (pos.distanceTo(result[index]) > POSITION_EPS) {
    1634       175383 :             index = result.insertAtClosest(pos, false);
    1635              :         }
    1636       337081 :         if (i != no - 1) {
    1637       175386 :             mySegmentStartIndex.push_back(index);
    1638              :         }
    1639       843664 :         while ((int)myShapeSegments.size() < index) {
    1640       506583 :             myShapeSegments.push_back(i);
    1641              :         }
    1642              :         //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
    1643              :     }
    1644       326023 :     while (myShapeSegments.size() < result.size()) {
    1645       164328 :         myShapeSegments.push_back(no - 1);
    1646              :     }
    1647       161695 :     return result;
    1648            0 : }
    1649              : 
    1650              : bool
    1651     46214072 : GUILane::isSelected() const {
    1652     46214072 :     return gSelected.isSelected(GLO_LANE, getGlID());
    1653              : }
    1654              : 
    1655              : bool
    1656         9296 : GUILane::isLaneOrEdgeSelected() const {
    1657         9296 :     return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
    1658              : }
    1659              : 
    1660              : double
    1661            0 : GUILane::getPendingEmits() const {
    1662            0 :     return MSNet::getInstance()->getInsertionControl().getPendingEmits(this);
    1663              : }
    1664              : 
    1665              : double
    1666            0 : GUILane::getClickPriority() const {
    1667            0 :     if (MSGlobals::gUseMesoSim) {
    1668              :         // do not select lanes in meso mode
    1669            0 :         return INVALID_PRIORITY;
    1670              :     }
    1671            0 :     if (myEdge->isCrossing()) {
    1672            0 :         return GLO_CROSSING;
    1673              :     }
    1674              :     return GLO_LANE;
    1675              : }
    1676              : 
    1677              : 
    1678              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1