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-2016 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  }
428  GLHelper::setColor(getLinkColor((*i)->getState()));
429  glBegin(GL_LINES);
430  const Position& p1 = getShape()[-1];
431  const Position& p2 = connected->getShape()[0];
432  glVertex2f(p1.x(), p1.y());
433  glVertex2f(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;
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  if (!MSGlobals::gUseMesoSim) {
467  setColor(s);
468  } else {
469  myShapeColors.clear();
470  const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
471  if (segmentColors.size() > 0) {
472  // apply segment specific shape colors
473  //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
474  for (int ii = 0; ii < (int)myShape.size() - 1; ++ii) {
475  myShapeColors.push_back(segmentColors[myShapeSegments[ii]]);
476  }
477  }
478  }
479  // recognize full transparency and simply don't draw
480  GLfloat color[4];
481  glGetFloatv(GL_CURRENT_COLOR, color);
482  if (color[3] != 0 && s.scale * exaggeration > s.laneMinSize) {
483  // draw lane
484  // check whether it is not too small
485  if (s.scale * exaggeration < 1.) {
486  if (myShapeColors.size() > 0) {
488  } else {
490  }
491  glPopMatrix();
492  } else {
493  GUINet* net = (GUINet*) MSNet::getInstance();
494  if (drawAsRailway(s)) {
495  // draw as railway
496  const SUMOReal halfRailWidth = 0.725 * exaggeration;
497  if (myShapeColors.size() > 0) {
499  } else {
501  }
502  glColor3d(1, 1, 1);
503  glTranslated(0, 0, .1);
505  if (!MSGlobals::gUseMesoSim) {
506  setColor(s);
507  }
508  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
509  } else if (isCrossing) {
511  // determine priority to decide color
513  if (link->havePriority() || net->getLinkTLIndex(link) > 0) {
514  glColor3d(0.9, 0.9, 0.9);
515  } else {
516  glColor3d(0.1, 0.1, 0.1);
517  }
518  glTranslated(0, 0, .2);
519  drawCrossties(0.5, 1.0, getWidth() * 0.5);
520  glTranslated(0, 0, -.2);
521  }
522  } else if (isWalkingArea) {
524  glTranslated(0, 0, .2);
525  if (s.scale * exaggeration < 20.) {
527  } else {
529  }
530  glTranslated(0, 0, -.2);
531 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
533 #endif
534  }
535  } else {
536  const SUMOReal halfWidth = isInternal ? myQuarterLaneWidth : myHalfLaneWidth;
537  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
538  const int cornerDetail = drawDetails && !isInternal ? s.scale * exaggeration : 0;
539  const SUMOReal offset = halfWidth * MAX2((SUMOReal)0, (exaggeration - 1));
540  if (myShapeColors.size() > 0) {
541  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myShapeColors, halfWidth * exaggeration, cornerDetail, offset);
542  } else {
543  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfWidth * exaggeration, cornerDetail, offset);
544  }
545  }
546 #ifdef GUILane_DEBUG_DRAW_VERTICES
548 #endif
549  glPopMatrix();
550  // draw ROWs (not for inner lanes)
551  if ((!isInternal || isCrossing) && drawDetails) {
552  glPushMatrix();
553  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
554  glTranslated(0, 0, .5);
556  // draw sublane-borders
557  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
558  for (SUMOReal offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
560  }
561  }
562  if (s.showLinkRules) {
563  drawLinkRules(s, *net);
564  }
566  drawArrows();
567  }
568  if (s.showLane2Lane) {
569  // this should be independent to the geometry:
570  // draw from end of first to the begin of second
572  }
573  if (s.showLaneDirection) {
575  }
576  glTranslated(0, 0, .1);
577  if (s.drawLinkJunctionIndex.show) {
578  drawLinkNo(s);
579  }
580  if (s.drawLinkTLIndex.show) {
581  drawTLSLinkNo(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  if (!MSGlobals::gUseMesoSim) {
621  setColor(s);
622  }
623  // optionally draw inverse markings
624  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
625  SUMOReal mw = (myHalfLaneWidth + SUMO_const_laneOffset + .01) * scale * (MSNet::getInstance()->lefthand() ? -1 : 1);
626  int e = (int) getShape().size() - 1;
627  for (int i = 0; i < e; ++i) {
628  glPushMatrix();
629  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
630  glRotated(myShapeRotations[i], 0, 0, 1);
631  for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) {
632  const SUMOReal length = MIN2((SUMOReal)3, myShapeLengths[i] - t);
633  glBegin(GL_QUADS);
634  glVertex2d(-mw, -t);
635  glVertex2d(-mw, -t - length);
636  glVertex2d(myQuarterLaneWidth * scale, -t - length);
637  glVertex2d(myQuarterLaneWidth * scale, -t);
638  glEnd();
639  }
640  glPopMatrix();
641  }
642  }
643  // draw white boundings and white markings
644  glColor3d(1, 1, 1);
646  getShape(),
648  getShapeLengths(),
650  glPopMatrix();
651 }
652 
653 
654 void
656  // draw bike lane markings onto the intersection
657  glColor3d(1, 1, 1);
658  int e = (int) getShape().size() - 1;
660  for (int i = 0; i < e; ++i) {
661  glPushMatrix();
662  glTranslated(getShape()[i].x(), getShape()[i].y(), GLO_JUNCTION + 0.1);
663  glRotated(myShapeRotations[i], 0, 0, 1);
664  for (SUMOReal t = 0; t < myShapeLengths[i]; t += 0.5) {
665  // left and right marking
666  for (int side = -1; side <= 1; side += 2) {
667  glBegin(GL_QUADS);
668  glVertex2d(side * mw, -t);
669  glVertex2d(side * mw, -t - 0.35);
670  glVertex2d(side * (mw + SUMO_const_laneOffset), -t - 0.35);
671  glVertex2d(side * (mw + SUMO_const_laneOffset), -t);
672  glEnd();
673  }
674  }
675  glPopMatrix();
676  }
677 }
678 
679 void
680 GUILane::drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const {
681  glPushMatrix();
682  // draw on top of of the white area between the rails
683  glTranslated(0, 0, 0.1);
684  int e = (int) getShape().size() - 1;
685  for (int i = 0; i < e; ++i) {
686  glPushMatrix();
687  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
688  glRotated(myShapeRotations[i], 0, 0, 1);
689  for (SUMOReal t = 0; t < myShapeLengths[i]; t += spacing) {
690  glBegin(GL_QUADS);
691  glVertex2d(-halfWidth, -t);
692  glVertex2d(-halfWidth, -t - length);
693  glVertex2d(halfWidth, -t - length);
694  glVertex2d(halfWidth, -t);
695  glEnd();
696  }
697  glPopMatrix();
698  }
699  glPopMatrix();
700 }
701 
702 
703 void
705  glColor3d(0.3, 0.3, 0.3);
706  glPushMatrix();
707  glTranslated(0, 0, GLO_EDGE);
708  int e = (int) getShape().size() - 1;
709  for (int i = 0; i < e; ++i) {
710  glPushMatrix();
711  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
712  glRotated(myShapeRotations[i], 0, 0, 1);
713  for (SUMOReal t = 0; t < myShapeLengths[i]; t += myWidth) {
714  const SUMOReal length = MIN2((SUMOReal)myHalfLaneWidth, myShapeLengths[i] - t);
715  glBegin(GL_TRIANGLES);
716  glVertex2d(0, -t - length);
717  glVertex2d(-myQuarterLaneWidth, -t);
718  glVertex2d(+myQuarterLaneWidth, -t);
719  glEnd();
720  }
721  glPopMatrix();
722  }
723  glPopMatrix();
724 }
725 
726 
727 
728 // ------ inherited from GUIGlObject
731  GUISUMOAbstractView& parent) {
732  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
733  buildPopupHeader(ret, app);
735  //
736  new FXMenuCommand(ret, "Copy edge name to clipboard", 0, ret, MID_COPY_EDGE_NAME);
739  //
740  buildShowParamsPopupEntry(ret, false);
743  new FXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), 0, 0, 0);
744  new FXMenuSeparator(ret);
745  buildPositionCopyEntry(ret, false);
746  new FXMenuSeparator(ret);
747  if (myAmClosed) {
748  if (myPermissionChanges.empty()) {
749  new FXMenuCommand(ret, "Reopen lane", 0, &parent, MID_CLOSE_LANE);
750  new FXMenuCommand(ret, "Reopen edge", 0, &parent, MID_CLOSE_EDGE);
751  } else {
752  new FXMenuCommand(ret, "Reopen lane (override rerouter)", 0, &parent, MID_CLOSE_LANE);
753  new FXMenuCommand(ret, "Reopen edge (override rerouter)", 0, &parent, MID_CLOSE_EDGE);
754  }
755  } else {
756  new FXMenuCommand(ret, "Close lane", 0, &parent, MID_CLOSE_LANE);
757  new FXMenuCommand(ret, "Close edge", 0, &parent, MID_CLOSE_EDGE);
758  }
759  new FXMenuCommand(ret, "Add rerouter", 0, &parent, MID_ADD_REROUTER);
760  return ret;
761 }
762 
763 
767  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 14);
768  // add items
769  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
770  ret->mkItem("length [m]", false, myLength);
771  ret->mkItem("width [m]", false, myWidth);
772  ret->mkItem("street name", false, myEdge->getStreetName());
773  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getStoredEdgeTravelTime));
774  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getLoadedEdgeWeight));
775  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, SUMOReal>(myEdge, &MSEdge::getRoutingSpeed));
776  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getBruttoOccupancy, 100.));
777  ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getNettoOccupancy, 100.));
778  ret->mkItem("edge type", false, myEdge->getEdgeType());
779  ret->mkItem("priority", false, myEdge->getPriority());
780  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
781  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
782  ret->mkItem("permission code", false, myPermissions);
783  // close building
784  ret->closeBuilding();
785  return ret;
786 }
787 
788 
789 Boundary
791  Boundary b;
792  b.add(myShape[0]);
793  b.add(myShape[-1]);
794  b.grow(10);
795  // ensure that vehicles and persons on the side are drawn even if the edge
796  // is outside the view
797  return b;
798 }
799 
800 
801 
802 
803 
804 
805 
806 const PositionVector&
808  return myShape;
809 }
810 
811 
812 const std::vector<SUMOReal>&
814  return myShapeRotations;
815 }
816 
817 
818 const std::vector<SUMOReal>&
820  return myShapeLengths;
821 }
822 
823 
824 SUMOReal
826  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
827 }
828 
829 
830 SUMOReal
832  return (SUMOReal) myEdge->getLanes().size();
833 }
834 
835 
836 SUMOReal
839  if (!ews.knowsTravelTime(myEdge)) {
840  return -1;
841  } else {
842  SUMOReal value(0);
843  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
844  return value;
845  }
846 }
847 
848 
849 SUMOReal
852  if (!ews.knowsEffort(myEdge)) {
853  return -1;
854  } else {
855  SUMOReal value(-1);
856  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
857  return value;
858  }
859 }
860 
861 
862 void
864  const GUIColorer& c = s.laneColorer;
865  if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
867  }
868 }
869 
870 
871 bool
872 GUILane::setFunctionalColor(int activeScheme) const {
873  switch (activeScheme) {
874  case 18: {
877  return true;
878  }
879  default:
880  return false;
881  }
882 }
883 
884 
885 bool
887  const int activeScheme = c.getActive();
888  myShapeColors.clear();
889  switch (activeScheme) {
890  case 22: // color by height at segment start
891  for (PositionVector::const_iterator ii = myShape.begin(); ii != myShape.end() - 1; ++ii) {
892  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
893  }
894  return true;
895  case 24: // color by inclination at segment start
896  for (int ii = 1; ii < (int)myShape.size(); ++ii) {
897  const SUMOReal inc = (myShape[ii].z() - myShape[ii - 1].z()) / MAX2(POSITION_EPS, myShape[ii].distanceTo2D(myShape[ii - 1]));
898  myShapeColors.push_back(c.getScheme().getColor(inc));
899  }
900  return true;
901  default:
902  return false;
903  }
904 }
905 
906 
907 SUMOReal
908 GUILane::getColorValue(int activeScheme) const {
909  switch (activeScheme) {
910  case 0:
911  switch (myPermissions) {
912  case SVC_PEDESTRIAN:
913  return 1;
914  case SVC_BICYCLE:
915  return 2;
916  case 0:
917  return 3;
918  case SVC_SHIP:
919  return 4;
920  case SVC_AUTHORITY:
921  return 6;
922  default:
923  break;
924  }
926  return 0;
927  } else {
928  return 5;
929  }
930  case 1:
931  return gSelected.isSelected(getType(), getGlID()) ||
932  gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
933  case 2:
934  return (SUMOReal)myPermissions;
935  case 3:
936  return getSpeedLimit();
937  case 4:
938  return getBruttoOccupancy();
939  case 5:
940  return getNettoOccupancy();
941  case 6:
942  return firstWaitingTime();
943  case 7:
944  return getEdgeLaneNumber();
945  case 8:
946  return getCO2Emissions() / myLength;
947  case 9:
948  return getCOEmissions() / myLength;
949  case 10:
950  return getPMxEmissions() / myLength;
951  case 11:
952  return getNOxEmissions() / myLength;
953  case 12:
954  return getHCEmissions() / myLength;
955  case 13:
956  return getFuelConsumption() / myLength;
957  case 14:
959  case 15: {
960  return getStoredEdgeTravelTime();
961  }
962  case 16: {
964  if (!ews.knowsTravelTime(myEdge)) {
965  return -1;
966  } else {
967  SUMOReal value(0);
968  ews.retrieveExistingTravelTime(myEdge, 0, value);
969  return 100 * myLength / value / getSpeedLimit();
970  }
971  }
972  case 17: {
973  return 1 / myLengthGeometryFactor;
974  }
975  case 19: {
976  return getLoadedEdgeWeight();
977  }
978  case 20: {
979  return myEdge->getPriority();
980  }
981  case 21: {
982  // color by z of first shape point
983  return getShape()[0].z();
984  }
985  case 23: {
986  // color by incline
987  return (getShape()[-1].z() - getShape()[0].z()) / getLength();
988  }
989  case 25: {
990  // color by average speed
991  return getMeanSpeed();
992  }
993  case 26: {
994  // color by average relative speed
995  return getMeanSpeed() / myMaxSpeed;
996  }
997  case 27: {
998  // color by routing device assumed speed
999  return myEdge->getRoutingSpeed();
1000  }
1001  case 28:
1003  case 29:
1005  }
1006  return 0;
1007 }
1008 
1009 
1010 SUMOReal
1011 GUILane::getScaleValue(int activeScheme) const {
1012  switch (activeScheme) {
1013  case 0:
1014  return 0;
1015  case 1:
1016  return gSelected.isSelected(getType(), getGlID()) ||
1017  gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1018  case 2:
1019  return getSpeedLimit();
1020  case 3:
1021  return getBruttoOccupancy();
1022  case 4:
1023  return getNettoOccupancy();
1024  case 5:
1025  return firstWaitingTime();
1026  case 6:
1027  return getEdgeLaneNumber();
1028  case 7:
1029  return getCO2Emissions() / myLength;
1030  case 8:
1031  return getCOEmissions() / myLength;
1032  case 9:
1033  return getPMxEmissions() / myLength;
1034  case 10:
1035  return getNOxEmissions() / myLength;
1036  case 11:
1037  return getHCEmissions() / myLength;
1038  case 12:
1039  return getFuelConsumption() / myLength;
1040  case 13:
1042  case 14: {
1043  return getStoredEdgeTravelTime();
1044  }
1045  case 15: {
1047  if (!ews.knowsTravelTime(myEdge)) {
1048  return -1;
1049  } else {
1050  SUMOReal value(0);
1051  ews.retrieveExistingTravelTime(myEdge, 0, value);
1052  return 100 * myLength / value / getSpeedLimit();
1053  }
1054  }
1055  case 16: {
1056  return 1 / myLengthGeometryFactor;
1057  }
1058  case 17: {
1059  return getLoadedEdgeWeight();
1060  }
1061  case 18: {
1062  return myEdge->getPriority();
1063  }
1064  case 19: {
1065  // scale by average speed
1066  return getMeanSpeed();
1067  }
1068  case 20: {
1069  // scale by average relative speed
1070  return getMeanSpeed() / myMaxSpeed;
1071  }
1072  case 21:
1074  case 22:
1076  }
1077  return 0;
1078 }
1079 
1080 
1081 bool
1083  return isRailway(myPermissions) && s.showRails;
1084 }
1085 
1086 
1087 bool
1089  return isWaterway(myPermissions) && s.showRails; // reusing the showRails setting
1090 }
1091 
1092 
1093 #ifdef HAVE_OSG
1094 void
1095 GUILane::updateColor(const GUIVisualizationSettings& s) {
1097  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1098  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1099  myGeom->setColorArray(colors);
1100 }
1101 #endif
1102 
1103 
1104 void
1105 GUILane::closeTraffic(bool rebuildAllowed) {
1106  MSGlobals::gCheckRoutes = false;
1107  if (myAmClosed) {
1108  myPermissionChanges.clear(); // reset rerouters
1110  } else {
1112  }
1114  if (rebuildAllowed) {
1116  }
1117 }
1118 
1119 
1122  assert(MSGlobals::gUseMesoSim);
1123  int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1124  const SUMOReal slength = myLength / no;
1125  PositionVector result = shape;
1126  SUMOReal offset = 0;
1127  for (int i = 0; i < no; ++i) {
1128  offset += slength;
1129  Position pos = shape.positionAtOffset(offset);
1130  int index = result.indexOfClosest(pos);
1131  if (pos.distanceTo(result[index]) > POSITION_EPS) {
1132  index = result.insertAtClosest(pos);
1133  }
1134  while ((int)myShapeSegments.size() < index) {
1135  myShapeSegments.push_back(i);
1136  }
1137  //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1138  }
1139  while (myShapeSegments.size() < result.size()) {
1140  myShapeSegments.push_back(no - 1);
1141  }
1142  return result;
1143 }
1144 
1145 /****************************************************************************/
1146 
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition: GUILane.h:322
SUMOReal getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:496
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:1084
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1954
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
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:1048
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:863
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:571
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
long long int SUMOTime
Definition: SUMOTime.h:43
void resetPermissions(long transientID)
Definition: MSLane.cpp:2615
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:294
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2124
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:49
is a pedestrian
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 drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:271
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:978
~GUILane()
Destructor.
Definition: GUILane.cpp:106
void drawArrows() const
Definition: GUILane.cpp:355
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:195
int indexOfClosest(const Position &p) const
index of the closest position to p
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
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:221
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:235
SUMOReal length() const
Returns the length.
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1105
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
SUMOReal getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:507
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 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:1121
int myIndex
The lane index.
Definition: MSLane.h:1035
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1362
bool showRails
Information whether rails shall be drawn.
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition: GUILane.cpp:224
The link is a 180 degree turn.
const RGBColor & getLinkColor(const LinkState &ls)
Definition: StdDefs.cpp:53
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1543
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
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
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
This is a dead end link.
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads or pedestrian crossings
Definition: GUILane.cpp:680
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:472
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
T MAX2(T a, T b)
Definition: StdDefs.h:75
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
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
bool showLaneDirection
Whether to show direction indicators for lanes.
PositionVector reverse() const
reverse position vector
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:819
bool laneShowBorders
Information whether lane borders shall be drawn.
This is an uncontrolled, right-before-left link.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:790
std::map< long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1132
#define RAD2DEG(x)
Definition: GeomHelper.h:46
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:52
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:1075
bool showLinkRules
Information whether link rules (colored bars) shall be drawn.
A storage for edge travel times and efforts.
The link is controlled by a tls which is off, not blinking, may pass.
SUMOReal interpolateGeometryPosToLanePos(SUMOReal geometryPos) const
Definition: MSLane.h:450
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GUILane.cpp:886
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.
SUMOReal myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1081
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 drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition: GUILane.cpp:1088
The link is a (hard) left direction.
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1032
bool retrieveExistingEffort(const MSEdge *const e, const SUMOReal t, SUMOReal &value) const
Returns an effort for an edge and time if stored.
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)
const std::set< const MSVehicle * > & getParkingVehicles(const MSLane *lane) const
return parking vehicles on the given lane
authorities vehicles
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:288
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
SUMOReal beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position ...
The link is a straight direction.
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:232
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:245
MSLinkCont myLinks
Definition: MSLane.h:1104
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:979
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:95
bool isInternal() const
Definition: MSLane.cpp:1410
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
void rebuildAllowedLanes()
Definition: MSEdge.cpp:251
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:503
bool executeMovements(SUMOTime t, std::vector< MSLane *> &into)
Definition: GUILane.cpp:146
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:765
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2056
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition: GUILane.cpp:196
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:225
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:339
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2136
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2160
static bool gCheckRoutes
Definition: MSGlobals.h:83
SUMOReal z() const
Returns the z-position.
Definition: Position.h:73
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
This is an uncontrolled, minor link, has to brake.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2148
SUMOReal getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2184
A list of positions.
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:139
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition: GUILane.cpp:655
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
bool showSublanes
Whether to show sublane boundaries.
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:316
SUMOReal getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:666
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
SUMOReal firstWaitingTime() const
Definition: GUILane.cpp:825
void drawTextAtEnd(const std::string &text, const PositionVector &shape, SUMOReal x, const GUIVisualizationTextSettings &settings) const
Definition: GUILane.cpp:258
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
SUMOReal getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2172
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIVisualizationTextSettings drawLinkTLIndex
T MIN2(T a, T b)
Definition: StdDefs.h:69
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
The link is a (hard) right direction.
#define POSITION_EPS
Definition: config.h:187
const PositionVector & getShape() const
Definition: GUILane.cpp:807
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1187
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GUILane.cpp:872
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:126
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:153
SUMOReal myLength
Lane length [m].
Definition: MSLane.h:1072
int insertAtClosest(const Position &p)
inserts p between the two closest positions and returns the insertion index
const T getColor(const SUMOReal value) const
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Definition: MSEdge.h:249
virtual SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:212
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1082
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1532
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
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;.
bool lefthand() const
return whether the network was built for lefthand traffic
Definition: MSNet.h:654
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:91
vehicle is a passenger car (a "normal" car)
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:282
static SUMOReal naviDegree(const SUMOReal angle)
Definition: GeomHelper.cpp:191
is an arbitrary ship
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2041
const SUMOReal myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1121
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void unlock()
release mutex lock
Definition: MFXMutex.cpp:96
SUMOReal getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2084
void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: GUILane.cpp:160
SUMOReal getEdgeLaneNumber() const
Definition: GUILane.cpp:831
The edge is a pedestrian walking area (a special type of internal edge)
Definition: MSEdge.h:103
void drawMarkings(const GUIVisualizationSettings &s, SUMOReal scale) const
draw lane borders and white markings
Definition: GUILane.cpp:617
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:2603
SUMOReal getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:1011
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:232
void drawLane2LaneConnections() const
Definition: GUILane.cpp:422
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2100
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
The link has yellow light, may pass.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:360
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
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
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:1078
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, MSLink *link, const PositionVector &shape, SUMOReal x1, SUMOReal x2) const
Definition: GUILane.cpp:299
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
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2112
The link has red light (must brake)
static SUMOReal gLateralResolution
Definition: MSGlobals.h:89
The popup menu of a globject.
SUMOReal getColorValue(int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:908
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.
SUMOReal getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:850
void lock()
lock mutex
Definition: MFXMutex.cpp:86
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
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GUILane.cpp:704
GUIGlID getGlID() const
Returns the numerical id of the object.
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:75
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.
#define SUMOReal
Definition: config.h:213
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GUIVisualizationSizeSettings vehicleSize
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GUILane.cpp:813
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
FXbool locked()
Definition: MFXMutex.h:70
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:441
The link has yellow light, has to brake anyway.
SUMOReal getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition: GUILane.cpp:837
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:730
SUMOReal laneMinSize
The minimum visual lane width for drawing.
The edge is an internal edge.
Definition: MSEdge.h:97
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
GUIScaler laneScaler
The lane scaler.
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
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:133
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:210
A window containing a gl-object&#39;s parameter.
The link has red light (must brake) but indicates upcoming green.
GUIVisualizationTextSettings drawLinkJunctionIndex
bool retrieveExistingTravelTime(const MSEdge *const e, const SUMOReal t, SUMOReal &value) const
Returns a travel time for an edge and time if stored.
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
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:937
The link has no direction (is a dead end link)
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:716
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