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