SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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>
40 #include <utils/common/StdDefs.h>
41 #include <utils/geom/GeomHelper.h>
42 #include <utils/gui/div/GLHelper.h>
47 #include <microsim/MSGlobals.h>
48 #include <microsim/MSLane.h>
51 #include <microsim/MSNet.h>
53 #include "GUILane.h"
54 #include "GUIEdge.h"
55 #include "GUIVehicle.h"
56 #include "GUINet.h"
57 
58 #ifdef HAVE_OSG
59 #include <osg/Geometry>
60 #endif
61 
62 #ifdef CHECK_MEMORY_LEAKS
63 #include <foreign/nvwa/debug_new.h>
64 #endif // CHECK_MEMORY_LEAKS
65 
66 //#define GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
67 
68 // ===========================================================================
69 // method definitions
70 // ===========================================================================
71 GUILane::GUILane(const std::string& id, SUMOReal maxSpeed, SUMOReal length,
72  MSEdge* const edge, unsigned int numericalID,
73  const PositionVector& shape, SUMOReal width,
74  SVCPermissions permissions, unsigned int index)
75  : MSLane(id, maxSpeed, length, edge, numericalID, shape, width, permissions),
76  GUIGlObject(GLO_LANE, id) {
77  myShapeRotations.reserve(myShape.size() - 1);
78  myShapeLengths.reserve(myShape.size() - 1);
79  int e = (int) myShape.size() - 1;
80  for (int i = 0; i < e; ++i) {
81  const Position& f = myShape[i];
82  const Position& s = myShape[i + 1];
83  myShapeLengths.push_back(f.distanceTo2D(s));
84  myShapeRotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
85  }
86  //
89  myIndex = index;
90 }
91 
92 
94  // just to quit cleanly on a failure
95  if (myLock.locked()) {
96  myLock.unlock();
97  }
98 }
99 
100 
101 // ------ Vehicle insertion ------
102 void
104  const MSLane::VehCont::iterator& at,
105  MSMoveReminder::Notification notification) {
107  MSLane::incorporateVehicle(veh, pos, speed, at, notification);
108 }
109 
110 
111 // ------ Access to vehicles ------
112 const MSLane::VehCont&
114  myLock.lock();
115  return myVehicles;
116 }
117 
118 
119 void
121  myLock.unlock();
122 }
123 
124 
125 void
129 }
130 
131 
132 bool
133 GUILane::executeMovements(SUMOTime t, std::vector<MSLane*>& into) {
135  return MSLane::executeMovements(t, into);
136 }
137 
138 
139 MSVehicle*
140 GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
142  return MSLane::removeVehicle(remVehicle, notification, notify);
143 }
144 
145 
146 void
150 }
151 
152 
153 bool
156  return MSLane::integrateNewVehicle(t);
157 }
158 
159 
160 void
161 GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
163  MSLane::detectCollisions(timestep, stage);
164 }
165 
166 
167 // ------ Drawing methods ------
168 void
170  unsigned int noLinks = (unsigned int)myLinks.size();
171  if (noLinks == 0) {
172  return;
173  }
174  // draw all links
175  if (getEdge().isCrossing()) {
176  // draw indices at the start and end of the crossing
178  PositionVector shape = getShape();
179  shape.extrapolate(0.5); // draw on top of the walking area
180  drawTextAtEnd(toString(link->getIndex()), shape, 0);
181  drawTextAtEnd(toString(link->getIndex()), shape.reverse(), 0);
182  return;
183  }
184  // draw all links
185  SUMOReal w = myWidth / (SUMOReal) noLinks;
187  for (int i = noLinks; --i >= 0;) {
188  SUMOReal x2 = x1 - (SUMOReal)(w / 2.);
189  drawTextAtEnd(toString(myLinks[i]->getIndex()), getShape(), x2);
190  x1 -= w;
191  }
192 }
193 
194 
195 void
196 GUILane::drawTLSLinkNo(const GUINet& net) const {
197  unsigned int noLinks = (unsigned int)myLinks.size();
198  if (noLinks == 0) {
199  return;
200  }
201  if (getEdge().isCrossing()) {
202  // draw indices at the start and end of the crossing
204  int linkNo = net.getLinkTLIndex(link);
205  if (linkNo >= 0) {
206  PositionVector shape = getShape();
207  shape.extrapolate(0.5); // draw on top of the walking area
208  drawTextAtEnd(toString(linkNo), shape, 0);
209  drawTextAtEnd(toString(linkNo), shape.reverse(), 0);
210  }
211  return;
212  }
213  // draw all links
214  SUMOReal w = myWidth / (SUMOReal) noLinks;
216  for (int i = noLinks; --i >= 0;) {
217  SUMOReal x2 = x1 - (SUMOReal)(w / 2.);
218  int linkNo = net.getLinkTLIndex(myLinks[i]);
219  if (linkNo < 0) {
220  continue;
221  }
222  drawTextAtEnd(toString(linkNo), getShape(), x2);
223  x1 -= w;
224  }
225 }
226 
227 
228 void
229 GUILane::drawTextAtEnd(const std::string& text, const PositionVector& shape, SUMOReal x) const {
230  glPushMatrix();
231  const Position& end = shape.back();
232  const Position& f = shape[-2];
233  const SUMOReal rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
234  glTranslated(end.x(), end.y(), 0);
235  glRotated(rot, 0, 0, 1);
236  GLHelper::drawText(text, Position(x, 0), 0, .6, RGBColor(128, 128, 255, 255), 180);
237  glPopMatrix();
238 }
239 
240 
241 void
242 GUILane::drawLinkRules(const GUINet& net) const {
243  unsigned int noLinks = (unsigned int)myLinks.size();
244  if (noLinks == 0) {
245  drawLinkRule(net, 0, getShape(), 0, 0);
246  return;
247  }
248  if (getEdge().isCrossing()) {
249  // draw rules at the start and end of the crossing
251  PositionVector shape = getShape();
252  shape.extrapolate(0.5); // draw on top of the walking area
253  drawLinkRule(net, link, shape, 0, myWidth);
254  drawLinkRule(net, link, shape.reverse(), 0, myWidth);
255  return;
256  }
257  // draw all links
258  SUMOReal w = myWidth / (SUMOReal) noLinks;
259  SUMOReal x1 = 0;
260  for (unsigned int i = 0; i < noLinks; ++i) {
261  SUMOReal x2 = x1 + w;
262  drawLinkRule(net, myLinks[i], getShape(), x1, x2);
263  x1 = x2;
264  }
265 }
266 
267 
268 void
269 GUILane::drawLinkRule(const GUINet& net, MSLink* link, const PositionVector& shape, SUMOReal x1, SUMOReal x2) const {
270  const Position& end = shape.back();
271  const Position& f = shape[-2];
272  const SUMOReal rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
273  if (link == 0) {
275  glPushMatrix();
276  glTranslated(end.x(), end.y(), 0);
277  glRotated(rot, 0, 0, 1);
278  glBegin(GL_QUADS);
279  glVertex2d(-myHalfLaneWidth, 0.0);
280  glVertex2d(-myHalfLaneWidth, 0.5);
281  glVertex2d(myHalfLaneWidth, 0.5);
282  glVertex2d(myHalfLaneWidth, 0.0);
283  glEnd();
284  glPopMatrix();
285  } else {
286  glPushMatrix();
287  glTranslated(end.x(), end.y(), 0);
288  glRotated(rot, 0, 0, 1);
289  // select glID
290  switch (link->getState()) {
293  case LINKSTATE_TL_RED:
298  glPushName(net.getLinkTLID(link));
299  break;
300  case LINKSTATE_MAJOR:
301  case LINKSTATE_MINOR:
302  case LINKSTATE_EQUAL:
304  default:
305  glPushName(getGlID());
306  break;
307  }
309  if (!isRailway(myPermissions) || link->getState() != LINKSTATE_MAJOR) {
310  // THE WHITE BAR SHOULD BE THE DEFAULT FOR MOST RAILWAY
311  // LINKS AND LOOKS UGLY SO WE DO NOT DRAW IT
312  glBegin(GL_QUADS);
313  glVertex2d(x1 - myHalfLaneWidth, 0.0);
314  glVertex2d(x1 - myHalfLaneWidth, 0.5);
315  glVertex2d(x2 - myHalfLaneWidth, 0.5);
316  glVertex2d(x2 - myHalfLaneWidth, 0.0);
317  glEnd();
318  }
319  glPopName();
320  glPopMatrix();
321  }
322 }
323 
324 void
326  if (myLinks.size() == 0) {
327  return;
328  }
329  // draw all links
330  const Position& end = getShape().back();
331  const Position& f = getShape()[-2];
332  const SUMOReal rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
333  glPushMatrix();
334  glColor3d(1, 1, 1);
335  glTranslated(end.x(), end.y(), 0);
336  glRotated(rot, 0, 0, 1);
338  glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
339  }
340  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
341  LinkDirection dir = (*i)->getDirection();
342  LinkState state = (*i)->getState();
343  if (state == LINKSTATE_TL_OFF_NOSIGNAL || dir == LINKDIR_NODIR) {
344  continue;
345  }
346  switch (dir) {
347  case LINKDIR_STRAIGHT:
348  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
350  break;
351  case LINKDIR_TURN:
352  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
353  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
354  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
355  GLHelper::drawTriangleAtEnd(Line(Position(0.5, 2.5), Position(0.5, 4)), (SUMOReal) 1, (SUMOReal) .25);
356  break;
357  case LINKDIR_LEFT:
358  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
359  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
360  GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(1.5, 2.5)), (SUMOReal) 1, (SUMOReal) .25);
361  break;
362  case LINKDIR_RIGHT:
363  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
364  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
365  GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(-1.5, 2.5)), (SUMOReal) 1, (SUMOReal) .25);
366  break;
367  case LINKDIR_PARTLEFT:
368  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
369  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
370  GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(1.2, 1.3)), (SUMOReal) 1, (SUMOReal) .25);
371  break;
372  case LINKDIR_PARTRIGHT:
373  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
374  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
375  GLHelper::drawTriangleAtEnd(Line(Position(0, 2.5), Position(-1.2, 1.3)), (SUMOReal) 1, (SUMOReal) .25);
376  break;
377  default:
378  break;
379  }
380  }
381  glPopMatrix();
382 }
383 
384 
385 void
387  for (std::vector<MSLink*>::const_iterator i = myLinks.begin(); i != myLinks.end(); ++i) {
388  const MSLane* connected = (*i)->getLane();
389  if (connected == 0) {
390  continue;
391  }
392  GLHelper::setColor(getLinkColor((*i)->getState()));
393  glBegin(GL_LINES);
394  const Position& p1 = getShape()[-1];
395  const Position& p2 = connected->getShape()[0];
396  glVertex2f(p1.x(), p1.y());
397  glVertex2f(p2.x(), p2.y());
398  glEnd();
399  GLHelper::drawTriangleAtEnd(Line(p1, p2), (SUMOReal) .4, (SUMOReal) .2);
400  }
401 }
402 
403 
404 void
406  glPushMatrix();
407  glPushName(getGlID());
408  const bool isCrossing = myEdge->getPurpose() == MSEdge::EDGEFUNCTION_CROSSING;
409  const bool isWalkingArea = myEdge->getPurpose() == MSEdge::EDGEFUNCTION_WALKINGAREA;
410  const bool isInternal = isCrossing || isWalkingArea || myEdge->getPurpose() == MSEdge::EDGEFUNCTION_INTERNAL;
411  bool mustDrawMarkings = false;
413 #ifdef HAVE_INTERNAL
415  GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
416  exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s.edgeScaler.getActive()));
417  }
418 #endif
419  const bool drawDetails = s.scale * exaggeration > 5;
420  if (isCrossing || isWalkingArea) {
421  // draw internal lanes on top of junctions
422  glTranslated(0, 0, GLO_JUNCTION + 0.1);
423  } else {
424  glTranslated(0, 0, getType());
425  }
426  // set lane color
427  if (!MSGlobals::gUseMesoSim) {
428  setColor(s);
429  }
430  // draw lane
431  // check whether it is not too small
432  if (s.scale * exaggeration < 1.) {
434  glPopMatrix();
435  } else {
436  GUINet* net = (GUINet*) MSNet::getInstance();
437  if (isRailway(myPermissions)) {
438  // draw as railway
439  const SUMOReal halfRailWidth = 0.725 * exaggeration;
441  glColor3d(1, 1, 1);
442  glTranslated(0, 0, .1);
444  if (!MSGlobals::gUseMesoSim) {
445  setColor(s);
446  }
447  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
448  } else if (isCrossing) {
449  // determine priority to decide color
451  if (link->havePriority() || net->getLinkTLIndex(link) > 0) {
452  glColor3d(0.9, 0.9, 0.9);
453  } else {
454  glColor3d(0.1, 0.1, 0.1);
455  }
456  glTranslated(0, 0, .2);
457  drawCrossties(0.5, 1.0, getWidth() * 0.5);
458  glTranslated(0, 0, -.2);
459  } else if (isWalkingArea) {
460  glTranslated(0, 0, .2);
461  if (s.scale * exaggeration < 20.) {
463  } else {
465  }
466  glTranslated(0, 0, -.2);
467 #ifdef GUILane_DEBUG_DRAW_WALKING_AREA_VERTICES
468  RGBColor color = RGBColor::fromHSV(RandHelper::rand(360), 1, 1);
469  glTranslated(0, 0, .4);
470  for (int i = 0; i < (int)myShape.size(); ++i) {
472  80 / s.scale, color, 0);
473  }
474  glTranslated(0, 0, -.4);
475 #endif
476  } else {
477  const SUMOReal laneWidth = isInternal ? myQuarterLaneWidth : myHalfLaneWidth;
478  mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN;
479  // recognize full transparency and simply don't draw
480  GLfloat color[4];
481  glGetFloatv(GL_CURRENT_COLOR, color);
482  if (color[3] > 0) {
483  const int cornerDetail = drawDetails ? s.scale * exaggeration : 0;
484  GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, laneWidth * exaggeration, cornerDetail);
485  }
486  }
487  glPopMatrix();
488  // draw ROWs (not for inner lanes)
489  if ((!isInternal || isCrossing) && drawDetails) {
490  glPushMatrix();
491  glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
492  glTranslated(0, 0, .5);
493  drawLinkRules(*net);
495  drawArrows();
496  }
497  if (s.showLane2Lane) {
498  // this should be independent to the geometry:
499  // draw from end of first to the begin of second
501  }
502  glTranslated(0, 0, .1);
503  if (s.drawLinkJunctionIndex) {
504  drawLinkNo();
505  }
506  if (s.drawLinkTLIndex) {
507  drawTLSLinkNo(*net);
508  }
509  glPopMatrix();
510  }
511  }
512  if (mustDrawMarkings && drawDetails) { // needs matrix reset
513  drawMarkings(s, exaggeration);
514  }
515  // draw vehicles
517  // retrieve vehicles from lane; disallow simulation
518  const MSLane::VehCont& vehicles = getVehiclesSecure();
519  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
520  if ((*v)->getLane() == this) {
521  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
522  } // else: this is the shadow during a continuous lane change
523  }
524  // draw parking vehicles
525  const std::set<const MSVehicle*> parking = MSVehicleTransfer::getInstance()->getParkingVehicles(this);
526  for (std::set<const MSVehicle*>::const_iterator v = parking.begin(); v != parking.end(); ++v) {
527  static_cast<const GUIVehicle* const>(*v)->drawGL(s);
528  }
529  // allow lane simulation
530  releaseVehicles();
531  }
532  glPopName();
533 }
534 
535 
536 void
538  glPushMatrix();
539  glTranslated(0, 0, GLO_EDGE);
540 #ifdef HAVE_INTERNAL
542 #endif
543  setColor(s);
544  // optionally draw inverse markings
545  if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
546  SUMOReal mw = (myHalfLaneWidth + SUMO_const_laneOffset + .01) * scale;
547  int e = (int) getShape().size() - 1;
548  for (int i = 0; i < e; ++i) {
549  glPushMatrix();
550  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
551  glRotated(myShapeRotations[i], 0, 0, 1);
552  for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) {
553  glBegin(GL_QUADS);
554  glVertex2d(-mw, -t);
555  glVertex2d(-mw, -t - 3.);
556  glVertex2d(myQuarterLaneWidth * scale, -t - 3.);
557  glVertex2d(myQuarterLaneWidth * scale, -t);
558  glEnd();
559  }
560  glPopMatrix();
561  }
562  }
563  // draw white boundings and white markings
564  glColor3d(1, 1, 1);
566  getShape(),
568  getShapeLengths(),
569  (getHalfWidth() + SUMO_const_laneOffset) * scale);
570  glPopMatrix();
571 }
572 
573 
574 void
575 GUILane::drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const {
576  glPushMatrix();
577  // draw on top of of the white area between the rails
578  glTranslated(0, 0, 0.1);
579  int e = (int) getShape().size() - 1;
580  for (int i = 0; i < e; ++i) {
581  glPushMatrix();
582  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
583  glRotated(myShapeRotations[i], 0, 0, 1);
584  for (SUMOReal t = 0; t < myShapeLengths[i]; t += spacing) {
585  glBegin(GL_QUADS);
586  glVertex2d(-halfWidth, -t);
587  glVertex2d(-halfWidth, -t - length);
588  glVertex2d(halfWidth, -t - length);
589  glVertex2d(halfWidth, -t);
590  glEnd();
591  }
592  glPopMatrix();
593  }
594  glPopMatrix();
595 }
596 
597 // ------ inherited from GUIGlObject
600  GUISUMOAbstractView& parent) {
601  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
602  buildPopupHeader(ret, app);
604  //
607  //
608  buildShowParamsPopupEntry(ret, false);
610  new FXMenuCommand(ret, ("pos: " + toString(pos)).c_str(), 0, 0, 0);
611  new FXMenuSeparator(ret);
612  buildPositionCopyEntry(ret, false);
613  return ret;
614 }
615 
616 
621  new GUIParameterTableWindow(app, *this, 11);
622  // add items
623  ret->mkItem("maxspeed [m/s]", false, getSpeedLimit());
624  ret->mkItem("length [m]", false, myLength);
625  ret->mkItem("street name", false, myEdge->getStreetName());
626  ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getStoredEdgeTravelTime));
627  ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getLoadedEdgeWeight));
628  ret->mkItem("occupancy [%]", true, new FunctionBinding<GUILane, SUMOReal>(this, &GUILane::getBruttoOccupancy, 100.));
629  ret->mkItem("edge type", false, myEdge->getEdgeType());
630  ret->mkItem("priority", false, myEdge->getPriority());
631  ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
632  ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
633  ret->mkItem("permission code", false, myPermissions);
634  // close building
635  ret->closeBuilding();
636  return ret;
637 }
638 
639 
640 Boundary
642  Boundary b;
643  b.add(myShape[0]);
644  b.add(myShape[-1]);
645  b.grow(20);
646  return b;
647 }
648 
649 
650 
651 
652 
653 
654 
655 const PositionVector&
657  return myShape;
658 }
659 
660 
661 const std::vector<SUMOReal>&
663  return myShapeRotations;
664 }
665 
666 
667 const std::vector<SUMOReal>&
669  return myShapeLengths;
670 }
671 
672 
673 SUMOReal
675  return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
676 }
677 
678 
679 SUMOReal
681  return (SUMOReal) myEdge->getLanes().size();
682 }
683 
684 
685 SUMOReal
688  if (!ews.knowsTravelTime(myEdge)) {
689  return -1;
690  } else {
691  SUMOReal value(0);
692  ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
693  return value;
694  }
695 }
696 
697 
698 SUMOReal
701  if (!ews.knowsEffort(myEdge)) {
702  return -1;
703  } else {
704  SUMOReal value(0);
705  ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
706  return value;
707  }
708 }
709 
710 
711 void
713  const GUIColorer& c = s.laneColorer;
714  if (!setFunctionalColor(c.getActive())) {
716  }
717 }
718 
719 
720 bool
721 GUILane::setFunctionalColor(size_t activeScheme) const {
722  switch (activeScheme) {
723  case 18: {
724  SUMOReal hue = RAD2DEG(myShape.beginEndAngle()) + 180; // [0-360]
726  return true;
727  }
728  default:
729  return false;
730  }
731 }
732 
733 
734 SUMOReal
735 GUILane::getColorValue(size_t activeScheme) const {
736  switch (activeScheme) {
737  case 0:
738  switch (myPermissions) {
739  case SVC_PEDESTRIAN:
740  return 1;
741  case SVC_BICYCLE:
742  return 2;
743  case 0:
744  return 3;
745  default:
746  return 0;
747  }
748  case 1:
749  return gSelected.isSelected(getType(), getGlID()) ||
750  gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
751  case 2:
752  return (SUMOReal)myPermissions;
753  case 3:
754  return getSpeedLimit();
755  case 4:
756  return getBruttoOccupancy();
757  case 5:
758  return getNettoOccupancy();
759  case 6:
760  return firstWaitingTime();
761  case 7:
762  return getEdgeLaneNumber();
763  case 8:
764  return getCO2Emissions() / myLength;
765  case 9:
766  return getCOEmissions() / myLength;
767  case 10:
768  return getPMxEmissions() / myLength;
769  case 11:
770  return getNOxEmissions() / myLength;
771  case 12:
772  return getHCEmissions() / myLength;
773  case 13:
774  return getFuelConsumption() / myLength;
775  case 14:
777  case 15: {
778  return getStoredEdgeTravelTime();
779  }
780  case 16: {
782  if (!ews.knowsTravelTime(myEdge)) {
783  return -1;
784  } else {
785  SUMOReal value(0);
786  ews.retrieveExistingTravelTime(myEdge, 0, value);
787  return 100 * myLength / value / getSpeedLimit();
788  }
789  }
790  case 17: {
791  return 1 / myLengthGeometryFactor;
792  }
793  case 19: {
795  if (!ews.knowsEffort(myEdge)) {
796  return -1;
797  } else {
798  SUMOReal value(0);
799  ews.retrieveExistingEffort(myEdge, 0, value);
800  return value;
801  }
802  }
803  case 20: {
804  return myEdge->getPriority();
805  }
806  }
807  return 0;
808 }
809 
810 
811 SUMOReal
812 GUILane::getScaleValue(size_t activeScheme) const {
813  switch (activeScheme) {
814  case 0:
815  return 0;
816  case 1:
817  return gSelected.isSelected(getType(), getGlID()) ||
818  gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
819  case 2:
820  return getSpeedLimit();
821  case 3:
822  return getBruttoOccupancy();
823  case 4:
824  return getNettoOccupancy();
825  case 5:
826  return firstWaitingTime();
827  case 6:
828  return getEdgeLaneNumber();
829  case 7:
830  return getCO2Emissions() / myLength;
831  case 8:
832  return getCOEmissions() / myLength;
833  case 9:
834  return getPMxEmissions() / myLength;
835  case 10:
836  return getNOxEmissions() / myLength;
837  case 11:
838  return getHCEmissions() / myLength;
839  case 12:
840  return getFuelConsumption() / myLength;
841  case 13:
843  case 14: {
844  return getStoredEdgeTravelTime();
845  }
846  case 15: {
848  if (!ews.knowsTravelTime(myEdge)) {
849  return -1;
850  } else {
851  SUMOReal value(0);
852  ews.retrieveExistingTravelTime(myEdge, 0, value);
853  return 100 * myLength / value / getSpeedLimit();
854  }
855  }
856  case 16: {
857  return 1 / myLengthGeometryFactor;
858  }
859  case 17: {
860  return getLoadedEdgeWeight();
861  }
862  case 18: {
863  return myEdge->getPriority();
864  }
865  }
866  return 0;
867 }
868 
869 #ifdef HAVE_OSG
870 void
871 GUILane::updateColor(const GUIVisualizationSettings& s) {
873  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
874  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
875  myGeom->setColorArray(colors);
876 }
877 #endif
878 
879 
880 
881 /****************************************************************************/
882 
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:827
void drawLane2LaneConnections() const
Definition: GUILane.cpp:386
VehCont myVehicles
The lane&#39;s vehicles. The entering vehicles are inserted at the front of this container and the leavin...
Definition: MSLane.h:804
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GUILane.cpp:662
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:455
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:78
SUMOReal getScaleValue(size_t activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUILane.cpp:812
float laneWidthExaggeration
The lane exaggeration (upscale thickness)
SUMOReal getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition: GUILane.cpp:699
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUILane.cpp:712
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:46
is a pedestrian
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:287
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
~GUILane()
Destructor.
Definition: GUILane.cpp:93
unsigned int myIndex
The lane index.
Definition: GUILane.h:282
bool drawLinkTLIndex
Information whether a link&#39;s tls index shall be drawn.
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:180
GUIColorer laneColorer
The lane colorer.
The link has green light, has to brake.
Stores the information about how to visualize structures.
vehicle is a bicycle
int SVCPermissions
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:945
The link is a 180 degree turn.
const RGBColor & getLinkColor(const LinkState &ls)
Definition: StdDefs.cpp:52
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:88
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:405
Notification
Definition of a vehicle state.
void drawTextAtEnd(const std::string &text, const PositionVector &shape, SUMOReal x) const
Definition: GUILane.cpp:229
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:1551
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1066
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:251
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, 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:125
SUMOReal getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:386
void drawMarkings(const GUIVisualizationSettings &s, SUMOReal scale) const
draw lane borders and white markings
Definition: GUILane.cpp:537
This is a dead end link.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:156
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:1441
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:71
This is an uncontrolled, right-before-left link.
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GUILane.cpp:668
#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:378
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:49
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:810
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads or pedestrian crossings
Definition: GUILane.cpp:575
void drawArrows() const
Definition: GUILane.cpp:325
SUMOReal beginEndAngle() const
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.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
bool integrateNewVehicle(SUMOTime t)
Definition: GUILane.cpp:154
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
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:548
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:1539
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
PositionVector reverse() const
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &into)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:759
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
The link is a straight direction.
MSLinkCont myLinks
Definition: MSLane.h:848
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:702
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:90
void drawLinkRules(const GUINet &net) const
Definition: GUILane.cpp:242
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:61
std::vector< SUMOReal > myShapeRotations
The rotations of the shape parts.
Definition: GUILane.h:270
A road/street connecting two junctions.
Definition: MSEdge.h:75
size_t getActive() const
Definition: GUIColorer.h:73
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
MSLane * getLogicalPredecessorLane() const
Definition: MSLane.cpp:1351
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUILane.cpp:618
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:361
bool executeMovements(SUMOTime t, std::vector< MSLane * > &into)
Definition: GUILane.cpp:133
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUILane.h:291
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUILane.cpp:641
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 drawTLSLinkNo(const GUINet &net) const
Definition: GUILane.cpp:196
void planMovements(const SUMOTime t)
Definition: GUILane.cpp:126
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GUILane.h:273
#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.
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:203
const T getColor(const SUMOReal value) const
Definition: Line.h:51
SUMOReal firstWaitingTime() const
Definition: GUILane.cpp:674
void drawLinkNo() const
helper methods
Definition: GUILane.cpp:169
The link is a (hard) right direction.
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:362
GUILane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge *const edge, unsigned int numericalID, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, unsigned int index)
Constructor.
Definition: GUILane.cpp:71
float minSize
The minimum size to draw this object.
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify)
Definition: GUILane.cpp:140
SUMOReal myLength
Lane length [m].
Definition: MSLane.h:807
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, 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:103
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GUILane.cpp:721
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1059
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
void drawLinkRule(const GUINet &net, MSLink *link, const PositionVector &shape, SUMOReal x1, SUMOReal x2) const
Definition: GUILane.cpp:269
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:257
SUMOReal getEdgeLaneNumber() const
Definition: GUILane.cpp:680
const SUMOReal myLengthGeometryFactor
Definition: MSLane.h:853
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void extrapolate(SUMOReal val)
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:147
The edge is a pedestrian walking area (a special type of internal edge)
Definition: MSEdge.h:98
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width)
Draws a thick line.
Definition: GLHelper.cpp:124
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:1527
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:1515
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Definition: MSEdge.h:222
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIVehicle.cpp:927
SUMOReal getColorValue(size_t activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:735
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:90
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:263
The link has yellow light, may pass.
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:686
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:1491
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:813
static void drawTriangleAtEnd(const Line &l, SUMOReal tLength, SUMOReal tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:341
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:1503
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:96
void detectCollisions(SUMOTime timestep, const std::string &stage)
Definition: GUILane.cpp:161
The link has red light (must brake)
SUMOReal getHalfWidth() const
Definition: GUILane.h:203
The popup menu of a globject.
an edge
SUMOReal myHalfLaneWidth
Half of lane width, for speed-up.
Definition: GUILane.h:276
bool drawLinkJunctionIndex
Information whether a link&#39;s junction index shall be drawn.
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.
int SUMOTime
Definition: SUMOTime.h:43
void lock()
lock mutex
Definition: MFXMutex.cpp:86
void text()
Definition: gl2psTest.c:260
unsigned int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:188
SUMOReal myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition: GUILane.h:279
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:323
const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: GUILane.cpp:113
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:240
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:205
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.
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
#define SUMOReal
Definition: config.h:218
static const bool gUseMesoSim
Definition: MSGlobals.h:102
GUIVisualizationSizeSettings vehicleSize
FXbool locked()
Definition: MFXMutex.h:70
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:1563
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUILane.cpp:599
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
The edge is an internal edge.
Definition: MSEdge.h:92
SUMOReal interpolateGeometryPosToLanePos(SUMOReal geometryPos) const
Definition: MSLane.h:346
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:1426
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.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
A window containing a gl-object&#39;s parameter.
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0)
Draws thick lines.
Definition: GLHelper.cpp:157
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.
void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: GUILane.cpp:120
SUMOReal getExaggeration(const GUIVisualizationSettings &s) const
return the drawing size including exaggeration and constantSize values
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:687
The link has no direction (is a dead end link)
const PositionVector & getShape() const
Definition: GUILane.cpp:656
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:647
a junction
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:68