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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Representation of a lane in the micro simulation (gui-version)
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <utility>
35 #include <utils/geom/GeomHelper.h>
36 #include <utils/geom/Position.h>
40 #include <utils/common/StdDefs.h>
41 #include <utils/geom/GeomHelper.h>
42 #include <utils/gui/div/GLHelper.h>
48 #include <microsim/MSGlobals.h>
49 #include <microsim/MSLane.h>
53 #include <microsim/MSNet.h>
56 #include <mesosim/MELoop.h>
57 #include <mesosim/MESegment.h>
58 #include "GUILane.h"
59 #include "GUIEdge.h"
60 #include "GUIVehicle.h"
61 #include "GUINet.h"
62 
63 #ifdef HAVE_OSG
64 #include <osg/Geometry>
65 #endif
66 
67 //#define GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
68 //#define GUILane_DEBUG_DRAW_VERTICES
69 //#define GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
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  myAmClosed(false) {
82  myShape = splitAtSegments(shape);
83  assert(fabs(myShape.length() - shape.length()) < POSITION_EPS);
84  assert(myShapeSegments.size() == myShape.size());
85  }
86  myShapeRotations.reserve(myShape.size() - 1);
87  myShapeLengths.reserve(myShape.size() - 1);
88  myShapeColors.reserve(myShape.size() - 1);
89  int e = (int) myShape.size() - 1;
90  for (int i = 0; i < e; ++i) {
91  const Position& f = myShape[i];
92  const Position& s = myShape[i + 1];
93  myShapeLengths.push_back(f.distanceTo2D(s));
94  myShapeRotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
95  }
96  //
97  myHalfLaneWidth = (double)(myWidth / 2.);
98  myQuarterLaneWidth = (double)(myWidth / 4.);
99 }
100 
101 
103  // just to quit cleanly on a failure
104  if (myLock.locked()) {
105  myLock.unlock();
106  }
107 }
108 
109 
110 // ------ Vehicle insertion ------
111 void
112 GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
113  const MSLane::VehCont::iterator& at,
114  MSMoveReminder::Notification notification) {
116  MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
117 }
118 
119 
120 // ------ Access to vehicles ------
121 const MSLane::VehCont&
123  myLock.lock();
124  return myVehicles;
125 }
126 
127 
128 void
130  myLock.unlock();
131 }
132 
133 
134 void
138 }
139 
140 
141 bool
142 GUILane::executeMovements(SUMOTime t, std::vector<MSLane*>& into) {
144  return MSLane::executeMovements(t, into);
145 }
146 
147 
148 MSVehicle*
149 GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
151  return MSLane::removeVehicle(remVehicle, notification, notify);
152 }
153 
154 
155 void
158  return MSLane::removeParking(remVehicle);
159 }
160 
161 
162 void
166 }
167 
168 
169 bool
172  return MSLane::integrateNewVehicle(t);
173 }
174 
175 
176 void
177 GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
179  MSLane::detectCollisions(timestep, stage);
180 }
181 
182 
183 double
187 }
188 
189 
190 void
194 }
195 
196 
197 // ------ Drawing methods ------
198 void
200  int noLinks = (int)myLinks.size();
201  if (noLinks == 0) {
202  return;
203  }
204  // draw all links
205  if (getEdge().isCrossing()) {
206  // draw indices at the start and end of the crossing
208  PositionVector shape = getShape();
209  shape.extrapolate(0.5); // draw on top of the walking area
212  return;
213  }
214  // draw all links
215  double w = myWidth / (double) noLinks;
216  double x1 = myHalfLaneWidth;
217  const bool lefthand = MSNet::getInstance()->lefthand();
218  for (int i = noLinks; --i >= 0;) {
219  double x2 = x1 - (double)(w / 2.);
221  x1 -= w;
222  }
223 }
224 
225 
226 void
228  int noLinks = (int)myLinks.size();
229  if (noLinks == 0) {
230  return;
231  }
232  if (getEdge().isCrossing()) {
233  // draw indices at the start and end of the crossing
235  int linkNo = net.getLinkTLIndex(link);
236  if (linkNo >= 0) {
237  PositionVector shape = getShape();
238  shape.extrapolate(0.5); // draw on top of the walking area
241  }
242  return;
243  }
244  // draw all links
245  double w = myWidth / (double) noLinks;
246  double x1 = myHalfLaneWidth;
247  const bool lefthand = MSNet::getInstance()->lefthand();
248  for (int i = noLinks; --i >= 0;) {
249  double x2 = x1 - (double)(w / 2.);
250  int linkNo = net.getLinkTLIndex(myLinks[lefthand ? noLinks - 1 - i : i]);
251  if (linkNo < 0) {
252  continue;
253  }
255  x1 -= w;
256  }
257 }
258 
259 
260 void
262  int noLinks = (int)myLinks.size();
263  if (noLinks == 0) {
264  drawLinkRule(s, net, 0, getShape(), 0, 0);
265  return;
266  }
267  if (getEdge().isCrossing()) {
268  // draw rules at the start and end of the crossing
270  PositionVector shape = getShape();
271  shape.extrapolate(0.5); // draw on top of the walking area
272  drawLinkRule(s, net, link, shape, 0, myWidth);
273  drawLinkRule(s, net, link, shape.reverse(), 0, myWidth);
274  return;
275  }
276  // draw all links
277  double w = myWidth / (double) noLinks;
278  double x1 = 0;
279  const bool lefthand = MSNet::getInstance()->lefthand();
280  for (int i = 0; i < noLinks; ++i) {
281  double x2 = x1 + w;
282  drawLinkRule(s, net, myLinks[lefthand ? noLinks - 1 - i : i], getShape(), x1, x2);
283  x1 = x2;
284  }
285 }
286 
287 
288 void
289 GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, MSLink* link, const PositionVector& shape, double x1, double x2) const {
290  const Position& end = shape.back();
291  const Position& f = shape[-2];
292  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
293  if (link == 0) {
295  glPushMatrix();
296  glTranslated(end.x(), end.y(), 0);
297  glRotated(rot, 0, 0, 1);
298  glBegin(GL_QUADS);
299  glVertex2d(-myHalfLaneWidth, 0.0);
300  glVertex2d(-myHalfLaneWidth, 0.5);
301  glVertex2d(myHalfLaneWidth, 0.5);
302  glVertex2d(myHalfLaneWidth, 0.0);
303  glEnd();
304  glPopMatrix();
305  } else {
306  glPushMatrix();
307  glTranslated(end.x(), end.y(), 0);
308  glRotated(rot, 0, 0, 1);
309  // select glID
310  switch (link->getState()) {
313  case LINKSTATE_TL_RED:
318  glPushName(net.getLinkTLID(link));
319  break;
320  case LINKSTATE_MAJOR:
321  case LINKSTATE_MINOR:
322  case LINKSTATE_EQUAL:
324  default:
325  glPushName(getGlID());
326  break;
327  }
329  if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
330  // the white bar should be the default for most railway
331  // links and looks ugly so we do not draw it
332  glBegin(GL_QUADS);
333  glVertex2d(x1 - myHalfLaneWidth, 0.0);
334  glVertex2d(x1 - myHalfLaneWidth, 0.5);
335  glVertex2d(x2 - myHalfLaneWidth, 0.5);
336  glVertex2d(x2 - myHalfLaneWidth, 0.0);
337  glEnd();
338  }
339  glPopName();
340  glPopMatrix();
341  }
342 }
343 
344 void
346  if (myLinks.size() == 0) {
347  return;
348  }
349  // draw all links
350  const Position& end = getShape().back();
351  const Position& f = getShape()[-2];
352  const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
353  glPushMatrix();
354  glColor3d(1, 1, 1);
355  glTranslated(end.x(), end.y(), 0);
356  glRotated(rot, 0, 0, 1);
358  glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
359  }
360  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
361  LinkDirection dir = (*i)->getDirection();
362  LinkState state = (*i)->getState();
363  if (state == LINKSTATE_TL_OFF_NOSIGNAL || dir == LINKDIR_NODIR) {
364  continue;
365  }
366  switch (dir) {
367  case LINKDIR_STRAIGHT:
368  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
369  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
370  break;
371  case LINKDIR_TURN:
372  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
373  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
374  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
375  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
376  break;
378  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
379  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
380  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
381  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
382  break;
383  case LINKDIR_LEFT:
384  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
385  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
386  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
387  break;
388  case LINKDIR_RIGHT:
389  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
390  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
391  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
392  break;
393  case LINKDIR_PARTLEFT:
394  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
395  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
396  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
397  break;
398  case LINKDIR_PARTRIGHT:
399  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
400  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
401  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
402  break;
403  default:
404  break;
405  }
406  }
407  glPopMatrix();
408 }
409 
410 
411 void
413  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
414  const MSLane* connected = (*i)->getLane();
415  if (connected == 0) {
416  continue;
417  }
419  glBegin(GL_LINES);
420  const Position& p1 = getShape()[-1];
421  const Position& p2 = connected->getShape()[0];
422  glVertex2d(p1.x(), p1.y());
423  glVertex2d(p2.x(), p2.y());
424  glEnd();
425  GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
426  }
427 }
428 
429 
430 void
432  glPushMatrix();
433  glPushName(getGlID());
434  const bool isCrossing = myEdge->isCrossing();
435  const bool isWalkingArea = myEdge->isWalkingArea();
436  const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
437  bool mustDrawMarkings = false;
438  double exaggeration = s.laneWidthExaggeration;
440  GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
441  exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s.edgeScaler.getActive()));
442  } else {
444  }
445  const bool drawDetails = s.scale * exaggeration > 5 && !s.drawForSelecting;
446  if (isCrossing || isWalkingArea) {
447  // draw internal lanes on top of junctions
448  glTranslated(0, 0, GLO_JUNCTION + 0.1);
449  } else if (isWaterway(myPermissions)) {
450  // draw waterways below normal roads
451  glTranslated(0, 0, getType() - 0.2);
452  } else {
453  glTranslated(0, 0, getType());
454  }
455  // set lane color
456  setColor(s);
458  myShapeColors.clear();
459  const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
460  if (segmentColors.size() > 0) {
461  // apply segment specific shape colors
462  //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
463  for (int ii = 0; ii < (int)myShape.size() - 1; ++ii) {
464  myShapeColors.push_back(segmentColors[myShapeSegments[ii]]);
465  }
466  }
467  }
468  // recognize full transparency and simply don't draw
469  GLfloat color[4];
470  glGetFloatv(GL_CURRENT_COLOR, color);
471  if (color[3] != 0 && s.scale * exaggeration > s.laneMinSize &&
472  // only show one edge for a pair of superposed rail edges
474  || s.showLaneDirection
476  // draw lane
477  // check whether it is not too small
478  if (s.scale * exaggeration < 1.) {
479  if (myShapeColors.size() > 0) {
481  } else {
483  }
484  glPopMatrix();
485  } else {
486  GUINet* net = (GUINet*) MSNet::getInstance();
487  if (drawAsRailway(s)) {
488  // draw as railway
489  const double halfRailWidth = 0.725 * exaggeration;
490  if (myShapeColors.size() > 0) {
492  } else {
494  }
495  glColor3d(1, 1, 1);
496  glTranslated(0, 0, .1);
498  setColor(s);
499  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
500  } else if (isCrossing) {
502  glTranslated(0, 0, .2);
503  drawCrossties(0.5, 1.0, getWidth() * 0.5);
504  glTranslated(0, 0, -.2);
505  }
506  } else if (isWalkingArea) {
508  glTranslated(0, 0, .2);
509  if (s.scale * exaggeration < 20.) {
511  } else {
513  }
514  glTranslated(0, 0, -.2);
515 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
517 #endif
518  }
519  } else {
520  const double halfWidth = isInternal ? myQuarterLaneWidth : myHalfLaneWidth;
521  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
522  const int cornerDetail = drawDetails && !isInternal ? (int)(s.scale * exaggeration) : 0;
523  const double offset = halfWidth * MAX2(0., (exaggeration - 1));
524  if (myShapeColors.size() > 0) {
525  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myShapeColors, halfWidth * exaggeration, cornerDetail, offset);
526  } else {
527  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfWidth * exaggeration, cornerDetail, offset);
528  }
529  }
530 #ifdef GUILane_DEBUG_DRAW_VERTICES
532 #endif
533 #ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
536  }
537 #endif
538  glPopMatrix();
539  // draw ROWs (not for inner lanes)
540  if ((!isInternal || isCrossing) && (drawDetails || s.drawForSelecting)) {
541  glPushMatrix();
542  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
543  glTranslated(0, 0, .5);
544  if (drawDetails) {
546  // draw sublane-borders
547  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
548  for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
550  }
551  }
553  drawArrows();
554  }
555  if (s.showLane2Lane) {
556  // this should be independent to the geometry:
557  // draw from end of first to the begin of second
559  }
560  if (s.showLaneDirection) {
561  if (drawAsRailway(s)) {
562  // improve visibility of superposed rail edges
563  setColor(s);
564  } else {
565  glColor3d(0.3, 0.3, 0.3);
566  }
568  }
569  glTranslated(0, 0, .1);
570  if (s.drawLinkJunctionIndex.show) {
571  drawLinkNo(s);
572  }
573  if (s.drawLinkTLIndex.show) {
574  drawTLSLinkNo(s, *net);
575  }
576  }
577  // make sure link rules are drawn so tls can be selected via right-click
578  if (s.showLinkRules) {
579  drawLinkRules(s, *net);
580  }
581  glPopMatrix();
582  }
583  }
584  if (mustDrawMarkings && drawDetails && s.laneShowBorders) { // needs matrix reset
585  drawMarkings(s, exaggeration);
586  }
587  if (drawDetails && isInternal && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders) {
589  }
590  } else {
591  glPopMatrix();
592  }
593  // draw vehicles
595  // retrieve vehicles from lane; disallow simulation
596  const MSLane::VehCont& vehicles = getVehiclesSecure();
597  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
598  if ((*v)->getLane() == this) {
599  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
600  } // else: this is the shadow during a continuous lane change
601  }
602  // draw parking vehicles
603  for (std::set<const MSVehicle*>::const_iterator v = myParkingVehicles.begin(); v != myParkingVehicles.end(); ++v) {
604  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
605  }
606  // allow lane simulation
607  releaseVehicles();
608  }
609  glPopName();
610 }
611 
612 
613 void
614 GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale) const {
615  glPushMatrix();
616  glTranslated(0, 0, GLO_EDGE);
617  setColor(s);
618  // optionally draw inverse markings
619  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
620  double mw = (myHalfLaneWidth + SUMO_const_laneOffset + .01) * scale * (MSNet::getInstance()->lefthand() ? -1 : 1);
621  int e = (int) getShape().size() - 1;
622  for (int i = 0; i < e; ++i) {
623  glPushMatrix();
624  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
625  glRotated(myShapeRotations[i], 0, 0, 1);
626  for (double t = 0; t < myShapeLengths[i]; t += 6) {
627  const double length = MIN2((double)3, myShapeLengths[i] - t);
628  glBegin(GL_QUADS);
629  glVertex2d(-mw, -t);
630  glVertex2d(-mw, -t - length);
631  glVertex2d(myQuarterLaneWidth * scale, -t - length);
632  glVertex2d(myQuarterLaneWidth * scale, -t);
633  glEnd();
634  }
635  glPopMatrix();
636  }
637  }
638  // draw white boundings and white markings
639  glColor3d(1, 1, 1);
641  getShape(),
643  getShapeLengths(),
645  glPopMatrix();
646 }
647 
648 
649 void
651  // draw bike lane markings onto the intersection
652  glColor3d(1, 1, 1);
653  int e = (int) getShape().size() - 1;
654  double mw = (myHalfLaneWidth + SUMO_const_laneOffset);
655  for (int i = 0; i < e; ++i) {
656  glPushMatrix();
657  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.1);
658  glRotated(myShapeRotations[i], 0, 0, 1);
659  for (double t = 0; t < myShapeLengths[i]; t += 0.5) {
660  // left and right marking
661  for (int side = -1; side <= 1; side += 2) {
662  glBegin(GL_QUADS);
663  glVertex2d(side * mw, -t);
664  glVertex2d(side * mw, -t - 0.35);
665  glVertex2d(side * (mw + SUMO_const_laneOffset), -t - 0.35);
666  glVertex2d(side * (mw + SUMO_const_laneOffset), -t);
667  glEnd();
668  }
669  }
670  glPopMatrix();
671  }
672 }
673 
674 void
675 GUILane::drawCrossties(double length, double spacing, double halfWidth) const {
676  glPushMatrix();
677  // draw on top of of the white area between the rails
678  glTranslated(0, 0, 0.1);
679  int e = (int) getShape().size() - 1;
680  for (int i = 0; i < e; ++i) {
681  glPushMatrix();
682  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
683  glRotated(myShapeRotations[i], 0, 0, 1);
684  for (double t = 0; t < myShapeLengths[i]; t += spacing) {
685  glBegin(GL_QUADS);
686  glVertex2d(-halfWidth, -t);
687  glVertex2d(-halfWidth, -t - length);
688  glVertex2d(halfWidth, -t - length);
689  glVertex2d(halfWidth, -t);
690  glEnd();
691  }
692  glPopMatrix();
693  }
694  glPopMatrix();
695 }
696 
697 
698 void
700  glPushMatrix();
701  glTranslated(0, 0, GLO_EDGE);
702  int e = (int) getShape().size() - 1;
703  for (int i = 0; i < e; ++i) {
704  glPushMatrix();
705  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
706  glRotated(myShapeRotations[i], 0, 0, 1);
707  for (double t = 0; t < myShapeLengths[i]; t += myWidth) {
708  const double length = MIN2((double)myHalfLaneWidth, myShapeLengths[i] - t);
709  glBegin(GL_TRIANGLES);
710  glVertex2d(0, -t - length);
711  glVertex2d(-myQuarterLaneWidth, -t);
712  glVertex2d(+myQuarterLaneWidth, -t);
713  glEnd();
714  }
715  glPopMatrix();
716  }
717  glPopMatrix();
718 }
719 
720 
721 void
723  glPushMatrix();
724  glColor3d(1.0, 0.3, 0.3);
725  const double orthoLength = 0.5;
726  const MSLink* link = getLinkCont().front();
727  const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
728  const std::vector<std::pair<double, double> >& lengthsBehind = link->getLengthsBehindCrossing();
729  if (foeLanes.size() == lengthsBehind.size()) {
730  for (int i = 0; i < (int)foeLanes.size(); ++i) {
731  const MSLane* l = foeLanes[i];
732  Position pos = l->geometryPositionAtOffset(l->getLength() - lengthsBehind[i].second);
733  PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
734  if (ortho.length() < orthoLength) {
735  ortho.extrapolate(orthoLength - ortho.length(), false, true);
736  }
737  GLHelper::drawLine(ortho);
738  //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - lengthsBehind[i].second << " pos=" << pos << "\n";
739  }
740  }
741  glPopMatrix();
742 }
743 
744 
745 // ------ inherited from GUIGlObject
748  GUISUMOAbstractView& parent) {
749  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
750  buildPopupHeader(ret, app);
752  //
753  new FXMenuCommand(ret, "Copy edge name to clipboard", 0, ret, MID_COPY_EDGE_NAME);
756  //
757  buildShowParamsPopupEntry(ret, false);
760  new FXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), 0, 0, 0);
761  new FXMenuSeparator(ret);
762  buildPositionCopyEntry(ret, false);
763  new FXMenuSeparator(ret);
764  if (myAmClosed) {
765  if (myPermissionChanges.empty()) {
766  new FXMenuCommand(ret, "Reopen lane", 0, &parent, MID_CLOSE_LANE);
767  new FXMenuCommand(ret, "Reopen edge", 0, &parent, MID_CLOSE_EDGE);
768  } else {
769  new FXMenuCommand(ret, "Reopen lane (override rerouter)", 0, &parent, MID_CLOSE_LANE);
770  new FXMenuCommand(ret, "Reopen edge (override rerouter)", 0, &parent, MID_CLOSE_EDGE);
771  }
772  } else {
773  new FXMenuCommand(ret, "Close lane", 0, &parent, MID_CLOSE_LANE);
774  new FXMenuCommand(ret, "Close edge", 0, &parent, MID_CLOSE_EDGE);
775  }
776  new FXMenuCommand(ret, "Add rerouter", 0, &parent, MID_ADD_REROUTER);
777  return ret;
778 }
779 
780 
784  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 14);
785  // add items
786  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
787  ret->mkItem("length [m]", false, myLength);
788  ret->mkItem("width [m]", false, myWidth);
789  ret->mkItem("street name", false, myEdge->getStreetName());
790  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
791  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
792  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
793  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
794  ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
795  ret->mkItem("edge type", false, myEdge->getEdgeType());
796  ret->mkItem("priority", false, myEdge->getPriority());
797  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
798  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
799  ret->mkItem("permission code", false, myPermissions);
800  // close building
801  ret->closeBuilding();
802  return ret;
803 }
804 
805 
806 Boundary
808  Boundary b;
809  b.add(myShape[0]);
810  b.add(myShape[-1]);
811  b.grow(10);
812  // ensure that vehicles and persons on the side are drawn even if the edge
813  // is outside the view
814  return b;
815 }
816 
817 
818 
819 
820 
821 
822 
823 const PositionVector&
825  return myShape;
826 }
827 
828 
829 const std::vector<double>&
831  return myShapeRotations;
832 }
833 
834 
835 const std::vector<double>&
837  return myShapeLengths;
838 }
839 
840 
841 double
843  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
844 }
845 
846 
847 double
849  return (double) myEdge->getLanes().size();
850 }
851 
852 
853 double
856  if (!ews.knowsTravelTime(myEdge)) {
857  return -1;
858  } else {
859  double value(0);
860  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
861  return value;
862  }
863 }
864 
865 
866 double
869  if (!ews.knowsEffort(myEdge)) {
870  return -1;
871  } else {
872  double value(-1);
873  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
874  return value;
875  }
876 }
877 
878 
879 void
882  GLHelper::setColor(static_cast<const GUIEdge*>(myEdge)->getMesoColor());
883  } else {
884  const GUIColorer& c = s.laneColorer;
885  if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
887  }
888  }
889 }
890 
891 
892 bool
893 GUILane::setFunctionalColor(int activeScheme) const {
894  switch (activeScheme) {
895  case 0:
896  if (myEdge->isCrossing()) {
897  // determine priority to decide color
899  if (link->havePriority() || link->getTLLogic() != 0) {
900  GLHelper::setColor(RGBColor(230, 230, 230));
901  } else {
902  GLHelper::setColor(RGBColor(26, 26, 26));
903  }
904  return true;
905  } else {
906  return false;
907  }
908  case 18: {
909  double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
911  return true;
912  }
913  default:
914  return false;
915  }
916 }
917 
918 
919 bool
921  const int activeScheme = c.getActive();
922  myShapeColors.clear();
923  switch (activeScheme) {
924  case 22: // color by height at segment start
925  for (PositionVector::const_iterator ii = myShape.begin(); ii != myShape.end() - 1; ++ii) {
926  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
927  }
928  return true;
929  case 24: // color by inclination at segment start
930  for (int ii = 1; ii < (int)myShape.size(); ++ii) {
931  const double inc = (myShape[ii].z() - myShape[ii - 1].z()) / MAX2(POSITION_EPS, myShape[ii].distanceTo2D(myShape[ii - 1]));
932  myShapeColors.push_back(c.getScheme().getColor(inc));
933  }
934  return true;
935  default:
936  return false;
937  }
938 }
939 
940 
941 double
942 GUILane::getColorValue(int activeScheme) const {
943  switch (activeScheme) {
944  case 0:
945  switch (myPermissions) {
946  case SVC_PEDESTRIAN:
947  return 1;
948  case SVC_BICYCLE:
949  return 2;
950  case 0:
951  return 3;
952  case SVC_SHIP:
953  return 4;
954  case SVC_AUTHORITY:
955  return 6;
956  default:
957  break;
958  }
959  if (myEdge->isTazConnector()) {
960  return 7;
961  } else if ((myPermissions & SVC_PASSENGER) != 0 || isRailway(myPermissions)) {
962  return 0;
963  } else {
964  return 5;
965  }
966  case 1:
967  return isLaneOrEdgeSelected();
968  case 2:
969  return (double)myPermissions;
970  case 3:
971  return getSpeedLimit();
972  case 4:
973  return getBruttoOccupancy();
974  case 5:
975  return getNettoOccupancy();
976  case 6:
977  return firstWaitingTime();
978  case 7:
979  return getEdgeLaneNumber();
980  case 8:
981  return getCO2Emissions() / myLength;
982  case 9:
983  return getCOEmissions() / myLength;
984  case 10:
985  return getPMxEmissions() / myLength;
986  case 11:
987  return getNOxEmissions() / myLength;
988  case 12:
989  return getHCEmissions() / myLength;
990  case 13:
991  return getFuelConsumption() / myLength;
992  case 14:
994  case 15: {
995  return getStoredEdgeTravelTime();
996  }
997  case 16: {
999  if (!ews.knowsTravelTime(myEdge)) {
1000  return -1;
1001  } else {
1002  double value(0);
1003  ews.retrieveExistingTravelTime(myEdge, 0, value);
1004  return 100 * myLength / value / getSpeedLimit();
1005  }
1006  }
1007  case 17: {
1008  // geometrical length has no meaning for walkingAreas since it describes the outer boundary
1009  return myEdge->isWalkingArea() ? 1 : 1 / myLengthGeometryFactor;
1010  }
1011  case 19: {
1012  return getLoadedEdgeWeight();
1013  }
1014  case 20: {
1015  return myEdge->getPriority();
1016  }
1017  case 21: {
1018  // color by z of first shape point
1019  return getShape()[0].z();
1020  }
1021  case 23: {
1022  // color by incline
1023  return (getShape()[-1].z() - getShape()[0].z()) / getLength();
1024  }
1025  case 25: {
1026  // color by average speed
1027  return getMeanSpeed();
1028  }
1029  case 26: {
1030  // color by average relative speed
1031  return getMeanSpeed() / myMaxSpeed;
1032  }
1033  case 27: {
1034  // color by routing device assumed speed
1035  return myEdge->getRoutingSpeed();
1036  }
1037  case 28:
1039  case 29:
1041  }
1042  return 0;
1043 }
1044 
1045 
1046 double
1047 GUILane::getScaleValue(int activeScheme) const {
1048  switch (activeScheme) {
1049  case 0:
1050  return 0;
1051  case 1:
1052  return isLaneOrEdgeSelected();
1053  case 2:
1054  return getSpeedLimit();
1055  case 3:
1056  return getBruttoOccupancy();
1057  case 4:
1058  return getNettoOccupancy();
1059  case 5:
1060  return firstWaitingTime();
1061  case 6:
1062  return getEdgeLaneNumber();
1063  case 7:
1064  return getCO2Emissions() / myLength;
1065  case 8:
1066  return getCOEmissions() / myLength;
1067  case 9:
1068  return getPMxEmissions() / myLength;
1069  case 10:
1070  return getNOxEmissions() / myLength;
1071  case 11:
1072  return getHCEmissions() / myLength;
1073  case 12:
1074  return getFuelConsumption() / myLength;
1075  case 13:
1077  case 14: {
1078  return getStoredEdgeTravelTime();
1079  }
1080  case 15: {
1082  if (!ews.knowsTravelTime(myEdge)) {
1083  return -1;
1084  } else {
1085  double value(0);
1086  ews.retrieveExistingTravelTime(myEdge, 0, value);
1087  return 100 * myLength / value / getSpeedLimit();
1088  }
1089  }
1090  case 16: {
1091  return 1 / myLengthGeometryFactor;
1092  }
1093  case 17: {
1094  return getLoadedEdgeWeight();
1095  }
1096  case 18: {
1097  return myEdge->getPriority();
1098  }
1099  case 19: {
1100  // scale by average speed
1101  return getMeanSpeed();
1102  }
1103  case 20: {
1104  // scale by average relative speed
1105  return getMeanSpeed() / myMaxSpeed;
1106  }
1107  case 21:
1109  case 22:
1111  }
1112  return 0;
1113 }
1114 
1115 
1116 bool
1118  return isRailway(myPermissions) && s.showRails;
1119 }
1120 
1121 
1122 bool
1124  return isWaterway(myPermissions) && s.showRails; // reusing the showRails setting
1125 }
1126 
1127 
1128 #ifdef HAVE_OSG
1129 void
1130 GUILane::updateColor(const GUIVisualizationSettings& s) {
1132  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1133  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1134  myGeom->setColorArray(colors);
1135 }
1136 #endif
1137 
1138 
1139 void
1140 GUILane::closeTraffic(bool rebuildAllowed) {
1141  MSGlobals::gCheckRoutes = false;
1142  if (myAmClosed) {
1143  myPermissionChanges.clear(); // reset rerouters
1145  } else {
1147  }
1149  if (rebuildAllowed) {
1151  }
1152 }
1153 
1154 
1157  assert(MSGlobals::gUseMesoSim);
1158  int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1159  const double slength = myLength / no;
1160  PositionVector result = shape;
1161  double offset = 0;
1162  for (int i = 0; i < no; ++i) {
1163  offset += slength;
1164  Position pos = shape.positionAtOffset(offset);
1165  int index = result.indexOfClosest(pos);
1166  if (pos.distanceTo(result[index]) > POSITION_EPS) {
1167  index = result.insertAtClosest(pos);
1168  }
1169  while ((int)myShapeSegments.size() < index) {
1170  myShapeSegments.push_back(i);
1171  }
1172  //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1173  }
1174  while (myShapeSegments.size() < result.size()) {
1175  myShapeSegments.push_back(no - 1);
1176  }
1177  return result;
1178 }
1179 
1180 bool
1182  return gSelected.isSelected(GLO_LANE, getGlID());
1183 }
1184 
1185 bool
1187  return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1188 }
1189 
1190 /****************************************************************************/
1191 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:332
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:2383
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:91
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition: GUILane.cpp:722
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1204
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2256
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:867
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:1156
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:880
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2478
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:607
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
double scale
information about a lane&#39;s width (temporary, used for a single view)
void resetPermissions(long transientID)
Definition: MSLane.cpp:3131
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:232
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:278
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:183
void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:191
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:72
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:261
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:2729
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:1074
~GUILane()
Destructor.
Definition: GUILane.cpp:102
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:491
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition: GUILane.cpp:1186
void drawArrows() const
Definition: GUILane.cpp:345
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1047
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:190
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:2502
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:543
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:301
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:249
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1140
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:89
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
GUIColorer laneColorer
The lane colorer.
void drawCrossties(double length, double spacing, double halfWidth) const
draw crossties for railroads or pedestrian crossings
Definition: GUILane.cpp:675
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:556
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
double y() const
Returns the y-position.
Definition: Position.h:67
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:1156
int myIndex
The lane index.
Definition: MSLane.h:1143
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1715
bool showRails
Information whether rails shall be drawn.
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:227
The link is a 180 degree turn.
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1944
double x() const
Returns the x-position.
Definition: Position.h:62
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.
This is a dead end link.
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:167
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
T MAX2(T a, T b)
Definition: StdDefs.h:73
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:2466
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:83
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:497
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:439
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:82
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:807
std::map< long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1264
const double SUMO_const_laneOffset
Definition: StdDefs.h:52
#define RAD2DEG(x)
Definition: GeomHelper.h:45
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:229
const std::vector< double > & getShapeRotations() const
Definition: GUILane.cpp:830
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GUILane.cpp:920
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:259
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:513
bool integrateNewVehicle(SUMOTime t)
Definition: GUILane.cpp:170
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
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:1123
The link is a (hard) left direction.
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1140
double getColorValue(int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:942
std::set< const MSVehicle * > myParkingVehicles
Definition: MSLane.h:1189
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
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:272
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:854
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:1232
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1157
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:102
bool isInternal() const
Definition: MSLane.cpp:1774
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:59
double firstWaitingTime() const
Definition: GUILane.cpp:842
A road/street connecting two junctions.
Definition: MSEdge.h:80
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:186
void rebuildAllowedLanes()
Definition: MSEdge.cpp:246
double myLength
Lane length [m].
Definition: MSLane.h:1192
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:520
void removeParking(MSVehicle *veh)
remove parking vehicle
Definition: GUILane.cpp:156
bool executeMovements(SUMOTime t, std::vector< MSLane *> &into)
Definition: GUILane.cpp:142
double getEdgeLaneNumber() const
Definition: GUILane.cpp:848
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:782
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:112
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:199
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:242
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:449
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2442
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:349
static bool gCheckRoutes
Definition: MSGlobals.h:85
double minSize
The minimum size to draw this object.
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:467
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:45
A list of positions.
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:135
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:650
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
bool showSublanes
Whether to show sublane boundaries.
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUILane.cpp:1181
double getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:489
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:737
#define STEPS2TIME(x)
Definition: SUMOTime.h:64
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:67
The link is a (hard) right direction.
#define POSITION_EPS
Definition: config.h:175
const MSEdge * getMyOppositeSuperposableEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition: MSEdge.h:243
const PositionVector & getShape() const
Definition: GUILane.cpp:824
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1507
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GUILane.cpp:893
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:122
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:149
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:276
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1117
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:234
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1933
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:229
double laneMinSize
The minimum visual lane width for drawing.
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2490
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:597
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:89
vehicle is a passenger car (a "normal" car)
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:266
is an arbitrary ship
void unlock()
release mutex lock
Definition: MFXMutex.cpp:93
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:163
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:3119
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2514
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition: GUILane.cpp:614
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
void drawLane2LaneConnections() const
Definition: GUILane.cpp:412
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2454
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition: GUILane.cpp:289
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:252
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:88
The link has yellow light, may pass.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:359
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:75
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:70
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1198
const std::vector< double > & getShapeLengths() const
Definition: GUILane.cpp:836
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:177
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:461
This is an uncontrolled, major link, may pass.
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2526
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void lock()
lock mutex
Definition: MFXMutex.cpp:83
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
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GUILane.cpp:699
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:68
bool isWalkingArea() const
return whether this edge is walking area
Definition: MSEdge.h:248
The link is a 180 degree turn (left-hand network)
bool showLane2Lane
Information whether lane-to-lane arrows shall be drawn.
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:428
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:239
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIVisualizationSizeSettings vehicleSize
long long int SUMOTime
Definition: TraCIDefs.h:51
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2426
FXbool locked()
Definition: MFXMutex.h:69
double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: GUILane.cpp:184
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1250
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:431
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:137
The link has yellow light, has to brake anyway.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1874
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:250
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:85
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:747
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
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:1201
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2398
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
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:97
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:129
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:205
A window containing a gl-object&#39;s parameter.
static const RGBColor & getLinkColor(const LinkState &ls)
The link has red light (must brake) but indicates upcoming green.
GUIVisualizationTextSettings drawLinkJunctionIndex
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
const double myWidth
Lane width [m].
Definition: MSLane.h:1195
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:290
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:1073
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:785
a junction
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:455
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:60