SUMO - Simulation of Urban MObility
GUILane.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Representation of a lane in the micro simulation (gui-version)
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <utility>
29 #include <utils/geom/GeomHelper.h>
30 #include <utils/geom/Position.h>
34 #include <utils/common/StdDefs.h>
35 #include <utils/geom/GeomHelper.h>
36 #include <utils/gui/div/GLHelper.h>
42 #include <microsim/MSGlobals.h>
43 #include <microsim/MSLane.h>
47 #include <microsim/MSNet.h>
50 #include <mesosim/MELoop.h>
51 #include <mesosim/MESegment.h>
52 #include "GUILane.h"
53 #include "GUIEdge.h"
54 #include "GUIVehicle.h"
55 #include "GUINet.h"
56 
57 #ifdef HAVE_OSG
58 #include <osg/Geometry>
59 #endif
60 
61 //#define GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
62 //#define GUILane_DEBUG_DRAW_VERTICES
63 //#define GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
64 
65 // ===========================================================================
66 // static member declaration
67 // ===========================================================================
68 const RGBColor GUILane::MESO_USE_LANE_COLOR(0, 0, 0, 0);
69 
70 
71 // ===========================================================================
72 // method definitions
73 // ===========================================================================
74 GUILane::GUILane(const std::string& id, double maxSpeed, double length,
75  MSEdge* const edge, int numericalID,
76  const PositionVector& shape, double width,
77  SVCPermissions permissions, int index, bool isRampAccel) :
78  MSLane(id, maxSpeed, length, edge, numericalID, shape, width, permissions, index, isRampAccel),
79  GUIGlObject(GLO_LANE, id),
80 #ifdef HAVE_OSG
81  myGeom(0),
82 #endif
83  myAmClosed(false) {
85  myShape = splitAtSegments(shape);
86  assert(fabs(myShape.length() - shape.length()) < POSITION_EPS);
87  assert(myShapeSegments.size() == myShape.size());
88  }
89  myShapeRotations.reserve(myShape.size() - 1);
90  myShapeLengths.reserve(myShape.size() - 1);
91  myShapeColors.reserve(myShape.size() - 1);
92  int e = (int) myShape.size() - 1;
93  for (int i = 0; i < e; ++i) {
94  const Position& f = myShape[i];
95  const Position& s = myShape[i + 1];
96  myShapeLengths.push_back(f.distanceTo2D(s));
97  myShapeRotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
98  }
99  //
100  myHalfLaneWidth = myWidth / 2.;
102 }
103 
104 
106  // just to quit cleanly on a failure
107  if (myLock.locked()) {
108  myLock.unlock();
109  }
110 }
111 
112 
113 // ------ Vehicle insertion ------
114 void
115 GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
116  const MSLane::VehCont::iterator& at,
117  MSMoveReminder::Notification notification) {
119  MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
120 }
121 
122 
123 // ------ Access to vehicles ------
124 const MSLane::VehCont&
126  myLock.lock();
127  return myVehicles;
128 }
129 
130 
131 void
133  myLock.unlock();
134 }
135 
136 
137 void
141 }
142 
143 void
147 }
148 
149 
150 bool
151 GUILane::executeMovements(SUMOTime t, std::vector<MSLane*>& into) {
153  return MSLane::executeMovements(t, into);
154 }
155 
156 
157 MSVehicle*
158 GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
160  return MSLane::removeVehicle(remVehicle, notification, notify);
161 }
162 
163 
164 void
167  return MSLane::removeParking(remVehicle);
168 }
169 
170 
171 void
175 }
176 
177 
178 bool
181  return MSLane::integrateNewVehicle(t);
182 }
183 
184 
185 void
186 GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
188  MSLane::detectCollisions(timestep, stage);
189 }
190 
191 
192 double
196 }
197 
198 
199 void
203 }
204 
205 
206 // ------ Drawing methods ------
207 void
209  int noLinks = (int)myLinks.size();
210  if (noLinks == 0) {
211  return;
212  }
213  // draw all links
214  if (getEdge().isCrossing()) {
215  // draw indices at the start and end of the crossing
217  PositionVector shape = getShape();
218  shape.extrapolate(0.5); // draw on top of the walking area
221  return;
222  }
223  // draw all links
224  double w = myWidth / (double) noLinks;
225  double x1 = myHalfLaneWidth;
226  const bool lefthand = MSNet::getInstance()->lefthand();
227  for (int i = noLinks; --i >= 0;) {
228  double x2 = x1 - (double)(w / 2.);
230  x1 -= w;
231  }
232 }
233 
234 
235 void
237  int noLinks = (int)myLinks.size();
238  if (noLinks == 0) {
239  return;
240  }
241  if (getEdge().isCrossing()) {
242  // draw indices at the start and end of the crossing
244  int linkNo = net.getLinkTLIndex(link);
245  // maybe the reverse link is controlled separately
246  int linkNo2 = net.getLinkTLIndex(myLinks.front());
247  // otherwise, use the same index as the forward link
248  if (linkNo2 < 0) {
249  linkNo2 = linkNo;
250  }
251  if (linkNo >= 0) {
252  PositionVector shape = getShape();
253  shape.extrapolate(0.5); // draw on top of the walking area
256  }
257  return;
258  }
259  // draw all links
260  double w = myWidth / (double) noLinks;
261  double x1 = myHalfLaneWidth;
262  const bool lefthand = MSNet::getInstance()->lefthand();
263  for (int i = noLinks; --i >= 0;) {
264  double x2 = x1 - (double)(w / 2.);
265  int linkNo = net.getLinkTLIndex(myLinks[lefthand ? noLinks - 1 - i : i]);
266  if (linkNo < 0) {
267  continue;
268  }
270  x1 -= w;
271  }
272 }
273 
274 
275 void
277  int noLinks = (int)myLinks.size();
278  if (noLinks == 0) {
279  drawLinkRule(s, net, nullptr, getShape(), 0, 0);
280  return;
281  }
282  if (getEdge().isCrossing()) {
283  // draw rules at the start and end of the crossing
285  MSLink* link2 = myLinks.front();
286  if (link2->getTLLogic() == nullptr) {
287  link2 = link;
288  }
289  PositionVector shape = getShape();
290  shape.extrapolate(0.5); // draw on top of the walking area
291  drawLinkRule(s, net, link2, shape, 0, myWidth);
292  drawLinkRule(s, net, link, shape.reverse(), 0, myWidth);
293  return;
294  }
295  // draw all links
296  double w = myWidth / (double) noLinks;
297  double x1 = 0;
298  const bool lefthand = MSNet::getInstance()->lefthand();
299  for (int i = 0; i < noLinks; ++i) {
300  double x2 = x1 + w;
301  drawLinkRule(s, net, myLinks[lefthand ? noLinks - 1 - i : i], getShape(), x1, x2);
302  x1 = x2;
303  }
304  // draw stopOffset for passenger cars
305  if (myStopOffsets.size() != 0 && (myStopOffsets.begin()->first & SVC_PASSENGER) != 0) {
306  const double stopOffsetPassenger = myStopOffsets.begin()->second;
307  const Position& end = myShape.back();
308  const Position& f = myShape[-2];
309  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
311  glPushMatrix();
312  glTranslated(end.x(), end.y(), 0);
313  glRotated(rot, 0, 0, 1);
314  glTranslated(0, stopOffsetPassenger, 0);
315  glBegin(GL_QUADS);
316  glVertex2d(-myHalfLaneWidth, 0.0);
317  glVertex2d(-myHalfLaneWidth, 0.2);
318  glVertex2d(myHalfLaneWidth, 0.2);
319  glVertex2d(myHalfLaneWidth, 0.0);
320  glEnd();
321  glPopMatrix();
322  }
323 }
324 
325 
326 void
327 GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const {
328  const Position& end = shape.back();
329  const Position& f = shape[-2];
330  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
331  if (link == nullptr) {
333  glPushMatrix();
334  glTranslated(end.x(), end.y(), 0);
335  glRotated(rot, 0, 0, 1);
336  glBegin(GL_QUADS);
337  glVertex2d(-myHalfLaneWidth, 0.0);
338  glVertex2d(-myHalfLaneWidth, 0.5);
339  glVertex2d(myHalfLaneWidth, 0.5);
340  glVertex2d(myHalfLaneWidth, 0.0);
341  glEnd();
342  glPopMatrix();
343  } else {
344  glPushMatrix();
345  glTranslated(end.x(), end.y(), 0);
346  glRotated(rot, 0, 0, 1);
347  // select glID
348  switch (link->getState()) {
351  case LINKSTATE_TL_RED:
357  glPushName(net.getLinkTLID(link));
358  break;
359  case LINKSTATE_MAJOR:
360  case LINKSTATE_MINOR:
361  case LINKSTATE_EQUAL:
362  default:
363  glPushName(getGlID());
364  break;
365  }
367  if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
368  // the white bar should be the default for most railway
369  // links and looks ugly so we do not draw it
370  glBegin(GL_QUADS);
371  glVertex2d(x1 - myHalfLaneWidth, 0.0);
372  glVertex2d(x1 - myHalfLaneWidth, 0.5);
373  glVertex2d(x2 - myHalfLaneWidth, 0.5);
374  glVertex2d(x2 - myHalfLaneWidth, 0.0);
375  glEnd();
376  }
377  glPopName();
378  glPopMatrix();
379  }
380 }
381 
382 void
384  if (myLinks.size() == 0) {
385  return;
386  }
387  // draw all links
388  const Position& end = getShape().back();
389  const Position& f = getShape()[-2];
390  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
391  glPushMatrix();
392  glColor3d(1, 1, 1);
393  glTranslated(end.x(), end.y(), 0);
394  glRotated(rot, 0, 0, 1);
396  glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
397  }
398  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
399  LinkDirection dir = (*i)->getDirection();
400  LinkState state = (*i)->getState();
401  if (state == LINKSTATE_DEADEND || dir == LINKDIR_NODIR) {
402  continue;
403  }
404  switch (dir) {
405  case LINKDIR_STRAIGHT:
406  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
407  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
408  break;
409  case LINKDIR_TURN:
410  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
411  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
412  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
413  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
414  break;
416  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
417  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
418  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
419  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
420  break;
421  case LINKDIR_LEFT:
422  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
423  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
424  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
425  break;
426  case LINKDIR_RIGHT:
427  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
428  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
429  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
430  break;
431  case LINKDIR_PARTLEFT:
432  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
433  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
434  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
435  break;
436  case LINKDIR_PARTRIGHT:
437  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
438  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
439  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
440  break;
441  default:
442  break;
443  }
444  }
445  glPopMatrix();
446 }
447 
448 
449 void
450 GUILane::drawLane2LaneConnections(double exaggeration) const {
451  Position centroid;
452  if (exaggeration > 1) {
453  centroid = myEdge->getToJunction()->getShape().getCentroid();
454  }
455  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
456  const MSLane* connected = (*i)->getLane();
457  if (connected == nullptr) {
458  continue;
459  }
461  glBegin(GL_LINES);
462  Position p1 = getShape()[-1];
463  Position p2 = connected->getShape()[0];
464  if (exaggeration > 1) {
465  p1 = centroid + ((p1 - centroid) * exaggeration);
466  p2 = centroid + ((p2 - centroid) * exaggeration);
467  }
468  glVertex2d(p1.x(), p1.y());
469  glVertex2d(p2.x(), p2.y());
470  glEnd();
471  GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
472  }
473 }
474 
475 
476 void
478  glPushMatrix();
479  glPushName(getGlID());
480  const bool isCrossing = myEdge->isCrossing();
481  const bool isWalkingArea = myEdge->isWalkingArea();
482  const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
483  bool mustDrawMarkings = false;
484  double exaggeration = s.laneWidthExaggeration;
486  GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
487  exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s.edgeScaler.getActive()));
488  } else {
490  }
491  const bool drawDetails = (s.scale * exaggeration > 5 || s.junctionSize.minSize == 0) && !s.drawForSelecting;
492  if (isCrossing || isWalkingArea) {
493  // draw internal lanes on top of junctions
494  glTranslated(0, 0, GLO_JUNCTION + 0.1);
495  } else if (isWaterway(myPermissions)) {
496  // draw waterways below normal roads
497  glTranslated(0, 0, getType() - 0.2);
498  } else {
499  glTranslated(0, 0, getType());
500  }
501  // set lane color
502  setColor(s);
504  myShapeColors.clear();
505  const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
506  if (segmentColors.size() > 0) {
507  // apply segment specific shape colors
508  //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
509  for (int ii = 0; ii < (int)myShape.size() - 1; ++ii) {
510  myShapeColors.push_back(segmentColors[myShapeSegments[ii]]);
511  }
512  }
513  }
514  // recognize full transparency and simply don't draw
515  GLfloat color[4];
516  glGetFloatv(GL_CURRENT_COLOR, color);
517  bool hiddenBidi = myEdge->getBidiEdge() != nullptr && myEdge->getNumericalID() > myEdge->getBidiEdge()->getNumericalID();
518  if (color[3] != 0 && s.scale * exaggeration > s.laneMinSize) {
519  // scale tls-controlled lane2lane-arrows along with their junction shapes
520  double junctionExaggeration = 1;
521  if (!isInternal
524  junctionExaggeration = MAX2(1.001, s.junctionSize.getExaggeration(s, this, 4));
525  }
526  // draw lane
527  // check whether it is not too small
528  if (s.scale * exaggeration < 1. && junctionExaggeration == 1 && s.junctionSize.minSize != 0) {
529  if (!isInternal) {
530  if (myShapeColors.size() > 0) {
532  } else {
534  }
535  }
536  glPopMatrix();
537  } else {
538  GUINet* net = (GUINet*) MSNet::getInstance();
539  if (hiddenBidi) {
540  // do not draw shape
541  } else if (drawAsRailway(s)) {
542  // draw as railway: assume standard gauge of 1435mm when lane width is not set
543  // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
544  // assume crosstie length of 181% gauge (2600mm for standard gauge)
545  const double width = myWidth;
546  const double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * exaggeration;
547  const double halfInnerFeetWidth = halfGauge - 0.039 * exaggeration;
548  const double halfRailWidth = halfInnerFeetWidth + 0.15 * exaggeration;
549  const double halfCrossTieWidth = halfGauge * 1.81;
550  if (myShapeColors.size() > 0) {
552  } else {
554  }
555  // Draw white on top with reduced width (the area between the two tracks)
556  glColor3d(1, 1, 1);
557  glTranslated(0, 0, .1);
559  setColor(s);
560  GLHelper::drawCrossTies(myShape, myShapeRotations, myShapeLengths, 0.26 * exaggeration, 0.6 * exaggeration, halfCrossTieWidth, s.drawForSelecting);
561  } else if (isCrossing) {
562  if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
563  glTranslated(0, 0, .2);
565  glTranslated(0, 0, -.2);
566  }
567  } else if (isWalkingArea) {
568  if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
569  glTranslated(0, 0, .2);
570  if (s.scale * exaggeration < 20.) {
572  } else {
574  }
575  glTranslated(0, 0, -.2);
576 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
578 #endif
579  }
580  } else {
581  // we draw the lanes with reduced width so that the lane markings below are visible
582  // (this avoids artifacts at geometry corners without having to
583  // compute lane-marking intersection points)
584  const double halfWidth = isInternal ? myQuarterLaneWidth : (myHalfLaneWidth - SUMO_const_laneMarkWidth / 2);
585  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
586  const int cornerDetail = drawDetails && !isInternal ? (int)(s.scale * exaggeration) : 0;
587  const double offset = halfWidth * MAX2(0., (exaggeration - 1));
588  if (myShapeColors.size() > 0) {
589  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myShapeColors, halfWidth * exaggeration, cornerDetail, offset);
590  } else {
591  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfWidth * exaggeration, cornerDetail, offset);
592  }
593  }
594 #ifdef GUILane_DEBUG_DRAW_VERTICES
596 #endif
597 #ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
600  }
601 #endif
602  glPopMatrix();
603  // draw details
604  if ((!isInternal || isCrossing || !s.drawJunctionShape) && (drawDetails || s.drawForSelecting || junctionExaggeration > 1)) {
605  glPushMatrix();
606  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
607  glTranslated(0, 0, .5);
608  if (drawDetails) {
609  if (s.showLaneDirection) {
610  if (drawAsRailway(s)) {
611  // improve visibility of superposed rail edges
612  GLHelper::setColor(setColor(s).changedBrightness(100));
613  } else {
614  glColor3d(0.3, 0.3, 0.3);
615  }
616  if (!isCrossing || s.drawCrossingsAndWalkingareas) {
617  drawDirectionIndicators(exaggeration);
618  }
619  }
620  if (!isInternal) {
621  if (MSGlobals::gLateralResolution > 0 && s.showSublanes && !hiddenBidi) {
622  // draw sublane-borders
623  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
624  for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
626  }
627  }
629  drawArrows();
630  }
631  glTranslated(0, 0, 1000);
632  if (s.drawLinkJunctionIndex.show) {
633  drawLinkNo(s);
634  }
635  if (s.drawLinkTLIndex.show) {
636  drawTLSLinkNo(s, *net);
637  }
638  glTranslated(0, 0, -1000);
639  }
640  glTranslated(0, 0, .1);
641  }
642  // make sure link rules are drawn so tls can be selected via right-click
643  if (s.showLinkRules && (drawDetails || s.drawForSelecting)) {
644  drawLinkRules(s, *net);
645  }
646  if ((drawDetails || junctionExaggeration > 1) && s.showLane2Lane) {
647  // draw from end of first to the begin of second but respect junction scaling
648  drawLane2LaneConnections(junctionExaggeration);
649  }
650  glPopMatrix();
651  }
652  }
653  if (mustDrawMarkings && drawDetails && s.laneShowBorders && !hiddenBidi) { // needs matrix reset
654  drawMarkings(s, exaggeration);
655  }
656  if (drawDetails && isInternal && s.showBikeMarkings && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi) {
658  }
659  } else {
660  glPopMatrix();
661  }
662  // draw vehicles
663  if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
664  // retrieve vehicles from lane; disallow simulation
665  const MSLane::VehCont& vehicles = getVehiclesSecure();
666  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
667  if ((*v)->getLane() == this) {
668  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
669  } // else: this is the shadow during a continuous lane change
670  }
671  // draw parking vehicles
672  for (std::set<const MSVehicle*>::const_iterator v = myParkingVehicles.begin(); v != myParkingVehicles.end(); ++v) {
673  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
674  }
675  // allow lane simulation
676  releaseVehicles();
677  }
678  glPopName();
679 }
680 
681 
682 void
683 GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale) const {
684  glPushMatrix();
685  glTranslated(0, 0, GLO_EDGE);
686  setColor(s);
687  // optionally draw inverse markings
688  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
689  double mw = (myHalfLaneWidth + SUMO_const_laneMarkWidth) * scale;
690  double mw2 = (myHalfLaneWidth - SUMO_const_laneMarkWidth) * scale;
691  if (MSNet::getInstance()->lefthand()) {
692  mw *= -1;
693  mw2 *= -1;
694  }
695  int e = (int) getShape().size() - 1;
696  for (int i = 0; i < e; ++i) {
697  glPushMatrix();
698  glTranslated(getShape()[i].x(), getShape()[i].y(), 2.1);
699  glRotated(myShapeRotations[i], 0, 0, 1);
700  for (double t = 0; t < myShapeLengths[i]; t += 6) {
701  const double length = MIN2((double)3, myShapeLengths[i] - t);
702  glBegin(GL_QUADS);
703  glVertex2d(-mw, -t);
704  glVertex2d(-mw, -t - length);
705  glVertex2d(-mw2, -t - length);
706  glVertex2d(-mw2, -t);
707  glEnd();
708  }
709  glPopMatrix();
710  }
711  }
712  // draw white boundings and white markings
713  glColor3d(1, 1, 1);
715  getShape(),
717  getShapeLengths(),
719  glPopMatrix();
720 }
721 
722 
723 void
725  // draw bike lane markings onto the intersection
726  glColor3d(1, 1, 1);
727  const int e = (int) getShape().size() - 1;
728  const double markWidth = 0.1;
729  const double mw = myHalfLaneWidth;
730  for (int i = 0; i < e; ++i) {
731  glPushMatrix();
732  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.4);
733  glRotated(myShapeRotations[i], 0, 0, 1);
734  for (double t = 0; t < myShapeLengths[i]; t += 0.5) {
735  // left and right marking
736  for (int side = -1; side <= 1; side += 2) {
737  glBegin(GL_QUADS);
738  glVertex2d(side * mw, -t);
739  glVertex2d(side * mw, -t - 0.35);
740  glVertex2d(side * (mw + markWidth), -t - 0.35);
741  glVertex2d(side * (mw + markWidth), -t);
742  glEnd();
743  }
744  }
745  glPopMatrix();
746  }
747 }
748 
749 void
750 GUILane::drawDirectionIndicators(double exaggeration) const {
751  glPushMatrix();
752  glTranslated(0, 0, GLO_EDGE);
753  int e = (int) getShape().size() - 1;
754  const double w = MAX2(POSITION_EPS, myWidth);
755  const double w2 = MAX2(POSITION_EPS, myHalfLaneWidth);
756  const double w4 = MAX2(POSITION_EPS, myQuarterLaneWidth);
757  for (int i = 0; i < e; ++i) {
758  glPushMatrix();
759  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
760  glRotated(myShapeRotations[i], 0, 0, 1);
761  for (double t = 0; t < myShapeLengths[i]; t += w) {
762  const double length = MIN2(w2, myShapeLengths[i] - t) * exaggeration;
763  glBegin(GL_TRIANGLES);
764  glVertex2d(0, -t - length);
765  glVertex2d(-w4 * exaggeration, -t);
766  glVertex2d(+w4 * exaggeration, -t);
767  glEnd();
768  }
769  glPopMatrix();
770  }
771  glPopMatrix();
772 }
773 
774 
775 void
777  glPushMatrix();
778  glColor3d(1.0, 0.3, 0.3);
779  const double orthoLength = 0.5;
780  const MSLink* link = getLinkCont().front();
781  const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
782  const std::vector<std::pair<double, double> >& lengthsBehind = link->getLengthsBehindCrossing();
783  if (foeLanes.size() == lengthsBehind.size()) {
784  for (int i = 0; i < (int)foeLanes.size(); ++i) {
785  const MSLane* l = foeLanes[i];
786  Position pos = l->geometryPositionAtOffset(l->getLength() - lengthsBehind[i].second);
787  PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
788  if (ortho.length() < orthoLength) {
789  ortho.extrapolate(orthoLength - ortho.length(), false, true);
790  }
791  GLHelper::drawLine(ortho);
792  //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - lengthsBehind[i].second << " pos=" << pos << "\n";
793  }
794  }
795  glPopMatrix();
796 }
797 
798 
799 // ------ inherited from GUIGlObject
802  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
803  buildPopupHeader(ret, app);
805  //
806  new FXMenuCommand(ret, "Copy edge name to clipboard", nullptr, ret, MID_COPY_EDGE_NAME);
809  //
810  buildShowParamsPopupEntry(ret, false);
813  new FXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), nullptr, nullptr, 0);
814  new FXMenuSeparator(ret);
815  buildPositionCopyEntry(ret, false);
816  new FXMenuSeparator(ret);
817  if (myAmClosed) {
818  if (myPermissionChanges.empty()) {
819  new FXMenuCommand(ret, "Reopen lane", nullptr, &parent, MID_CLOSE_LANE);
820  new FXMenuCommand(ret, "Reopen edge", nullptr, &parent, MID_CLOSE_EDGE);
821  } else {
822  new FXMenuCommand(ret, "Reopen lane (override rerouter)", nullptr, &parent, MID_CLOSE_LANE);
823  new FXMenuCommand(ret, "Reopen edge (override rerouter)", nullptr, &parent, MID_CLOSE_EDGE);
824  }
825  } else {
826  new FXMenuCommand(ret, "Close lane", nullptr, &parent, MID_CLOSE_LANE);
827  new FXMenuCommand(ret, "Close edge", nullptr, &parent, MID_CLOSE_EDGE);
828  }
829  new FXMenuCommand(ret, "Add rerouter", nullptr, &parent, MID_ADD_REROUTER);
830  return ret;
831 }
832 
833 
836  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 16 + (int)myEdge->getParametersMap().size());
837  // add items
838  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
839  ret->mkItem("length [m]", false, myLength);
840  ret->mkItem("width [m]", false, myWidth);
841  ret->mkItem("street name", false, myEdge->getStreetName());
842  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
843  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
844  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
845  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
846  ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
847  ret->mkItem("pending insertions [#]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getPendingEmits));
848  ret->mkItem("edge type", false, myEdge->getEdgeType());
849  ret->mkItem("priority", false, myEdge->getPriority());
850  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
851  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
852  ret->mkItem("permission code", false, myPermissions);
853  if (myEdge->getBidiEdge() != nullptr) {
854  ret->mkItem("bidi-edge", false, myEdge->getBidiEdge()->getID());
855  }
856  for (const auto& kv : myEdge->getParametersMap()) {
857  ret->mkItem(("edgeParam:" + kv.first).c_str(), false, kv.second);
858  }
859  ret->closeBuilding();
860  return ret;
861 }
862 
863 
864 Boundary
866  Boundary b;
867  b.add(myShape[0]);
868  b.add(myShape[-1]);
869  b.grow(10);
870  // ensure that vehicles and persons on the side are drawn even if the edge
871  // is outside the view
872  return b;
873 }
874 
875 
876 const PositionVector&
878  return myShape;
879 }
880 
881 
882 const std::vector<double>&
884  return myShapeRotations;
885 }
886 
887 
888 const std::vector<double>&
890  return myShapeLengths;
891 }
892 
893 
894 double
896  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
897 }
898 
899 
900 double
902  return (double) myEdge->getLanes().size();
903 }
904 
905 
906 double
909  if (!ews.knowsTravelTime(myEdge)) {
910  return -1;
911  } else {
912  double value(0);
913  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
914  return value;
915  }
916 }
917 
918 
919 double
922  if (!ews.knowsEffort(myEdge)) {
923  return -1;
924  } else {
925  double value(-1);
926  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
927  return value;
928  }
929 }
930 
931 
932 RGBColor
934  // setting and retrieving the color does not work in OSGView so we return it explicitliy
935  RGBColor col;
936  if (MSGlobals::gUseMesoSim && static_cast<const GUIEdge*>(myEdge)->getMesoColor() != MESO_USE_LANE_COLOR) {
937  col = static_cast<const GUIEdge*>(myEdge)->getMesoColor();
938  } else {
939  const GUIColorer& c = s.laneColorer;
940  if (!setFunctionalColor(c, col) && !setMultiColor(s, c, col)) {
941  col = c.getScheme().getColor(getColorValue(s, c.getActive()));
942  }
943  }
944  GLHelper::setColor(col);
945  return col;
946 }
947 
948 
949 bool
950 GUILane::setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme) const {
951  if (activeScheme < 0) {
952  activeScheme = c.getActive();
953  }
954  switch (activeScheme) {
955  case 0:
956  if (myEdge->isCrossing()) {
957  // determine priority to decide color
959  if (link->havePriority() || link->getTLLogic() != nullptr) {
960  col = RGBColor(230, 230, 230);
961  } else {
962  col = RGBColor(26, 26, 26);
963  }
964  GLHelper::setColor(col);
965  return true;
966  } else {
967  return false;
968  }
969  case 18: {
970  double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
971  col = RGBColor::fromHSV(hue, 1., 1.);
972  GLHelper::setColor(col);
973  return true;
974  }
975  case 30: { // taz color
976  col = c.getScheme().getColor(0);
977  std::vector<RGBColor> tazColors;
978  for (MSEdge* e: myEdge->getPredecessors()) {
979  if (e->isTazConnector() && e->knowsParameter("tazColor")) {
980  tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
981  }
982  }
983  for (MSEdge* e: myEdge->getSuccessors()) {
984  if (e->isTazConnector() && e->knowsParameter("tazColor")) {
985  tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
986  }
987  }
988  if (tazColors.size() > 0) {
989  int randColor = RandHelper::rand((int)tazColors.size(), RGBColor::getColorRNG());
990  col = tazColors[randColor];
991  }
992  GLHelper::setColor(col);
993  return true;
994  }
995  default:
996  return false;
997  }
998 }
999 
1000 
1001 bool
1003  const int activeScheme = c.getActive();
1004  myShapeColors.clear();
1005  switch (activeScheme) {
1006  case 22: // color by height at segment start
1007  for (PositionVector::const_iterator ii = myShape.begin(); ii != myShape.end() - 1; ++ii) {
1008  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
1009  }
1010  // osg fallback (edge height at start)
1011  col = c.getScheme().getColor(getColorValue(s, 21));
1012  return true;
1013  case 24: // color by inclination at segment start
1014  for (int ii = 1; ii < (int)myShape.size(); ++ii) {
1015  const double inc = (myShape[ii].z() - myShape[ii - 1].z()) / MAX2(POSITION_EPS, myShape[ii].distanceTo2D(myShape[ii - 1]));
1016  myShapeColors.push_back(c.getScheme().getColor(inc));
1017  }
1018  col = c.getScheme().getColor(getColorValue(s, 23));
1019  return true;
1020  default:
1021  return false;
1022  }
1023 }
1024 
1025 
1026 double
1027 GUILane::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
1028  switch (activeScheme) {
1029  case 0:
1030  switch (myPermissions) {
1031  case SVC_PEDESTRIAN:
1032  return 1;
1033  case SVC_BICYCLE:
1034  return 2;
1035  case 0:
1036  return 3;
1037  case SVC_SHIP:
1038  return 4;
1039  case SVC_AUTHORITY:
1040  return 7;
1041  default:
1042  break;
1043  }
1044  if (myEdge->isTazConnector()) {
1045  return 8;
1046  } else if (isRailway(myPermissions)) {
1047  return 5;
1048  } else if ((myPermissions & SVC_PASSENGER) != 0) {
1049  return 0;
1050  } else {
1051  return 6;
1052  }
1053  case 1:
1054  return isLaneOrEdgeSelected();
1055  case 2:
1056  return (double)myPermissions;
1057  case 3:
1058  return getSpeedLimit();
1059  case 4:
1060  return getBruttoOccupancy();
1061  case 5:
1062  return getNettoOccupancy();
1063  case 6:
1064  return firstWaitingTime();
1065  case 7:
1066  return getEdgeLaneNumber();
1067  case 8:
1068  return getCO2Emissions() / myLength;
1069  case 9:
1070  return getCOEmissions() / myLength;
1071  case 10:
1072  return getPMxEmissions() / myLength;
1073  case 11:
1074  return getNOxEmissions() / myLength;
1075  case 12:
1076  return getHCEmissions() / myLength;
1077  case 13:
1078  return getFuelConsumption() / myLength;
1079  case 14:
1081  case 15: {
1082  return getStoredEdgeTravelTime();
1083  }
1084  case 16: {
1086  if (!ews.knowsTravelTime(myEdge)) {
1087  return -1;
1088  } else {
1089  double value(0);
1090  ews.retrieveExistingTravelTime(myEdge, 0, value);
1091  return 100 * myLength / value / getSpeedLimit();
1092  }
1093  }
1094  case 17: {
1095  // geometrical length has no meaning for walkingAreas since it describes the outer boundary
1096  return myEdge->isWalkingArea() ? 1 : 1 / myLengthGeometryFactor;
1097  }
1098  case 19: {
1099  return getLoadedEdgeWeight();
1100  }
1101  case 20: {
1102  return myEdge->getPriority();
1103  }
1104  case 21: {
1105  // color by z of first shape point
1106  return getShape()[0].z();
1107  }
1108  case 23: {
1109  // color by incline
1110  return (getShape()[-1].z() - getShape()[0].z()) / getLength();
1111  }
1112  case 25: {
1113  // color by average speed
1114  return getMeanSpeed();
1115  }
1116  case 26: {
1117  // color by average relative speed
1118  return getMeanSpeed() / myMaxSpeed;
1119  }
1120  case 27: {
1121  // color by routing device assumed speed
1122  return myEdge->getRoutingSpeed();
1123  }
1124  case 28:
1126  case 29:
1127  return getPendingEmits();
1128  case 31: {
1129  // by numerical edge param value
1130  try {
1132  } catch (NumberFormatException&) {
1133  WRITE_WARNING("Edge parameter '" + myEdge->getParameter(s.edgeParam, "0") + "' key '" + s.edgeParam + "' is not a number for edge '" + myEdge->getID() + "'");
1134  return 0;
1135  }
1136  }
1137  case 32: {
1138  // by numerical lane param value
1139  try {
1141  } catch (NumberFormatException&) {
1142  WRITE_WARNING("Lane parameter '" + getParameter(s.laneParam, "0") + "' key '" + s.laneParam + "' is not a number for lane '" + getID() + "'");
1143  return 0;
1144  }
1145  }
1146  }
1147  return 0;
1148 }
1149 
1150 
1151 double
1152 GUILane::getScaleValue(int activeScheme) const {
1153  switch (activeScheme) {
1154  case 0:
1155  return 0;
1156  case 1:
1157  return isLaneOrEdgeSelected();
1158  case 2:
1159  return getSpeedLimit();
1160  case 3:
1161  return getBruttoOccupancy();
1162  case 4:
1163  return getNettoOccupancy();
1164  case 5:
1165  return firstWaitingTime();
1166  case 6:
1167  return getEdgeLaneNumber();
1168  case 7:
1169  return getCO2Emissions() / myLength;
1170  case 8:
1171  return getCOEmissions() / myLength;
1172  case 9:
1173  return getPMxEmissions() / myLength;
1174  case 10:
1175  return getNOxEmissions() / myLength;
1176  case 11:
1177  return getHCEmissions() / myLength;
1178  case 12:
1179  return getFuelConsumption() / myLength;
1180  case 13:
1182  case 14: {
1183  return getStoredEdgeTravelTime();
1184  }
1185  case 15: {
1187  if (!ews.knowsTravelTime(myEdge)) {
1188  return -1;
1189  } else {
1190  double value(0);
1191  ews.retrieveExistingTravelTime(myEdge, 0, value);
1192  return 100 * myLength / value / getSpeedLimit();
1193  }
1194  }
1195  case 16: {
1196  return 1 / myLengthGeometryFactor;
1197  }
1198  case 17: {
1199  return getLoadedEdgeWeight();
1200  }
1201  case 18: {
1202  return myEdge->getPriority();
1203  }
1204  case 19: {
1205  // scale by average speed
1206  return getMeanSpeed();
1207  }
1208  case 20: {
1209  // scale by average relative speed
1210  return getMeanSpeed() / myMaxSpeed;
1211  }
1212  case 21:
1214  case 22:
1216  }
1217  return 0;
1218 }
1219 
1220 
1221 bool
1224 }
1225 
1226 
1227 bool
1229  return isWaterway(myPermissions) && s.showRails && !s.drawForSelecting; // reusing the showRails setting
1230 }
1231 
1232 
1233 #ifdef HAVE_OSG
1234 void
1235 GUILane::updateColor(const GUIVisualizationSettings& s) {
1236  if (myGeom == 0) {
1237  // not drawn
1238  return;
1239  }
1240  const RGBColor col = setColor(s);
1241  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1242  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1243  myGeom->setColorArray(colors);
1244 }
1245 #endif
1246 
1247 
1248 void
1249 GUILane::closeTraffic(bool rebuildAllowed) {
1250  MSGlobals::gCheckRoutes = false;
1251  if (myAmClosed) {
1252  myPermissionChanges.clear(); // reset rerouters
1254  } else {
1256  }
1258  if (rebuildAllowed) {
1260  for (MSEdge* const pred : getEdge().getPredecessors()) {
1261  pred->rebuildAllowedTargets();
1262  }
1263  }
1264 }
1265 
1266 
1269  assert(MSGlobals::gUseMesoSim);
1270  int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1271  const double slength = myLength / no;
1272  PositionVector result = shape;
1273  double offset = 0;
1274  for (int i = 0; i < no; ++i) {
1275  offset += slength;
1276  Position pos = shape.positionAtOffset(offset);
1277  int index = result.indexOfClosest(pos);
1278  if (pos.distanceTo(result[index]) > POSITION_EPS) {
1279  index = result.insertAtClosest(pos);
1280  }
1281  while ((int)myShapeSegments.size() < index) {
1282  myShapeSegments.push_back(i);
1283  }
1284  //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1285  }
1286  while (myShapeSegments.size() < result.size()) {
1287  myShapeSegments.push_back(no - 1);
1288  }
1289  return result;
1290 }
1291 
1292 bool
1294  return gSelected.isSelected(GLO_LANE, getGlID());
1295 }
1296 
1297 bool
1299  return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1300 }
1301 
1302 double
1305 }
1306 
1307 
1308 /****************************************************************************/
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:332
GUIVisualizationSizeSettings junctionSize
The link is a partial left direction.
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2531
The link has green light, may pass.
std::string getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a &#39; &#39;.
static double gLateralResolution
Definition: MSGlobals.h:85
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:776
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1273
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2407
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:920
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:329
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1220
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:177
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2626
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:640
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
long long int SUMOTime
Definition: SUMOTime.h:36
double scale
information about a lane&#39;s width (temporary, used for a single view)
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:950
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void setJunctionApproaches(const SUMOTime t)
Definition: GUILane.cpp:144
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:274
is a pedestrian
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:178
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:200
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0) const
return orthogonal through p (extending this vector if necessary)
double z() const
Returns the z-position.
Definition: Position.h:67
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:276
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:2877
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1141
~GUILane()
Destructor.
Definition: GUILane.cpp:105
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:497
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1298
void drawArrows() const
Definition: GUILane.cpp:383
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1152
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:185
int indexOfClosest(const Position &p) const
index of the closest position to p
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2650
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
static void drawTextAtEnd(const std::string &text, const PositionVector &shape, double x, double size, RGBColor color)
draw text and the end of shape
Definition: GLHelper.cpp:683
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:299
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:244
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1249
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:352
double exaggeration
The size exaggeration (upscale)
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:84
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
GUIColorer laneColorer
The lane colorer.
The link has green light, has to brake.
Stores the information about how to visualize structures.
const MSEdgeVector & getPredecessors() const
Definition: MSEdge.h:338
vehicle is a bicycle
static void debugVertices(const PositionVector &shape, double size, double layer=256)
draw vertex numbers for the given shape (in a random color)
Definition: GLHelper.cpp:736
const double SUMO_const_laneWidth
Definition: StdDefs.h:51
double y() const
Returns the y-position.
Definition: Position.h:62
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition: GUILane.cpp:1268
int myIndex
The lane index.
Definition: MSLane.h:1207
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:61
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1804
bool showRails
Information whether rails shall be drawn.
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:236
The link is a 180 degree turn.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
Notification
Definition of a vehicle state.
bool setMultiColor(const GUIVisualizationSettings &s, const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GUILane.cpp:1002
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2045
double x() const
Returns the x-position.
Definition: Position.h:57
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1336
This is a dead end link.
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
T MAX2(T a, T b)
Definition: StdDefs.h:76
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2614
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:78
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:514
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:456
bool showLaneDirection
Whether to show direction indicators for lanes.
PositionVector reverse() const
reverse position vector
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:77
bool laneShowBorders
Information whether lane borders shall be drawn.
This is an uncontrolled, right-before-left link.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:865
#define RAD2DEG(x)
Definition: GeomHelper.h:39
const std::string & getID() const
Returns the id.
Definition: Named.h:78
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
bool showLinkRules
Information whether link rules (colored bars) shall be drawn.
A storage for edge travel times and efforts.
The link is controlled by a tls which is off, not blinking, may pass.
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:244
const MSJunction * getToJunction() const
Definition: MSEdge.h:347
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:883
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:255
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:530
bool integrateNewVehicle(SUMOTime t)
Definition: GUILane.cpp:179
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition: MSEdge.h:239
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:326
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1228
The link is a (hard) left direction.
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1204
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1253
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
GUILane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel)
Constructor.
Definition: GUILane.cpp:74
authorities vehicles
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:268
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:907
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
The link is a straight direction.
MSLinkCont myLinks
Definition: MSLane.h:1301
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1203
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:97
std::string edgeParam
key for coloring by edge parameter
bool isInternal() const
Definition: MSLane.cpp:1875
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
double firstWaitingTime() const
Definition: GUILane.cpp:895
A road/street connecting two junctions.
Definition: MSEdge.h:75
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:180
void rebuildAllowedLanes()
Definition: MSEdge.cpp:258
double myLength
Lane length [m].
Definition: MSLane.h:1256
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:537
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:165
bool executeMovements(SUMOTime t, std::vector< MSLane *> &into)
Definition: GUILane.cpp:151
double getEdgeLaneNumber() const
Definition: GUILane.cpp:901
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3483
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:835
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: GUILane.cpp:115
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:3471
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:208
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:258
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:573
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2590
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:349
static bool gCheckRoutes
Definition: MSGlobals.h:79
double minSize
The minimum size to draw this object.
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:484
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:234
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position ...
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
This is an uncontrolled, minor link, has to brake.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:138
virtual void setJunctionApproaches(const SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. ...
Definition: MSLane.cpp:1146
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:724
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition: GUILane.cpp:1303
bool showSublanes
Whether to show sublane boundaries.
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1293
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:57
double getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:506
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:781
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIVisualizationTextSettings drawLinkTLIndex
T MIN2(T a, T b)
Definition: StdDefs.h:70
The link is a (hard) right direction.
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:933
#define POSITION_EPS
Definition: config.h:172
const PositionVector & getShape() const
Definition: GUILane.cpp:877
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1593
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1027
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:125
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:158
int insertAtClosest(const Position &p)
inserts p between the two closest positions and returns the insertion index
const T getColor(const double value) const
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:270
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1222
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:230
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2034
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:225
double laneMinSize
The minimum visual lane width for drawing.
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2638
GUIScaler edgeScaler
The mesoscopic edge scaler.
The link is a partial right direction.
bool lefthand() const
return whether the network was built for lefthand traffic
Definition: MSNet.h:615
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:90
vehicle is a passenger car (a "normal" car)
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:262
std::map< SVCPermissions, double > myStopOffsets
Definition: MSLane.h:1264
is an arbitrary ship
void unlock()
release mutex lock
Definition: MFXMutex.cpp:87
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:172
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:981
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2662
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:683
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2602
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:327
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
double length() const
Returns the length.
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool isTazConnector() const
Definition: MSEdge.h:248
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
The link has yellow light, may pass.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:369
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:70
The link is controlled by a tls which is off and blinks, has to brake.
A mutex encapsulator which locks/unlocks the given mutex on construction/destruction, respectively.
Definition: AbstractMutex.h:59
static void drawCrossTies(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double length, double spacing, double halfWidth, bool drawForSelecting)
draw crossties for railroads or pedestrian crossings
Definition: GLHelper.cpp:696
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1267
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:450
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:889
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:186
The link has red light (must brake)
The popup menu of a globject.
an edge
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:478
This is an uncontrolled, major link, may pass.
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2674
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void lock()
lock mutex
Definition: MFXMutex.cpp:77
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:323
bool drawCrossingsAndWalkingareas
whether crosings and walkingareas shall be drawn
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:345
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
GUIGlID getGlID() const
Returns the numerical id of the object.
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:63
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:244
The link is a 180 degree turn (left-hand network)
bool showLane2Lane
Information whether lane-to-lane arrows shall be drawn.
void drawDirectionIndicators(double exaggeration) const
direction indicators for lanes
Definition: GUILane.cpp:750
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:436
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:234
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIVisualizationSizeSettings vehicleSize
bool drawJunctionShape
whether the shape of the junction should be drawn
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2574
FXbool locked()
check if mutex is locked
Definition: MFXMutex.h:63
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:193
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1319
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:477
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:132
The link has yellow light, has to brake anyway.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1975
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length) ...
Definition: MELoop.cpp:244
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:801
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:335
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
static std::mt19937 * getColorRNG()
Definition: RGBColor.h:106
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
GUIScaler laneScaler
The lane scaler.
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:338
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1270
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2546
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
GUISelectedStorage gSelected
A global holder of selected objects.
static bool gUseMesoSim
Definition: MSGlobals.h:91
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:132
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:200
A window containing a gl-object&#39;s parameter.
static const RGBColor & getLinkColor(const LinkState &ls)
map from LinkState to color constants
The link has red light (must brake) but indicates upcoming green.
GUIVisualizationTextSettings drawLinkJunctionIndex
const PositionVector & getShape() const
Returns this junction&#39;s shape.
Definition: MSJunction.h:90
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
const double myWidth
Lane width [m].
Definition: MSLane.h:1259
bool showBikeMarkings
Information whether bicycle lane marking shall be drawn.
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: MSLane.cpp:306
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
Definition: MSLane.cpp:1107
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:127
The link has no direction (is a dead end link)
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:793
a junction
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:579
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:54