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 // method definitions
72 // ===========================================================================
73 GUILane::GUILane(const std::string& id, double maxSpeed, double length,
74  MSEdge* const edge, int numericalID,
75  const PositionVector& shape, double width,
76  SVCPermissions permissions, int index, bool isRampAccel) :
77  MSLane(id, maxSpeed, length, edge, numericalID, shape, width, permissions, index, isRampAccel),
78  GUIGlObject(GLO_LANE, id),
79 #ifdef HAVE_OSG
80  myGeom(0),
81 #endif
82  myAmClosed(false) {
84  myShape = splitAtSegments(shape);
85  assert(fabs(myShape.length() - shape.length()) < POSITION_EPS);
86  assert(myShapeSegments.size() == myShape.size());
87  }
88  myShapeRotations.reserve(myShape.size() - 1);
89  myShapeLengths.reserve(myShape.size() - 1);
90  myShapeColors.reserve(myShape.size() - 1);
91  int e = (int) myShape.size() - 1;
92  for (int i = 0; i < e; ++i) {
93  const Position& f = myShape[i];
94  const Position& s = myShape[i + 1];
95  myShapeLengths.push_back(f.distanceTo2D(s));
96  myShapeRotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
97  }
98  //
99  myHalfLaneWidth = (double)(myWidth / 2.);
100  myQuarterLaneWidth = (double)(myWidth / 4.);
101 }
102 
103 
105  // just to quit cleanly on a failure
106  if (myLock.locked()) {
107  myLock.unlock();
108  }
109 }
110 
111 
112 // ------ Vehicle insertion ------
113 void
114 GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
115  const MSLane::VehCont::iterator& at,
116  MSMoveReminder::Notification notification) {
118  MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
119 }
120 
121 
122 // ------ Access to vehicles ------
123 const MSLane::VehCont&
125  myLock.lock();
126  return myVehicles;
127 }
128 
129 
130 void
132  myLock.unlock();
133 }
134 
135 
136 void
140 }
141 
142 
143 bool
144 GUILane::executeMovements(SUMOTime t, std::vector<MSLane*>& into) {
146  return MSLane::executeMovements(t, into);
147 }
148 
149 
150 MSVehicle*
151 GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
153  return MSLane::removeVehicle(remVehicle, notification, notify);
154 }
155 
156 
157 void
160  return MSLane::removeParking(remVehicle);
161 }
162 
163 
164 void
168 }
169 
170 
171 bool
174  return MSLane::integrateNewVehicle(t);
175 }
176 
177 
178 void
179 GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
181  MSLane::detectCollisions(timestep, stage);
182 }
183 
184 
185 double
189 }
190 
191 
192 void
196 }
197 
198 
199 // ------ Drawing methods ------
200 void
202  int noLinks = (int)myLinks.size();
203  if (noLinks == 0) {
204  return;
205  }
206  // draw all links
207  if (getEdge().isCrossing()) {
208  // draw indices at the start and end of the crossing
210  PositionVector shape = getShape();
211  shape.extrapolate(0.5); // draw on top of the walking area
214  return;
215  }
216  // draw all links
217  double w = myWidth / (double) noLinks;
218  double x1 = myHalfLaneWidth;
219  const bool lefthand = MSNet::getInstance()->lefthand();
220  for (int i = noLinks; --i >= 0;) {
221  double x2 = x1 - (double)(w / 2.);
223  x1 -= w;
224  }
225 }
226 
227 
228 void
230  int noLinks = (int)myLinks.size();
231  if (noLinks == 0) {
232  return;
233  }
234  if (getEdge().isCrossing()) {
235  // draw indices at the start and end of the crossing
237  int linkNo = net.getLinkTLIndex(link);
238  // maybe the reverse link is controlled separately
239  int linkNo2 = net.getLinkTLIndex(myLinks.front());
240  // otherwise, use the same index as the forward link
241  if (linkNo2 < 0) {
242  linkNo2 = linkNo;
243  }
244  if (linkNo >= 0) {
245  PositionVector shape = getShape();
246  shape.extrapolate(0.5); // draw on top of the walking area
249  }
250  return;
251  }
252  // draw all links
253  double w = myWidth / (double) noLinks;
254  double x1 = myHalfLaneWidth;
255  const bool lefthand = MSNet::getInstance()->lefthand();
256  for (int i = noLinks; --i >= 0;) {
257  double x2 = x1 - (double)(w / 2.);
258  int linkNo = net.getLinkTLIndex(myLinks[lefthand ? noLinks - 1 - i : i]);
259  if (linkNo < 0) {
260  continue;
261  }
263  x1 -= w;
264  }
265 }
266 
267 
268 void
270  int noLinks = (int)myLinks.size();
271  if (noLinks == 0) {
272  drawLinkRule(s, net, 0, getShape(), 0, 0);
273  return;
274  }
275  if (getEdge().isCrossing()) {
276  // draw rules at the start and end of the crossing
278  MSLink* link2 = myLinks.front();
279  if (link2->getTLLogic() == 0) {
280  link2 = link;
281  }
282  PositionVector shape = getShape();
283  shape.extrapolate(0.5); // draw on top of the walking area
284  drawLinkRule(s, net, link2, shape, 0, myWidth);
285  drawLinkRule(s, net, link, shape.reverse(), 0, myWidth);
286  return;
287  }
288  // draw all links
289  double w = myWidth / (double) noLinks;
290  double x1 = 0;
291  const bool lefthand = MSNet::getInstance()->lefthand();
292  for (int i = 0; i < noLinks; ++i) {
293  double x2 = x1 + w;
294  drawLinkRule(s, net, myLinks[lefthand ? noLinks - 1 - i : i], getShape(), x1, x2);
295  x1 = x2;
296  }
297 }
298 
299 
300 void
301 GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const {
302  const Position& end = shape.back();
303  const Position& f = shape[-2];
304  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
305  if (link == 0) {
307  glPushMatrix();
308  glTranslated(end.x(), end.y(), 0);
309  glRotated(rot, 0, 0, 1);
310  glBegin(GL_QUADS);
311  glVertex2d(-myHalfLaneWidth, 0.0);
312  glVertex2d(-myHalfLaneWidth, 0.5);
313  glVertex2d(myHalfLaneWidth, 0.5);
314  glVertex2d(myHalfLaneWidth, 0.0);
315  glEnd();
316  glPopMatrix();
317  } else {
318  glPushMatrix();
319  glTranslated(end.x(), end.y(), 0);
320  glRotated(rot, 0, 0, 1);
321  // select glID
322  switch (link->getState()) {
325  case LINKSTATE_TL_RED:
331  glPushName(net.getLinkTLID(link));
332  break;
333  case LINKSTATE_MAJOR:
334  case LINKSTATE_MINOR:
335  case LINKSTATE_EQUAL:
336  default:
337  glPushName(getGlID());
338  break;
339  }
341  if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
342  // the white bar should be the default for most railway
343  // links and looks ugly so we do not draw it
344  glBegin(GL_QUADS);
345  glVertex2d(x1 - myHalfLaneWidth, 0.0);
346  glVertex2d(x1 - myHalfLaneWidth, 0.5);
347  glVertex2d(x2 - myHalfLaneWidth, 0.5);
348  glVertex2d(x2 - myHalfLaneWidth, 0.0);
349  glEnd();
350  }
351  glPopName();
352  glPopMatrix();
353  }
354 }
355 
356 void
358  if (myLinks.size() == 0) {
359  return;
360  }
361  // draw all links
362  const Position& end = getShape().back();
363  const Position& f = getShape()[-2];
364  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
365  glPushMatrix();
366  glColor3d(1, 1, 1);
367  glTranslated(end.x(), end.y(), 0);
368  glRotated(rot, 0, 0, 1);
370  glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
371  }
372  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
373  LinkDirection dir = (*i)->getDirection();
374  LinkState state = (*i)->getState();
375  if (state == LINKSTATE_DEADEND || dir == LINKDIR_NODIR) {
376  continue;
377  }
378  switch (dir) {
379  case LINKDIR_STRAIGHT:
380  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
381  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
382  break;
383  case LINKDIR_TURN:
384  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
385  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
386  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
387  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
388  break;
390  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
391  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
392  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
393  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
394  break;
395  case LINKDIR_LEFT:
396  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
397  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
398  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
399  break;
400  case LINKDIR_RIGHT:
401  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
402  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
403  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
404  break;
405  case LINKDIR_PARTLEFT:
406  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
407  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
408  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
409  break;
410  case LINKDIR_PARTRIGHT:
411  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
412  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
413  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
414  break;
415  default:
416  break;
417  }
418  }
419  glPopMatrix();
420 }
421 
422 
423 void
424 GUILane::drawLane2LaneConnections(double exaggeration) const {
425  Position centroid;
426  if (exaggeration > 1) {
427  centroid = myEdge->getToJunction()->getShape().getCentroid();
428  }
429  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
430  const MSLane* connected = (*i)->getLane();
431  if (connected == 0) {
432  continue;
433  }
435  glBegin(GL_LINES);
436  Position p1 = getShape()[-1];
437  Position p2 = connected->getShape()[0];
438  if (exaggeration > 1) {
439  p1 = centroid + ((p1 - centroid) * exaggeration);
440  p2 = centroid + ((p2 - centroid) * exaggeration);
441  }
442  glVertex2d(p1.x(), p1.y());
443  glVertex2d(p2.x(), p2.y());
444  glEnd();
445  GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
446  }
447 }
448 
449 
450 void
452  glPushMatrix();
453  glPushName(getGlID());
454  const bool isCrossing = myEdge->isCrossing();
455  const bool isWalkingArea = myEdge->isWalkingArea();
456  const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
457  bool mustDrawMarkings = false;
458  double exaggeration = s.laneWidthExaggeration;
460  GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
461  exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s.edgeScaler.getActive()));
462  } else {
464  }
465  const bool drawDetails = s.scale * exaggeration > 5 && !s.drawForSelecting;
466  if (isCrossing || isWalkingArea) {
467  // draw internal lanes on top of junctions
468  glTranslated(0, 0, GLO_JUNCTION + 0.1);
469  } else if (isWaterway(myPermissions)) {
470  // draw waterways below normal roads
471  glTranslated(0, 0, getType() - 0.2);
472  } else {
473  glTranslated(0, 0, getType());
474  }
475  // set lane color
476  setColor(s);
478  myShapeColors.clear();
479  const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
480  if (segmentColors.size() > 0) {
481  // apply segment specific shape colors
482  //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
483  for (int ii = 0; ii < (int)myShape.size() - 1; ++ii) {
484  myShapeColors.push_back(segmentColors[myShapeSegments[ii]]);
485  }
486  }
487  }
488  // recognize full transparency and simply don't draw
489  GLfloat color[4];
490  glGetFloatv(GL_CURRENT_COLOR, color);
491  if (color[3] != 0 && s.scale * exaggeration > s.laneMinSize &&
492  // only show one edge for a pair of superposed rail edges
493  (myEdge->getBidiEdge() == 0
494  || s.showLaneDirection
496  // scale tls-controlled lane2lane-arrows along with their junction shapes
497  double junctionExaggeration = 1;
498  if (!isInternal
501  junctionExaggeration = MAX2(1.001, s.junctionSize.getExaggeration(s, 4));
502  }
503  // draw lane
504  // check whether it is not too small
505  if (s.scale * exaggeration < 1. && junctionExaggeration == 1) {
506  if (!isInternal) {
507  if (myShapeColors.size() > 0) {
509  } else {
511  }
512  }
513  glPopMatrix();
514  } else {
515  GUINet* net = (GUINet*) MSNet::getInstance();
516  if (drawAsRailway(s)) {
517  // draw as railway: assume standard gauge of 1435mm when lane width is not set
518  // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
519  // assume crosstie length of 181% gauge (2600mm for standard gauge)
520  const double width = myWidth;
521  const double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * exaggeration;
522  const double halfInnerFeetWidth = halfGauge - 0.039 * exaggeration;
523  const double halfRailWidth = halfInnerFeetWidth + 0.15 * exaggeration;
524  const double halfCrossTieWidth = halfGauge * 1.81;
525  if (myShapeColors.size() > 0) {
527  } else {
529  }
530  // Draw white on top with reduced width (the area between the two tracks)
531  glColor3d(1, 1, 1);
532  glTranslated(0, 0, .1);
534  setColor(s);
535  GLHelper::drawCrossTies(myShape, myShapeRotations, myShapeLengths, 0.26 * exaggeration, 0.6 * exaggeration, halfCrossTieWidth, s.drawForSelecting);
536  } else if (isCrossing) {
537  if (s.drawCrossingsAndWalkingareas && s.scale > 3.0) {
538  glTranslated(0, 0, .2);
540  glTranslated(0, 0, -.2);
541  }
542  } else if (isWalkingArea) {
543  if (s.drawCrossingsAndWalkingareas && s.scale > 3.0) {
544  glTranslated(0, 0, .2);
545  if (s.scale * exaggeration < 20.) {
547  } else {
549  }
550  glTranslated(0, 0, -.2);
551 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
553 #endif
554  }
555  } else {
556  // we draw the lanes with reduced width so that the lane markings below are visible
557  // (this avoids artifacts at geometry corners without having to
558  // compute lane-marking intersection points)
559  const double halfWidth = isInternal ? myQuarterLaneWidth : (myHalfLaneWidth - SUMO_const_laneMarkWidth / 2);
560  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
561  const int cornerDetail = drawDetails && !isInternal ? (int)(s.scale * exaggeration) : 0;
562  const double offset = halfWidth * MAX2(0., (exaggeration - 1));
563  if (myShapeColors.size() > 0) {
564  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myShapeColors, halfWidth * exaggeration, cornerDetail, offset);
565  } else {
566  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfWidth * exaggeration, cornerDetail, offset);
567  }
568  }
569 #ifdef GUILane_DEBUG_DRAW_VERTICES
571 #endif
572 #ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
575  }
576 #endif
577  glPopMatrix();
578  // draw details
579  if ((!isInternal || isCrossing) && (drawDetails || s.drawForSelecting || junctionExaggeration > 1)) {
580  glPushMatrix();
581  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
582  glTranslated(0, 0, .5);
583  if (drawDetails) {
585  // draw sublane-borders
586  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
587  for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
589  }
590  }
592  drawArrows();
593  }
594  if (s.showLaneDirection) {
595  if (drawAsRailway(s)) {
596  // improve visibility of superposed rail edges
597  setColor(s);
598  } else {
599  glColor3d(0.3, 0.3, 0.3);
600  }
601  if (!isCrossing || s.drawCrossingsAndWalkingareas) {
602  drawDirectionIndicators(exaggeration);
603  }
604  }
605  glTranslated(0, 0, .1);
606  if (s.drawLinkJunctionIndex.show) {
607  drawLinkNo(s);
608  }
609  if (s.drawLinkTLIndex.show) {
610  drawTLSLinkNo(s, *net);
611  }
612  }
613  // make sure link rules are drawn so tls can be selected via right-click
614  if (s.showLinkRules && (drawDetails || s.drawForSelecting)) {
615  drawLinkRules(s, *net);
616  }
617  if ((drawDetails || junctionExaggeration > 1) && s.showLane2Lane) {
618  // draw from end of first to the begin of second but respect junction scaling
619  drawLane2LaneConnections(junctionExaggeration);
620  }
621  glPopMatrix();
622  }
623  }
624  if (mustDrawMarkings && drawDetails && s.laneShowBorders) { // needs matrix reset
625  drawMarkings(s, exaggeration);
626  }
627  if (drawDetails && isInternal && s.showBikeMarkings && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders) {
629  }
630  } else {
631  glPopMatrix();
632  }
633  // draw vehicles
635  // retrieve vehicles from lane; disallow simulation
636  const MSLane::VehCont& vehicles = getVehiclesSecure();
637  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
638  if ((*v)->getLane() == this) {
639  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
640  } // else: this is the shadow during a continuous lane change
641  }
642  // draw parking vehicles
643  for (std::set<const MSVehicle*>::const_iterator v = myParkingVehicles.begin(); v != myParkingVehicles.end(); ++v) {
644  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
645  }
646  // allow lane simulation
647  releaseVehicles();
648  }
649  glPopName();
650 }
651 
652 
653 void
654 GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale) const {
655  glPushMatrix();
656  glTranslated(0, 0, GLO_EDGE);
657  setColor(s);
658  // optionally draw inverse markings
659  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
660  double mw = (myHalfLaneWidth + SUMO_const_laneMarkWidth) * scale;
661  double mw2 = (myHalfLaneWidth - SUMO_const_laneMarkWidth) * scale;
662  if (MSNet::getInstance()->lefthand()) {
663  mw *= -1;
664  mw2 *= -1;
665  }
666  int e = (int) getShape().size() - 1;
667  for (int i = 0; i < e; ++i) {
668  glPushMatrix();
669  glTranslated(getShape()[i].x(), getShape()[i].y(), 2.1);
670  glRotated(myShapeRotations[i], 0, 0, 1);
671  for (double t = 0; t < myShapeLengths[i]; t += 6) {
672  const double length = MIN2((double)3, myShapeLengths[i] - t);
673  glBegin(GL_QUADS);
674  glVertex2d(-mw, -t);
675  glVertex2d(-mw, -t - length);
676  glVertex2d(-mw2, -t - length);
677  glVertex2d(-mw2, -t);
678  glEnd();
679  }
680  glPopMatrix();
681  }
682  }
683  // draw white boundings and white markings
684  glColor3d(1, 1, 1);
686  getShape(),
688  getShapeLengths(),
690  glPopMatrix();
691 }
692 
693 
694 void
696  // draw bike lane markings onto the intersection
697  glColor3d(1, 1, 1);
698  const int e = (int) getShape().size() - 1;
699  const double markWidth = 0.1;
700  const double mw = myHalfLaneWidth;
701  for (int i = 0; i < e; ++i) {
702  glPushMatrix();
703  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.4);
704  glRotated(myShapeRotations[i], 0, 0, 1);
705  for (double t = 0; t < myShapeLengths[i]; t += 0.5) {
706  // left and right marking
707  for (int side = -1; side <= 1; side += 2) {
708  glBegin(GL_QUADS);
709  glVertex2d(side * mw, -t);
710  glVertex2d(side * mw, -t - 0.35);
711  glVertex2d(side * (mw + markWidth), -t - 0.35);
712  glVertex2d(side * (mw + markWidth), -t);
713  glEnd();
714  }
715  }
716  glPopMatrix();
717  }
718 }
719 
720 void
721 GUILane::drawDirectionIndicators(double exaggeration) const {
722  glPushMatrix();
723  glTranslated(0, 0, GLO_EDGE);
724  int e = (int) getShape().size() - 1;
725  const double w = MAX2(POSITION_EPS, myWidth);
726  const double w2 = MAX2(POSITION_EPS, myHalfLaneWidth);
727  const double w4 = MAX2(POSITION_EPS, myQuarterLaneWidth);
728  for (int i = 0; i < e; ++i) {
729  glPushMatrix();
730  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
731  glRotated(myShapeRotations[i], 0, 0, 1);
732  for (double t = 0; t < myShapeLengths[i]; t += w) {
733  const double length = MIN2(w2, myShapeLengths[i] - t) * exaggeration;
734  glBegin(GL_TRIANGLES);
735  glVertex2d(0, -t - length);
736  glVertex2d(-w4 * exaggeration, -t);
737  glVertex2d(+w4 * exaggeration, -t);
738  glEnd();
739  }
740  glPopMatrix();
741  }
742  glPopMatrix();
743 }
744 
745 
746 void
748  glPushMatrix();
749  glColor3d(1.0, 0.3, 0.3);
750  const double orthoLength = 0.5;
751  const MSLink* link = getLinkCont().front();
752  const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
753  const std::vector<std::pair<double, double> >& lengthsBehind = link->getLengthsBehindCrossing();
754  if (foeLanes.size() == lengthsBehind.size()) {
755  for (int i = 0; i < (int)foeLanes.size(); ++i) {
756  const MSLane* l = foeLanes[i];
757  Position pos = l->geometryPositionAtOffset(l->getLength() - lengthsBehind[i].second);
758  PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
759  if (ortho.length() < orthoLength) {
760  ortho.extrapolate(orthoLength - ortho.length(), false, true);
761  }
762  GLHelper::drawLine(ortho);
763  //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - lengthsBehind[i].second << " pos=" << pos << "\n";
764  }
765  }
766  glPopMatrix();
767 }
768 
769 
770 // ------ inherited from GUIGlObject
773  GUISUMOAbstractView& parent) {
774  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
775  buildPopupHeader(ret, app);
777  //
778  new FXMenuCommand(ret, "Copy edge name to clipboard", 0, ret, MID_COPY_EDGE_NAME);
781  //
782  buildShowParamsPopupEntry(ret, false);
785  new FXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), 0, 0, 0);
786  new FXMenuSeparator(ret);
787  buildPositionCopyEntry(ret, false);
788  new FXMenuSeparator(ret);
789  if (myAmClosed) {
790  if (myPermissionChanges.empty()) {
791  new FXMenuCommand(ret, "Reopen lane", 0, &parent, MID_CLOSE_LANE);
792  new FXMenuCommand(ret, "Reopen edge", 0, &parent, MID_CLOSE_EDGE);
793  } else {
794  new FXMenuCommand(ret, "Reopen lane (override rerouter)", 0, &parent, MID_CLOSE_LANE);
795  new FXMenuCommand(ret, "Reopen edge (override rerouter)", 0, &parent, MID_CLOSE_EDGE);
796  }
797  } else {
798  new FXMenuCommand(ret, "Close lane", 0, &parent, MID_CLOSE_LANE);
799  new FXMenuCommand(ret, "Close edge", 0, &parent, MID_CLOSE_EDGE);
800  }
801  new FXMenuCommand(ret, "Add rerouter", 0, &parent, MID_ADD_REROUTER);
802  return ret;
803 }
804 
805 
809  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 15);
810  // add items
811  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
812  ret->mkItem("length [m]", false, myLength);
813  ret->mkItem("width [m]", false, myWidth);
814  ret->mkItem("street name", false, myEdge->getStreetName());
815  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
816  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
817  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
818  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
819  ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
820  ret->mkItem("pending insertions [#]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getPendingEmits));
821  ret->mkItem("edge type", false, myEdge->getEdgeType());
822  ret->mkItem("priority", false, myEdge->getPriority());
823  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
824  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
825  ret->mkItem("permission code", false, myPermissions);
826  // close building
827  ret->closeBuilding();
828  return ret;
829 }
830 
831 
832 Boundary
834  Boundary b;
835  b.add(myShape[0]);
836  b.add(myShape[-1]);
837  b.grow(10);
838  // ensure that vehicles and persons on the side are drawn even if the edge
839  // is outside the view
840  return b;
841 }
842 
843 
844 
845 
846 
847 
848 
849 const PositionVector&
851  return myShape;
852 }
853 
854 
855 const std::vector<double>&
857  return myShapeRotations;
858 }
859 
860 
861 const std::vector<double>&
863  return myShapeLengths;
864 }
865 
866 
867 double
869  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
870 }
871 
872 
873 double
875  return (double) myEdge->getLanes().size();
876 }
877 
878 
879 double
882  if (!ews.knowsTravelTime(myEdge)) {
883  return -1;
884  } else {
885  double value(0);
886  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
887  return value;
888  }
889 }
890 
891 
892 double
895  if (!ews.knowsEffort(myEdge)) {
896  return -1;
897  } else {
898  double value(-1);
899  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
900  return value;
901  }
902 }
903 
904 
905 RGBColor
907  // setting and retrieving the color does not work in OSGView so we return it explicitliy
908  RGBColor col;
909  if (MSGlobals::gUseMesoSim && static_cast<const GUIEdge*>(myEdge)->getMesoColor() != MESO_USE_LANE_COLOR) {
910  col = static_cast<const GUIEdge*>(myEdge)->getMesoColor();
911  } else {
912  const GUIColorer& c = s.laneColorer;
913  if (!setFunctionalColor(c.getActive(), col) && !setMultiColor(c, col)) {
914  col = c.getScheme().getColor(getColorValue(c.getActive()));
915  }
916  }
917  GLHelper::setColor(col);
918  return col;
919 }
920 
921 
922 bool
923 GUILane::setFunctionalColor(int activeScheme, RGBColor& col) const {
924  switch (activeScheme) {
925  case 0:
926  if (myEdge->isCrossing()) {
927  // determine priority to decide color
929  if (link->havePriority() || link->getTLLogic() != 0) {
930  col = RGBColor(230, 230, 230);
931  } else {
932  col = RGBColor(26, 26, 26);
933  }
934  GLHelper::setColor(col);
935  return true;
936  } else {
937  return false;
938  }
939  case 18: {
940  double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
941  col = RGBColor::fromHSV(hue, 1., 1.);
942  GLHelper::setColor(col);
943  return true;
944  }
945  default:
946  return false;
947  }
948 }
949 
950 
951 bool
953  const int activeScheme = c.getActive();
954  myShapeColors.clear();
955  switch (activeScheme) {
956  case 22: // color by height at segment start
957  for (PositionVector::const_iterator ii = myShape.begin(); ii != myShape.end() - 1; ++ii) {
958  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
959  }
960  // osg fallback (edge height at start)
961  col = c.getScheme().getColor(getColorValue(21));
962  return true;
963  case 24: // color by inclination at segment start
964  for (int ii = 1; ii < (int)myShape.size(); ++ii) {
965  const double inc = (myShape[ii].z() - myShape[ii - 1].z()) / MAX2(POSITION_EPS, myShape[ii].distanceTo2D(myShape[ii - 1]));
966  myShapeColors.push_back(c.getScheme().getColor(inc));
967  }
968  col = c.getScheme().getColor(getColorValue(23));
969  return true;
970  default:
971  return false;
972  }
973 }
974 
975 
976 double
977 GUILane::getColorValue(int activeScheme) const {
978  switch (activeScheme) {
979  case 0:
980  switch (myPermissions) {
981  case SVC_PEDESTRIAN:
982  return 1;
983  case SVC_BICYCLE:
984  return 2;
985  case 0:
986  return 3;
987  case SVC_SHIP:
988  return 4;
989  case SVC_AUTHORITY:
990  return 7;
991  default:
992  break;
993  }
994  if (myEdge->isTazConnector()) {
995  return 8;
996  } else if (isRailway(myPermissions)) {
997  return 5;
998  } else if ((myPermissions & SVC_PASSENGER) != 0) {
999  return 0;
1000  } else {
1001  return 6;
1002  }
1003  case 1:
1004  return isLaneOrEdgeSelected();
1005  case 2:
1006  return (double)myPermissions;
1007  case 3:
1008  return getSpeedLimit();
1009  case 4:
1010  return getBruttoOccupancy();
1011  case 5:
1012  return getNettoOccupancy();
1013  case 6:
1014  return firstWaitingTime();
1015  case 7:
1016  return getEdgeLaneNumber();
1017  case 8:
1018  return getCO2Emissions() / myLength;
1019  case 9:
1020  return getCOEmissions() / myLength;
1021  case 10:
1022  return getPMxEmissions() / myLength;
1023  case 11:
1024  return getNOxEmissions() / myLength;
1025  case 12:
1026  return getHCEmissions() / myLength;
1027  case 13:
1028  return getFuelConsumption() / myLength;
1029  case 14:
1031  case 15: {
1032  return getStoredEdgeTravelTime();
1033  }
1034  case 16: {
1036  if (!ews.knowsTravelTime(myEdge)) {
1037  return -1;
1038  } else {
1039  double value(0);
1040  ews.retrieveExistingTravelTime(myEdge, 0, value);
1041  return 100 * myLength / value / getSpeedLimit();
1042  }
1043  }
1044  case 17: {
1045  // geometrical length has no meaning for walkingAreas since it describes the outer boundary
1046  return myEdge->isWalkingArea() ? 1 : 1 / myLengthGeometryFactor;
1047  }
1048  case 19: {
1049  return getLoadedEdgeWeight();
1050  }
1051  case 20: {
1052  return myEdge->getPriority();
1053  }
1054  case 21: {
1055  // color by z of first shape point
1056  return getShape()[0].z();
1057  }
1058  case 23: {
1059  // color by incline
1060  return (getShape()[-1].z() - getShape()[0].z()) / getLength();
1061  }
1062  case 25: {
1063  // color by average speed
1064  return getMeanSpeed();
1065  }
1066  case 26: {
1067  // color by average relative speed
1068  return getMeanSpeed() / myMaxSpeed;
1069  }
1070  case 27: {
1071  // color by routing device assumed speed
1072  return myEdge->getRoutingSpeed();
1073  }
1074  case 28:
1076  case 29:
1077  return getPendingEmits();
1078  }
1079  return 0;
1080 }
1081 
1082 
1083 double
1084 GUILane::getScaleValue(int activeScheme) const {
1085  switch (activeScheme) {
1086  case 0:
1087  return 0;
1088  case 1:
1089  return isLaneOrEdgeSelected();
1090  case 2:
1091  return getSpeedLimit();
1092  case 3:
1093  return getBruttoOccupancy();
1094  case 4:
1095  return getNettoOccupancy();
1096  case 5:
1097  return firstWaitingTime();
1098  case 6:
1099  return getEdgeLaneNumber();
1100  case 7:
1101  return getCO2Emissions() / myLength;
1102  case 8:
1103  return getCOEmissions() / myLength;
1104  case 9:
1105  return getPMxEmissions() / myLength;
1106  case 10:
1107  return getNOxEmissions() / myLength;
1108  case 11:
1109  return getHCEmissions() / myLength;
1110  case 12:
1111  return getFuelConsumption() / myLength;
1112  case 13:
1114  case 14: {
1115  return getStoredEdgeTravelTime();
1116  }
1117  case 15: {
1119  if (!ews.knowsTravelTime(myEdge)) {
1120  return -1;
1121  } else {
1122  double value(0);
1123  ews.retrieveExistingTravelTime(myEdge, 0, value);
1124  return 100 * myLength / value / getSpeedLimit();
1125  }
1126  }
1127  case 16: {
1128  return 1 / myLengthGeometryFactor;
1129  }
1130  case 17: {
1131  return getLoadedEdgeWeight();
1132  }
1133  case 18: {
1134  return myEdge->getPriority();
1135  }
1136  case 19: {
1137  // scale by average speed
1138  return getMeanSpeed();
1139  }
1140  case 20: {
1141  // scale by average relative speed
1142  return getMeanSpeed() / myMaxSpeed;
1143  }
1144  case 21:
1146  case 22:
1148  }
1149  return 0;
1150 }
1151 
1152 
1153 bool
1156 }
1157 
1158 
1159 bool
1161  return isWaterway(myPermissions) && s.showRails && !s.drawForSelecting; // reusing the showRails setting
1162 }
1163 
1164 
1165 #ifdef HAVE_OSG
1166 void
1167 GUILane::updateColor(const GUIVisualizationSettings& s) {
1168  if (myGeom == 0) {
1169  // not drawn
1170  return;
1171  }
1172  const RGBColor col = setColor(s);
1173  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1174  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1175  myGeom->setColorArray(colors);
1176 }
1177 #endif
1178 
1179 
1180 void
1181 GUILane::closeTraffic(bool rebuildAllowed) {
1182  MSGlobals::gCheckRoutes = false;
1183  if (myAmClosed) {
1184  myPermissionChanges.clear(); // reset rerouters
1186  } else {
1188  }
1190  if (rebuildAllowed) {
1192  }
1193 }
1194 
1195 
1198  assert(MSGlobals::gUseMesoSim);
1199  int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1200  const double slength = myLength / no;
1201  PositionVector result = shape;
1202  double offset = 0;
1203  for (int i = 0; i < no; ++i) {
1204  offset += slength;
1205  Position pos = shape.positionAtOffset(offset);
1206  int index = result.indexOfClosest(pos);
1207  if (pos.distanceTo(result[index]) > POSITION_EPS) {
1208  index = result.insertAtClosest(pos);
1209  }
1210  while ((int)myShapeSegments.size() < index) {
1211  myShapeSegments.push_back(i);
1212  }
1213  //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1214  }
1215  while (myShapeSegments.size() < result.size()) {
1216  myShapeSegments.push_back(no - 1);
1217  }
1218  return result;
1219 }
1220 
1221 bool
1223  return gSelected.isSelected(GLO_LANE, getGlID());
1224 }
1225 
1226 bool
1228  return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1229 }
1230 
1231 double
1234 }
1235 
1236 /****************************************************************************/
1237 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:326
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:2509
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:747
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1227
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2382
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:893
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GUILane.h:323
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1174
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2604
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:617
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)
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:273
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:193
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:66
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:269
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:2855
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:1095
~GUILane()
Destructor.
Definition: GUILane.cpp:104
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition: GUILane.cpp:923
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:480
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1227
void drawArrows() const
Definition: GUILane.cpp:357
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1084
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:2628
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:667
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:295
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:243
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1181
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition: GUILane.h:346
double exaggeration
The size exaggeration (upscale)
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:83
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.
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:720
const double SUMO_const_laneWidth
Definition: StdDefs.h:51
double y() const
Returns the y-position.
Definition: Position.h:61
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:1197
int myIndex
The lane index.
Definition: MSLane.h:1161
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1782
bool showRails
Information whether rails shall be drawn.
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:229
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.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2022
double x() const
Returns the x-position.
Definition: Position.h:56
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:1287
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:160
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:2592
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:507
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:449
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:76
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:833
#define RAD2DEG(x)
Definition: GeomHelper.h:39
bool setMultiColor(const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GUILane.cpp:952
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:233
const MSJunction * getToJunction() const
Definition: MSEdge.h:346
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:856
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:254
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:523
bool integrateNewVehicle(SUMOTime t)
Definition: GUILane.cpp:172
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:238
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:320
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1160
The link is a (hard) left direction.
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1158
double getColorValue(int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:977
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1207
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:73
authorities vehicles
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:267
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:880
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:1255
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1184
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:97
bool isInternal() const
Definition: MSLane.cpp:1852
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
double firstWaitingTime() const
Definition: GUILane.cpp:868
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:241
double myLength
Lane length [m].
Definition: MSLane.h:1210
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:530
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:158
bool executeMovements(SUMOTime t, std::vector< MSLane *> &into)
Definition: GUILane.cpp:144
double getEdgeLaneNumber() const
Definition: GUILane.cpp:874
void resetPermissions(long long transientID)
Definition: MSLane.cpp:3277
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:807
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:114
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:3265
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:201
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:246
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:2568
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:343
static bool gCheckRoutes
Definition: MSGlobals.h:79
double minSize
The minimum size to draw this object.
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:477
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 ...
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:137
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:695
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:1232
bool showSublanes
Whether to show sublane boundaries.
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1222
const double SUMO_const_laneMarkWidth
Definition: StdDefs.h:57
double getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:499
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:735
#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:906
#define POSITION_EPS
Definition: config.h:172
const PositionVector & getShape() const
Definition: GUILane.cpp:850
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1572
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:124
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:151
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:1154
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:229
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2011
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:224
double laneMinSize
The minimum visual lane width for drawing.
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2616
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:608
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:83
vehicle is a passenger car (a "normal" car)
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:261
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:165
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2640
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:654
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:2580
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:301
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:247
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:362
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:69
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:680
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1221
void drawLane2LaneConnections(double exaggeration) const
Definition: GUILane.cpp:424
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:862
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:179
The link has red light (must brake)
The popup menu of a globject.
an edge
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:471
This is an uncontrolled, major link, may pass.
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2652
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:317
bool drawCrossingsAndWalkingareas
whether crosings and walkingareas shall be drawn
bool myAmClosed
state for dynamic lane closings
Definition: GUILane.h:339
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:62
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:243
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:721
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:233
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIVisualizationSizeSettings vehicleSize
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2552
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:186
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1273
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:451
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:1952
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:772
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:329
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
GUIScaler laneScaler
The lane scaler.
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:332
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1224
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2524
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:71
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:131
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:89
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
const double myWidth
Lane width [m].
Definition: MSLane.h:1213
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:294
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:1094
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:126
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:765
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