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