Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUILane.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// Representation of a lane in the micro simulation (gui-version)
21/****************************************************************************/
22#include <config.h>
23
24#include <string>
25#include <utility>
28#include <utils/geom/Position.h>
42#include <microsim/MSGlobals.h>
43#include <microsim/MSLane.h>
44#include <microsim/MSLink.h>
48#include <microsim/MSNet.h>
52#include <mesosim/MELoop.h>
53#include <mesosim/MESegment.h>
54#include "GUILane.h"
55#include "GUIEdge.h"
56#include "GUIVehicle.h"
57#include "GUINet.h"
59
61
62//#define GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
63
64// ===========================================================================
65// static member declaration
66// ===========================================================================
69
70
71// ===========================================================================
72// method definitions
73// ===========================================================================
74GUILane::GUILane(const std::string& id, double maxSpeed, double friction, double length,
75 MSEdge* const edge, int numericalID,
76 const PositionVector& shape, double width,
77 SVCPermissions permissions,
78 SVCPermissions changeLeft, SVCPermissions changeRight,
79 int index, bool isRampAccel,
80 const std::string& type) :
81 MSLane(id, maxSpeed, friction, length, edge, numericalID, shape, width, permissions, changeLeft, changeRight, index, isRampAccel, type),
83 myParkingAreas(nullptr),
84 myTesselation(nullptr),
85#ifdef HAVE_OSG
86 myGeom(0),
87#endif
88 myAmClosed(false),
89 myLengthGeometryFactor2(myLengthGeometryFactor),
90 myLock(true) {
92 myShape = splitAtSegments(shape);
93 assert(fabs(myShape.length() - shape.length()) < POSITION_EPS);
94 assert(myShapeSegments.size() == myShape.size());
95 }
97 //
100}
101
102
104 // just to quit cleanly on a failure
105 if (myLock.locked()) {
106 myLock.unlock();
107 }
108 delete myParkingAreas;
109 delete myTesselation;
110}
111
112
113void
115 std::vector<double>& rotations,
116 std::vector<double>& lengths,
117 std::vector<RGBColor>& colors) {
118 rotations.clear();
119 lengths.clear();
120 colors.clear();
121 rotations.reserve(shape.size() - 1);
122 lengths.reserve(shape.size() - 1);
123 colors.reserve(shape.size() - 1);
124 int e = (int) shape.size() - 1;
125 for (int i = 0; i < e; ++i) {
126 const Position& f = shape[i];
127 const Position& s = shape[i + 1];
128 lengths.push_back(f.distanceTo2D(s));
129 rotations.push_back(RAD2DEG(atan2(s.x() - f.x(), f.y() - s.y())));
130 }
131}
132
133
134void
140
141
142// ------ Vehicle insertion ------
143void
144GUILane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
145 const MSLane::VehCont::iterator& at,
146 MSMoveReminder::Notification notification) {
147 FXMutexLock locker(myLock);
148 MSLane::incorporateVehicle(veh, pos, speed, posLat, at, notification);
149}
150
151
152// ------ Access to vehicles ------
153const MSLane::VehCont&
155 myLock.lock();
156 return myVehicles;
157}
158
159
160void
162 myLock.unlock();
163}
164
165
166void
168 FXMutexLock locker(myLock);
170}
171
172void
174 FXMutexLock locker(myLock);
176}
177
178
179void
181 FXMutexLock locker(myLock);
183}
184
185
187GUILane::removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify) {
188 FXMutexLock locker(myLock);
189 return MSLane::removeVehicle(remVehicle, notification, notify);
190}
191
192
193void
195 FXMutexLock locker(myLock);
196 return MSLane::removeParking(remVehicle);
197}
198
199
200void
205
206
207void
212
213
214void
215GUILane::detectCollisions(SUMOTime timestep, const std::string& stage) {
216 FXMutexLock locker(myLock);
217 MSLane::detectCollisions(timestep, stage);
218}
219
220
221double
223 FXMutexLock locker(myLock);
225}
226
227
228void
233
234
235// ------ Drawing methods ------
236void
238 int noLinks = (int)myLinks.size();
239 if (noLinks == 0) {
240 return;
241 }
242 // draw all links
243 if (getEdge().isCrossing()) {
244 // draw indices at the start and end of the crossing
245 const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
247 shape.extrapolate(0.5); // draw on top of the walking area
250 return;
251 }
252 // draw all links
253 double w = myWidth / (double) noLinks;
254 double x1 = myHalfLaneWidth;
255 for (int i = noLinks; --i >= 0;) {
256 double x2 = x1 - (double)(w / 2.);
258 x1 -= w;
259 }
260}
261
262
263void
265 int noLinks = (int)myLinks.size();
266 if (noLinks == 0) {
267 return;
268 }
269 if (getEdge().isCrossing()) {
270 // draw indices at the start and end of the crossing
271 const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
272 int linkNo = net.getLinkTLIndex(link);
273 // maybe the reverse link is controlled separately
274 int linkNo2 = net.getLinkTLIndex(myLinks.front());
275 // otherwise, use the same index as the forward link
276 if (linkNo2 < 0) {
277 linkNo2 = linkNo;
278 }
279 if (linkNo >= 0) {
281 shape.extrapolate(0.5); // draw on top of the walking area
282 GLHelper::drawTextAtEnd(toString(linkNo2), shape, 0, s.drawLinkTLIndex, s.scale);
284 }
285 return;
286 }
287 // draw all links
288 double w = myWidth / (double) noLinks;
289 double x1 = myHalfLaneWidth;
290 for (int i = noLinks; --i >= 0;) {
291 double x2 = x1 - (double)(w / 2.);
292 int linkNo = net.getLinkTLIndex(myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i]);
293 if (linkNo < 0) {
294 continue;
295 }
297 x1 -= w;
298 }
299}
300
301
302void
304 int noLinks = (int)myLinks.size();
305 const PositionVector& shape = getShape(s.secondaryShape);
306 if (noLinks == 0) {
307 drawLinkRule(s, net, nullptr, shape, 0, 0);
308 return;
309 }
310 if (getEdge().isCrossing()) {
311 // draw rules at the start and end of the crossing
312 const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
313 const MSLink* link2 = myLinks.front();
314 if (link2->getTLLogic() == nullptr) {
315 link2 = link;
316 }
317 PositionVector tmp = shape;
318 tmp.extrapolate(0.5); // draw on top of the walking area
319 drawLinkRule(s, net, link2, tmp, 0, myWidth);
320 drawLinkRule(s, net, link, tmp.reverse(), 0, myWidth);
321 return;
322 }
323 // draw all links
324 const double isRailSignal = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL;
325 double w = myWidth / (double) noLinks;
326 if (isRailSignal && noLinks > 1 && myLinks.back()->isTurnaround() && s.showRails) {
327 w = myWidth / (double)(noLinks - 1);
328 }
329 double x1 = isRailSignal ? -myWidth * 0.5 : 0;
330 for (int i = 0; i < noLinks; ++i) {
331 double x2 = x1 + w;
332 drawLinkRule(s, net, myLinks[MSGlobals::gLefthand ? noLinks - 1 - i : i], shape, x1, x2);
333 x1 = x2;
334 }
335 // draw stopOffset for passenger cars
337 const double stopOffsetPassenger = myLaneStopOffset.getOffset();
338 const Position& end = shape.back();
339 const Position& f = shape[-2];
340 const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
343 glTranslated(end.x(), end.y(), 0);
344 glRotated(rot, 0, 0, 1);
345 glTranslated(0, stopOffsetPassenger, 0);
346 glBegin(GL_QUADS);
347 glVertex2d(-myHalfLaneWidth, 0.0);
348 glVertex2d(-myHalfLaneWidth, 0.2);
349 glVertex2d(myHalfLaneWidth, 0.2);
350 glVertex2d(myHalfLaneWidth, 0.0);
351 glEnd();
353 }
354}
355
356
357void
358GUILane::drawLinkRule(const GUIVisualizationSettings& s, const GUINet& net, const MSLink* link, const PositionVector& shape, double x1, double x2) const {
359 const Position& end = shape.back();
360 const Position& f = shape[-2];
361 const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
362 if (link == nullptr) {
363 if (static_cast<GUIEdge*>(myEdge)->showDeadEnd()) {
365 } else {
367 }
369 glTranslated(end.x(), end.y(), 0);
370 glRotated(rot, 0, 0, 1);
371 glBegin(GL_QUADS);
372 glVertex2d(-myHalfLaneWidth, 0.0);
373 glVertex2d(-myHalfLaneWidth, 0.5);
374 glVertex2d(myHalfLaneWidth, 0.5);
375 glVertex2d(myHalfLaneWidth, 0.0);
376 glEnd();
378 } else {
380 glTranslated(end.x(), end.y(), 0);
381 glRotated(rot, 0, 0, 1);
382 // select glID
383
384 switch (link->getState()) {
386 case LINKSTATE_STOP: {
387 // might be a traffic light link
388 int tlID = net.getLinkTLID(link);
389 GLHelper::pushName(tlID != 0 ? tlID : getGlID());
390 break;
391 }
394 case LINKSTATE_TL_RED:
401 break;
402 case LINKSTATE_MAJOR:
403 case LINKSTATE_MINOR:
404 case LINKSTATE_EQUAL:
405 default:
407 break;
408 }
410 if (!(drawAsRailway(s) || drawAsWaterway(s)) || link->getState() != LINKSTATE_MAJOR) {
411 // the white bar should be the default for most railway
412 // links and looks ugly so we do not draw it
413 double scale = isInternal() ? 0.5 : 1;
415 scale *= MAX2(s.laneWidthExaggeration, s.junctionSize.getExaggeration(s, this, 10));
416 }
417 glScaled(scale, scale, 1);
418 glBegin(GL_QUADS);
419 glVertex2d(x1 - myHalfLaneWidth, 0.0);
420 glVertex2d(x1 - myHalfLaneWidth, 0.5);
421 glVertex2d(x2 - myHalfLaneWidth, 0.5);
422 glVertex2d(x2 - myHalfLaneWidth, 0.0);
423 glEnd();
424 }
427 }
428}
429
430void
431GUILane::drawArrows(bool secondaryShape) const {
432 if (myLinks.size() == 0) {
433 return;
434 }
435 // draw all links
436 const Position& end = getShape(secondaryShape).back();
437 const Position& f = getShape(secondaryShape)[-2];
438 const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
440 glColor3d(1, 1, 1);
441 glTranslated(end.x(), end.y(), 0);
442 glRotated(rot, 0, 0, 1);
444 glScaled(myWidth / SUMO_const_laneWidth, 1, 1);
445 }
446 for (const MSLink* const link : myLinks) {
447 LinkDirection dir = link->getDirection();
448 LinkState state = link->getState();
449 if (state == LINKSTATE_DEADEND || dir == LinkDirection::NODIR) {
450 continue;
451 }
452 switch (dir) {
454 GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
455 GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
456 break;
458 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
459 GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
460 GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
461 GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
462 break;
464 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
465 GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
466 GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
467 GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
468 break;
470 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
471 GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
472 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
473 break;
475 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
476 GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
477 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
478 break;
480 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
481 GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
482 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
483 break;
485 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
486 GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
487 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
488 break;
489 default:
490 break;
491 }
492 }
494}
495
496
497void
498GUILane::drawLane2LaneConnections(double exaggeration, bool s2) const {
499 Position centroid;
500 if (exaggeration > 1) {
501 centroid = myEdge->getToJunction()->getShape().getCentroid();
502 }
503 for (const MSLink* const link : myLinks) {
504 const GUILane* connected = dynamic_cast<GUILane*>(link->getLane());
505 if (connected == nullptr) {
506 continue;
507 }
509 glBegin(GL_LINES);
510 Position p1 = myEdge->isWalkingArea() ? getShape(s2).getCentroid() : getShape(s2)[-1];
511 Position p2 = connected->getEdge().isWalkingArea() ? connected->getShape(s2).getCentroid() : connected->getShape(s2)[0];
512 if (exaggeration > 1) {
513 p1 = centroid + ((p1 - centroid) * exaggeration);
514 p2 = centroid + ((p2 - centroid) * exaggeration);
515 }
516 glVertex2d(p1.x(), p1.y());
517 glVertex2d(p2.x(), p2.y());
518 glEnd();
519 GLHelper::drawTriangleAtEnd(p1, p2, (double) .4, (double) .2);
520 }
521}
522
523
524void
528 const bool s2 = s.secondaryShape;
529 const bool isCrossing = myEdge->isCrossing();
530 const bool isWalkingArea = myEdge->isWalkingArea();
531 const bool isInternal = isCrossing || isWalkingArea || myEdge->isInternal();
532 bool mustDrawMarkings = false;
533 double exaggeration = s.laneWidthExaggeration;
535 GUIEdge* myGUIEdge = dynamic_cast<GUIEdge*>(myEdge);
536 exaggeration *= s.edgeScaler.getScheme().getColor(myGUIEdge->getScaleValue(s, s.edgeScaler.getActive()));
537 } else {
538 exaggeration *= s.laneScaler.getScheme().getColor(getScaleValue(s, s.laneScaler.getActive(), s2));
539 }
540 const bool hasRailSignal = myEdge->getToJunction()->getType() == SumoXMLNodeType::RAIL_SIGNAL;
541 const bool detailZoom = s.scale * exaggeration > 5;
542 const bool drawDetails = (detailZoom || s.junctionSize.minSize == 0 || hasRailSignal) && !s.drawForPositionSelection;
543 const bool drawRails = drawAsRailway(s);
544 if (isCrossing || isWalkingArea) {
545 // draw internal lanes on top of junctions
546 glTranslated(0, 0, GLO_JUNCTION + 0.1);
547 } else if (isWaterway(myPermissions)) {
548 // draw waterways below normal roads
549 glTranslated(0, 0, getType() - 0.2);
550 } else {
551 glTranslated(0, 0, getType());
552 }
553 // set lane color
554 const RGBColor color = setColor(s);
555 const PositionVector& baseShape = getShape(s2);
556 auto& shapeColors = getShapeColors(s2);
558 shapeColors.clear();
559 const std::vector<RGBColor>& segmentColors = static_cast<const GUIEdge*>(myEdge)->getSegmentColors();
560 if (segmentColors.size() > 0) {
561 // apply segment specific shape colors
562 //std::cout << getID() << " shape=" << myShape << " shapeSegs=" << toString(myShapeSegments) << "\n";
563 for (int ii = 0; ii < (int)baseShape.size() - 1; ++ii) {
564 shapeColors.push_back(segmentColors[myShapeSegments[ii]]);
565 }
566 }
567 }
568 // recognize full transparency and simply don't draw
569 bool hiddenBidi = getBidiLane() != nullptr && myEdge->getNumericalID() > myEdge->getBidiEdge()->getNumericalID();
570 if (color.alpha() != 0 && s.scale * exaggeration > s.laneMinSize) {
571 // scale tls-controlled lane2lane-arrows along with their junction shapes
572 double junctionExaggeration = 1;
573 if (!isInternal
576 junctionExaggeration = MAX2(1.001, s.junctionSize.getExaggeration(s, this, 4));
577 }
578 // draw lane
579 // check whether it is not too small
580 if (s.scale * exaggeration < 1. && junctionExaggeration == 1 && s.junctionSize.minSize != 0) {
581 if (!isInternal || hasRailSignal) {
582 if (shapeColors.size() > 0) {
583 GLHelper::drawLine(baseShape, shapeColors);
584 } else {
585 GLHelper::drawLine(baseShape);
586 }
587 }
589 } else {
590 GUINet* net = (GUINet*) MSNet::getInstance();
591 const bool spreadSuperposed = s.spreadSuperposed && myBidiLane != nullptr;
592 if (hiddenBidi && !spreadSuperposed) {
593 // do not draw shape
594 mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions) && neighLaneNotBidi();
595 } else if (drawRails) {
596 // draw as railway: assume standard gauge of 1435mm when lane width is not set
597 // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
598 // assume crosstie length of 181% gauge (2600mm for standard gauge)
599 PositionVector shape = baseShape;
600 const double width = myWidth;
601 double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * exaggeration;
602 if (spreadSuperposed) {
603 try {
604 shape.move2side(halfGauge * 0.8);
605 } catch (InvalidArgument&) {}
606 halfGauge *= 0.4;
607 }
608 const double halfInnerFeetWidth = halfGauge - 0.039 * exaggeration;
609 const double halfRailWidth = detailZoom ? (halfInnerFeetWidth + 0.15 * exaggeration) : SUMO_const_halfLaneWidth * exaggeration;
610 const double halfCrossTieWidth = halfGauge * 1.81;
611 if (shapeColors.size() > 0) {
612 GLHelper::drawBoxLines(shape, getShapeRotations(s2), getShapeLengths(s2), getShapeColors(s2), halfRailWidth);
613 } else {
614 GLHelper::drawBoxLines(shape, getShapeRotations(s2), getShapeLengths(s2), halfRailWidth);
615 }
616 // Draw white on top with reduced width (the area between the two tracks)
617 if (detailZoom) {
618 glColor3d(1, 1, 1);
619 glTranslated(0, 0, .1);
620 GLHelper::drawBoxLines(shape, getShapeRotations(s2), getShapeLengths(s2), halfInnerFeetWidth);
621 setColor(s);
622 GLHelper::drawCrossTies(shape, getShapeRotations(s2), getShapeLengths(s2), 0.26 * exaggeration, 0.6 * exaggeration, halfCrossTieWidth, s.drawForPositionSelection);
623 }
624 } else if (isCrossing) {
625 if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
626 glTranslated(0, 0, .2);
628 glTranslated(0, 0, -.2);
629 }
630 } else if (isWalkingArea) {
631 if (s.drawCrossingsAndWalkingareas && (s.scale > 3.0 || s.junctionSize.minSize == 0)) {
632 glTranslated(0, 0, .2);
633 if (s.scale * exaggeration < 20.) {
634 GLHelper::drawFilledPoly(baseShape, true);
635 } else {
636 if (myTesselation == nullptr) {
638 }
639 myTesselation->drawTesselation(baseShape);
640 }
641 glTranslated(0, 0, -.2);
642 if (s.geometryIndices.show(this)) {
644 }
645 }
646 } else {
647 // we draw the lanes with reduced width so that the lane markings below are visible
648 // (this avoids artifacts at geometry corners without having to
649 // compute lane-marking intersection points)
651 mustDrawMarkings = !isInternal && myPermissions != 0 && myPermissions != SVC_PEDESTRIAN && exaggeration == 1.0 && !isWaterway(myPermissions);
652 const int cornerDetail = drawDetails && !isInternal ? (int)(s.scale * exaggeration) : 0;
653 double offset = halfWidth * MAX2(0., (exaggeration - 1)) * (MSGlobals::gLefthand ? -1 : 1);
654 if (spreadSuperposed) {
655 offset += halfWidth * 0.5 * (MSGlobals::gLefthand ? -1 : 1);
656 halfWidth *= 0.4; // create visible gap
657 }
658 if (shapeColors.size() > 0) {
659 GLHelper::drawBoxLines(baseShape, getShapeRotations(s2), getShapeLengths(s2), shapeColors, halfWidth * exaggeration, cornerDetail, offset);
660 } else {
661 GLHelper::drawBoxLines(baseShape, getShapeRotations(s2), getShapeLengths(s2), halfWidth * exaggeration, cornerDetail, offset);
662 }
663 }
664#ifdef GUILane_DEBUG_DRAW_FOE_INTERSECTIONS
667 }
668#endif
670 if (s.geometryIndices.show(this)) {
672 }
673 // draw details
674 if ((!isInternal || isCrossing || !s.drawJunctionShape) && (drawDetails || s.drawForPositionSelection || junctionExaggeration > 1)) {
676 glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
677 glTranslated(0, 0, .5);
678 if (drawDetails) {
679 if (s.showLaneDirection) {
680 if (drawRails) {
681 // improve visibility of superposed rail edges
682 GLHelper::setColor(setColor(s).changedBrightness(100));
683 } else {
684 glColor3d(0.3, 0.3, 0.3);
685 }
687 drawDirectionIndicators(exaggeration, spreadSuperposed, s.secondaryShape);
688 }
689 }
690 if (!isInternal || isCrossing
691 // controlled internal junction
692 || (getLinkCont().size() != 0 && getLinkCont()[0]->isInternalJunctionLink() && getLinkCont()[0]->getTLLogic() != nullptr)) {
693 if (MSGlobals::gLateralResolution > 0 && s.showSublanes && !hiddenBidi && (myPermissions & ~(SVC_PEDESTRIAN | SVC_RAIL_CLASSES)) != 0) {
694 // draw sublane-borders
695 const double offsetSign = MSGlobals::gLefthand ? -1 : 1;
697 for (double offset = -myHalfLaneWidth; offset < myHalfLaneWidth; offset += MSGlobals::gLateralResolution) {
698 GLHelper::drawBoxLines(baseShape, getShapeRotations(s2), getShapeLengths(s2), 0.01, 0, -offset * offsetSign);
699 }
700 }
702 // draw segment borders
704 for (int i : mySegmentStartIndex) {
705 if (shapeColors.size() > 0) {
706 GLHelper::setColor(shapeColors[i].changedBrightness(51));
707 }
708 GLHelper::drawBoxLine(baseShape[i], getShapeRotations(s2)[i] + 90, myWidth / 3, 0.2, 0);
709 GLHelper::drawBoxLine(baseShape[i], getShapeRotations(s2)[i] - 90, myWidth / 3, 0.2, 0);
710 }
711 }
712 if (s.showLinkDecals && !drawRails && !drawAsWaterway(s) && myPermissions != SVC_PEDESTRIAN) {
714 }
715 glTranslated(0, 0, 1000);
716 if (s.drawLinkJunctionIndex.show(nullptr)) {
717 drawLinkNo(s);
718 }
719 if (s.drawLinkTLIndex.show(nullptr)) {
720 drawTLSLinkNo(s, *net);
721 }
722 glTranslated(0, 0, -1000);
723 }
724 glTranslated(0, 0, .1);
725 }
726 if ((drawDetails || junctionExaggeration > 1) && s.showLane2Lane) {
727 // draw from end of first to the begin of second but respect junction scaling
728 drawLane2LaneConnections(junctionExaggeration, s.secondaryShape);
729 }
731 // make sure link rules are drawn so tls can be selected via right-click
732 if (s.showLinkRules && (drawDetails || s.drawForPositionSelection)
733 && !isWalkingArea
734 && (!myEdge->isInternal() || (getLinkCont().size() > 0 && getLinkCont()[0]->isInternalJunctionLink()))) {
736 glTranslated(0, 0, GLO_SHAPE); // must draw on top of junction shape and additionals
737 drawLinkRules(s, *net);
739 }
740 }
741 }
742 if (mustDrawMarkings && drawDetails && s.laneShowBorders) { // needs matrix reset
743 drawMarkings(s, exaggeration);
744 }
745 if (drawDetails && isInternal && s.showBikeMarkings && myPermissions == SVC_BICYCLE && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi) {
747 }
748 if (drawDetails && isInternal && exaggeration == 1.0 && s.showLinkDecals && s.laneShowBorders && !hiddenBidi && myIndex > 0
749 && !(myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER) && allowsChangingRight(SVC_PASSENGER))) {
750 // draw lane changing prohibitions on junction
752 }
753 } else {
755 }
756 // draw vehicles
757 if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
758 // retrieve vehicles from lane; disallow simulation
759 const MSLane::VehCont& vehicles = getVehiclesSecure();
760 for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
761 if ((*v)->getLane() == this) {
762 static_cast<const GUIVehicle*>(*v)->drawGL(s);
763 } // else: this is the shadow during a continuous lane change
764 }
765 // draw parking vehicles
766 for (const MSBaseVehicle* const v : myParkingVehicles) {
767 dynamic_cast<const GUIBaseVehicle*>(v)->drawGL(s);
768 }
769 // allow lane simulation
771 }
773}
774
775bool
777 const MSLane* right = getParallelLane(-1, false);
778 if (right && right->getBidiLane() == nullptr) {
779 return true;
780 }
781 const MSLane* left = getParallelLane(1, false);
782 if (left && left->getBidiLane() == nullptr) {
783 return true;
784 }
785 return false;
786}
787
788void
789GUILane::drawMarkings(const GUIVisualizationSettings& s, double scale) const {
791 glTranslated(0, 0, GLO_EDGE);
792 setColor(s);
793 // optionally draw inverse markings
794 const bool s2 = s.secondaryShape;
795 if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
796 const bool cl = myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER);
797 const bool cr = allowsChangingRight(SVC_PASSENGER);
799 }
800 // draw white boundings and white markings
801 glColor3d(1, 1, 1);
803 getShape(s2),
805 getShapeLengths(s2),
808}
809
810
811void
813 // draw bike lane markings onto the intersection
814 glColor3d(1, 1, 1);
816 const bool s2 = false;
817 const int e = (int) getShape(s2).size() - 1;
818 const double markWidth = 0.1;
819 const double mw = myHalfLaneWidth;
820 for (int i = 0; i < e; ++i) {
822 glTranslated(getShape(s2)[i].x(), getShape(s2)[i].y(), GLO_JUNCTION + 0.4);
823 glRotated(getShapeRotations(s2)[i], 0, 0, 1);
824 for (double t = 0; t < getShapeLengths(s2)[i]; t += 0.5) {
825 // left and right marking
826 for (int side = -1; side <= 1; side += 2) {
827 glBegin(GL_QUADS);
828 glVertex2d(side * mw, -t);
829 glVertex2d(side * mw, -t - 0.35);
830 glVertex2d(side * (mw + markWidth), -t - 0.35);
831 glVertex2d(side * (mw + markWidth), -t);
832 glEnd();
833 }
834 }
836 }
837}
838
839
840void
842 // fixme
843 const bool s2 = false;
844 // draw white markings
845 if (myIndex > 0 && (myEdge->getLanes()[myIndex - 1]->getPermissions() & myPermissions) != 0) {
846 glColor3d(1, 1, 1);
847 const bool cl = myEdge->getLanes()[myIndex - 1]->allowsChangingLeft(SVC_PASSENGER);
848 const bool cr = allowsChangingRight(SVC_PASSENGER);
849 // solid line marking
850 double mw, mw2;
851 // optional broken line marking
852 double mw3, mw4;
853 if (!cl && !cr) {
854 // draw a single solid line
857 mw3 = myHalfLaneWidth;
858 mw4 = myHalfLaneWidth;
859 } else {
860 // draw one solid and one broken line
861 if (cl) {
866 } else {
871 }
872 }
874 mw *= -1;
875 mw2 *= -1;
876 }
877 int e = (int) getShape(s2).size() - 1;
878 for (int i = 0; i < e; ++i) {
880 glTranslated(getShape(s2)[i].x(), getShape(s2)[i].y(), GLO_JUNCTION + 0.4);
881 glRotated(getShapeRotations(s2)[i], 0, 0, 1);
882 for (double t = 0; t < getShapeLengths(s2)[i]; t += 6) {
883 const double lengthSolid = MIN2(6.0, getShapeLengths(s2)[i] - t);
884 glBegin(GL_QUADS);
885 glVertex2d(-mw, -t);
886 glVertex2d(-mw, -t - lengthSolid);
887 glVertex2d(-mw2, -t - lengthSolid);
888 glVertex2d(-mw2, -t);
889 glEnd();
890 if (cl || cr) {
891 const double lengthBroken = MIN2(3.0, getShapeLengths(s2)[i] - t);
892 glBegin(GL_QUADS);
893 glVertex2d(-mw3, -t);
894 glVertex2d(-mw3, -t - lengthBroken);
895 glVertex2d(-mw4, -t - lengthBroken);
896 glVertex2d(-mw4, -t);
897 glEnd();
898 }
899 }
901 }
902 }
903}
904
905void
906GUILane::drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const {
908 glTranslated(0, 0, GLO_EDGE);
909 int e = (int) getShape(s2).size() - 1;
910 const double widthFactor = spreadSuperposed ? 0.4 : 1;
911 const double w = MAX2(POSITION_EPS, myWidth * widthFactor);
912 const double w2 = MAX2(POSITION_EPS, myHalfLaneWidth * widthFactor);
913 const double w4 = MAX2(POSITION_EPS, myQuarterLaneWidth * widthFactor);
914 const double sideOffset = spreadSuperposed ? w * -0.5 : 0;
915 for (int i = 0; i < e; ++i) {
917 glTranslated(getShape(s2)[i].x(), getShape(s2)[i].y(), 0.1);
918 glRotated(getShapeRotations(s2)[i], 0, 0, 1);
919 for (double t = 0; t < getShapeLengths(s2)[i]; t += w) {
920 const double length = MIN2(w2, getShapeLengths(s2)[i] - t) * exaggeration;
921 glBegin(GL_TRIANGLES);
922 glVertex2d(sideOffset, -t - length);
923 glVertex2d(sideOffset - w4 * exaggeration, -t);
924 glVertex2d(sideOffset + w4 * exaggeration, -t);
925 glEnd();
926 }
928 }
930}
931
932
933void
936 glColor3d(1.0, 0.3, 0.3);
937 const double orthoLength = 0.5;
938 const MSLink* link = getLinkCont().front();
939 const std::vector<const MSLane*>& foeLanes = link->getFoeLanes();
940 const auto& conflicts = link->getConflicts();
941 if (foeLanes.size() == conflicts.size()) {
942 for (int i = 0; i < (int)foeLanes.size(); ++i) {
943 const MSLane* l = foeLanes[i];
944 Position pos = l->geometryPositionAtOffset(l->getLength() - conflicts[i].lengthBehindCrossing);
945 PositionVector ortho = l->getShape().getOrthogonal(pos, 10, true, orthoLength);
946 if (ortho.length() < orthoLength) {
947 ortho.extrapolate(orthoLength - ortho.length(), false, true);
948 }
949 GLHelper::drawLine(ortho);
950 //std::cout << "foe=" << l->getID() << " lanePos=" << l->getLength() - lengthsBehind[i].second << " pos=" << pos << "\n";
951 }
952 }
954}
955
956
957// ------ inherited from GUIGlObject
960 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
961 buildPopupHeader(ret, app);
963 //
964 GUIDesigns::buildFXMenuCommand(ret, "Copy edge name to clipboard", nullptr, ret, MID_COPY_EDGE_NAME);
967 //
968 buildShowParamsPopupEntry(ret, false);
971 const double height = baseShape.positionAtOffset(pos).z();
972 GUIDesigns::buildFXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), nullptr, nullptr, 0);
973 if (getEdge().hasDistance()) {
974 GUIDesigns::buildFXMenuCommand(ret, ("distance: " + toString(getEdge().getDistanceAt(pos))).c_str(), nullptr, nullptr, 0);
975 }
976 new FXMenuSeparator(ret);
977 buildPositionCopyEntry(ret, app);
978 new FXMenuSeparator(ret);
979 if (myAmClosed) {
980 if (myPermissionChanges.empty()) {
981 GUIDesigns::buildFXMenuCommand(ret, "Reopen lane", nullptr, &parent, MID_CLOSE_LANE);
982 GUIDesigns::buildFXMenuCommand(ret, "Reopen edge", nullptr, &parent, MID_CLOSE_EDGE);
983 } else {
984 GUIDesigns::buildFXMenuCommand(ret, "Reopen lane (override rerouter)", nullptr, &parent, MID_CLOSE_LANE);
985 GUIDesigns::buildFXMenuCommand(ret, "Reopen edge (override rerouter)", nullptr, &parent, MID_CLOSE_EDGE);
986 }
987 } else {
988 GUIDesigns::buildFXMenuCommand(ret, "Close lane", nullptr, &parent, MID_CLOSE_LANE);
989 GUIDesigns::buildFXMenuCommand(ret, "Close edge", nullptr, &parent, MID_CLOSE_EDGE);
990 }
991 GUIDesigns::buildFXMenuCommand(ret, "Add rerouter", nullptr, &parent, MID_ADD_REROUTER);
992 new FXMenuSeparator(ret);
993 // reachability menu
994 FXMenuPane* reachableByClass = new FXMenuPane(ret);
995 ret->insertMenuPaneChild(reachableByClass);
996 new FXMenuCascade(ret, "Select reachable", GUIIconSubSys::getIcon(GUIIcon::FLAG), reachableByClass);
997 for (auto i : SumoVehicleClassStrings.getStrings()) {
999 }
1000 return ret;
1001}
1002
1003
1007 GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
1008 // add items
1009 ret->mkItem("allowed speed [m/s]", false, getSpeedLimit());
1010 const std::map<SUMOVehicleClass, double>* restrictions = MSNet::getInstance()->getRestrictions(myEdge->getEdgeType());
1011 if (restrictions != nullptr) {
1012 for (const auto& elem : *restrictions) {
1013 ret->mkItem((" allowed speed [m/s]: " + toString(elem.first)).c_str(), false, elem.second);
1014 }
1015 }
1016 ret->mkItem("length [m]", false, myLength);
1017 ret->mkItem("width [m]", false, myWidth);
1018 ret->mkItem("street name", false, myEdge->getStreetName());
1019 ret->mkItem("stored traveltime [s]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getStoredEdgeTravelTime));
1020 ret->mkItem("loaded weight", true, new FunctionBinding<GUILane, double>(this, &GUILane::getLoadedEdgeWeight));
1021 ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getRoutingSpeed));
1022 ret->mkItem("lane friction coefficient [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getFrictionCoefficient));
1023 ret->mkItem("time penalty [s]", true, new FunctionBinding<MSEdge, double>(myEdge, &MSEdge::getTimePenalty));
1024 ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getBruttoOccupancy, 100.));
1025 ret->mkItem("netto occupancy [%]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getNettoOccupancy, 100.));
1026 ret->mkItem("pending insertions [#]", true, new FunctionBinding<GUILane, double>(this, &GUILane::getPendingEmits));
1027 ret->mkItem("edge type", false, myEdge->getEdgeType());
1028 ret->mkItem("type", false, myLaneType);
1029 ret->mkItem("priority", false, myEdge->getPriority());
1030 ret->mkItem("distance [km]", false, myEdge->getDistance() / 1000);
1031 ret->mkItem("allowed vehicle class", false, getVehicleClassNames(myPermissions));
1032 ret->mkItem("disallowed vehicle class", false, getVehicleClassNames(~myPermissions));
1033 ret->mkItem("permission code", false, myPermissions);
1034 ret->mkItem("color value", true, new FunctionBinding<GUILane, double>(this, &GUILane::getColorValueForTracker));
1035 if (myBidiLane != nullptr) {
1036 ret->mkItem("bidi-lane", false, myBidiLane->getID());
1037 }
1038 for (const auto& kv : myEdge->getParametersMap()) {
1039 ret->mkItem(("edgeParam:" + kv.first).c_str(), false, kv.second);
1040 }
1042 ret->closeBuilding();
1043 return ret;
1044}
1045
1046
1049 Boundary b;
1050 b.add(myShape[0]);
1051 b.add(myShape[-1]);
1052 b.grow(10);
1053 // ensure that vehicles and persons on the side are drawn even if the edge
1054 // is outside the view
1055 return b;
1056}
1057
1058
1059const PositionVector&
1060GUILane::getShape(bool secondary) const {
1061 return secondary && myShape2.size() > 0 ? myShape2 : myShape;
1062}
1063
1064
1065const std::vector<double>&
1066GUILane::getShapeRotations(bool secondary) const {
1067 return secondary && myShapeRotations2.size() > 0 ? myShapeRotations2 : myShapeRotations;
1068}
1069
1070
1071const std::vector<double>&
1072GUILane::getShapeLengths(bool secondary) const {
1073 return secondary && myShapeLengths2.size() > 0 ? myShapeLengths2 : myShapeLengths;
1074}
1075
1076
1077std::vector<RGBColor>&
1078GUILane::getShapeColors(bool secondary) const {
1079 return secondary && myShapeColors2.size() > 0 ? myShapeColors2 : myShapeColors;
1080}
1081
1082
1083double
1085 return myVehicles.size() == 0 ? 0 : myVehicles.back()->getWaitingSeconds();
1086}
1087
1088
1089double
1091 return (double) myEdge->getLanes().size();
1092}
1093
1094
1095double
1098 if (!ews.knowsTravelTime(myEdge)) {
1099 return -1;
1100 } else {
1101 double value(0);
1102 ews.retrieveExistingTravelTime(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
1103 return value;
1104 }
1105}
1106
1107
1108double
1111 if (!ews.knowsEffort(myEdge)) {
1112 return -1;
1113 } else {
1114 double value(-1);
1115 ews.retrieveExistingEffort(myEdge, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()), value);
1116 return value;
1117 }
1118}
1119
1120
1121double
1123 switch (activeScheme) {
1124 case 18: {
1126 }
1127 default:
1128 return getColorValue(s, activeScheme);
1129 }
1130
1131}
1132
1133
1136 // setting and retrieving the color does not work in OSGView so we return it explicitliy
1137 RGBColor col;
1138 if (MSGlobals::gUseMesoSim && static_cast<const GUIEdge*>(myEdge)->getMesoColor() != MESO_USE_LANE_COLOR) {
1139 col = static_cast<const GUIEdge*>(myEdge)->getMesoColor();
1140 } else {
1141 const GUIColorer& c = s.laneColorer;
1142 if (!setFunctionalColor(c, col) && !setMultiColor(s, c, col)) {
1143 col = c.getScheme().getColor(getColorValue(s, c.getActive()));
1144 }
1145 }
1146 GLHelper::setColor(col);
1147 return col;
1148}
1149
1150
1151bool
1152GUILane::setFunctionalColor(const GUIColorer& c, RGBColor& col, int activeScheme) const {
1153 if (activeScheme < 0) {
1154 activeScheme = c.getActive();
1155 }
1156 switch (activeScheme) {
1157 case 0:
1158 if (myEdge->isCrossing()) {
1159 // determine priority to decide color
1160 const MSLink* const link = getLogicalPredecessorLane()->getLinkTo(this);
1161 if (link->havePriority() || link->getTLLogic() != nullptr) {
1162 col = RGBColor(230, 230, 230);
1163 } else {
1164 col = RGBColor(26, 26, 26);
1165 }
1166 GLHelper::setColor(col);
1167 return true;
1168 } else {
1169 return false;
1170 }
1171 case 18: {
1172 double hue = GeomHelper::naviDegree(myShape.beginEndAngle()); // [0-360]
1173 col = RGBColor::fromHSV(hue, 1., 1.);
1174 GLHelper::setColor(col);
1175 return true;
1176 }
1177 case 30: { // taz color
1178 col = c.getScheme().getColor(0);
1179 std::vector<RGBColor> tazColors;
1180 for (MSEdge* e : myEdge->getPredecessors()) {
1181 if (e->isTazConnector() && e->knowsParameter("tazColor")) {
1182 tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
1183 }
1184 }
1185 for (MSEdge* e : myEdge->getSuccessors()) {
1186 if (e->isTazConnector() && e->knowsParameter("tazColor")) {
1187 tazColors.push_back(RGBColor::parseColor(e->getParameter("tazColor")));
1188 }
1189 }
1190 if (tazColors.size() > 0) {
1191 int randColor = RandHelper::rand((int)tazColors.size(), RGBColor::getColorRNG());
1192 col = tazColors[randColor];
1193 }
1194 GLHelper::setColor(col);
1195 return true;
1196 }
1197 default:
1198 return false;
1199 }
1200}
1201
1202
1203bool
1205 const int activeScheme = c.getActive();
1206 auto& shapeColors = getShapeColors(s.secondaryShape);
1207 const PositionVector& shape = getShape(s.secondaryShape);
1208 shapeColors.clear();
1209 switch (activeScheme) {
1210 case 22: // color by height at segment start
1211 for (PositionVector::const_iterator ii = shape.begin(); ii != shape.end() - 1; ++ii) {
1212 shapeColors.push_back(c.getScheme().getColor(ii->z()));
1213 }
1214 // osg fallback (edge height at start)
1215 col = c.getScheme().getColor(getColorValue(s, 21));
1216 return true;
1217 case 24: // color by inclination at segment start
1218 for (int ii = 1; ii < (int)shape.size(); ++ii) {
1219 const double inc = (shape[ii].z() - shape[ii - 1].z()) / MAX2(POSITION_EPS, shape[ii].distanceTo2D(shape[ii - 1]));
1220 shapeColors.push_back(c.getScheme().getColor(inc));
1221 }
1222 col = c.getScheme().getColor(getColorValue(s, 23));
1223 return true;
1224 default:
1225 return false;
1226 }
1227}
1228
1229double
1231 if (myCachedGUISettings != nullptr) {
1233 const GUIColorer& c = s.laneColorer;
1235 } else {
1236 return 0;
1237 }
1238}
1239
1240
1241double
1242GUILane::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
1243 switch (activeScheme) {
1244 case 0:
1245 switch (myPermissions) {
1246 case SVC_PEDESTRIAN:
1247 return 1;
1248 case SVC_BICYCLE:
1249 return 2;
1250 case 0:
1251 // forbidden road or green verge
1252 return myEdge->getPermissions() == 0 ? 10 : 3;
1253 case SVC_SHIP:
1254 return 4;
1255 case SVC_AUTHORITY:
1256 return 8;
1257 default:
1258 break;
1259 }
1260 if (myEdge->isTazConnector()) {
1261 return 9;
1262 } else if (isRailway(myPermissions)) {
1263 if ((myPermissions & SVC_BUS) != 0) {
1264 return 6;
1265 } else {
1266 return 5;
1267 }
1268 } else if ((myPermissions & SVC_PASSENGER) != 0) {
1269 if ((myPermissions & (SVC_RAIL_CLASSES & ~SVC_RAIL_FAST)) != 0 && (myPermissions & SVC_SHIP) == 0) {
1270 return 6;
1271 } else {
1272 return 0;
1273 }
1274 } else {
1275 return 7;
1276 }
1277 case 1:
1278 return isLaneOrEdgeSelected();
1279 case 2:
1280 return (double)myPermissions;
1281 case 3:
1282 return getSpeedLimit();
1283 case 4:
1284 return getBruttoOccupancy();
1285 case 5:
1286 return getNettoOccupancy();
1287 case 6:
1288 return firstWaitingTime();
1289 case 7:
1290 return getEdgeLaneNumber();
1291 case 8:
1292 return getEmissions<PollutantsInterface::CO2>() / myLength;
1293 case 9:
1294 return getEmissions<PollutantsInterface::CO>() / myLength;
1295 case 10:
1296 return getEmissions<PollutantsInterface::PM_X>() / myLength;
1297 case 11:
1298 return getEmissions<PollutantsInterface::NO_X>() / myLength;
1299 case 12:
1300 return getEmissions<PollutantsInterface::HC>() / myLength;
1301 case 13:
1302 return getEmissions<PollutantsInterface::FUEL>() / myLength;
1303 case 14:
1305 case 15: {
1306 return getStoredEdgeTravelTime();
1307 }
1308 case 16: {
1310 if (!ews.knowsTravelTime(myEdge)) {
1311 return -1;
1312 } else {
1313 double value(0);
1314 ews.retrieveExistingTravelTime(myEdge, 0, value);
1315 return 100 * myLength / value / getSpeedLimit();
1316 }
1317 }
1318 case 17: {
1319 // geometrical length has no meaning for walkingAreas since it describes the outer boundary
1321 }
1322 case 19: {
1323 return getLoadedEdgeWeight();
1324 }
1325 case 20: {
1326 return myEdge->getPriority();
1327 }
1328 case 21: {
1329 // color by z of first shape point
1330 return getShape(s.secondaryShape)[0].z();
1331 }
1332 case 23: {
1333 // color by incline
1334 return (getShape(s.secondaryShape)[-1].z() - getShape(s.secondaryShape)[0].z()) / getLength();
1335 }
1336 case 25: {
1337 // color by average speed
1338 return getMeanSpeed();
1339 }
1340 case 26: {
1341 // color by average relative speed
1342 return getMeanSpeed() / myMaxSpeed;
1343 }
1344 case 27: {
1345 // color by routing device assumed speed
1346 return myEdge->getRoutingSpeed();
1347 }
1348 case 28:
1349 return getEmissions<PollutantsInterface::ELEC>() / myLength;
1350 case 29:
1351 return getPendingEmits();
1352 case 31: {
1353 // by numerical edge param value
1355 try {
1357 } catch (NumberFormatException&) {
1358 try {
1360 } catch (BoolFormatException&) {
1362 }
1363 }
1364 } else {
1366 }
1367 }
1368 case 32: {
1369 // by numerical lane param value
1370 if (knowsParameter(s.laneParam)) {
1371 try {
1373 } catch (NumberFormatException&) {
1374 try {
1376 } catch (BoolFormatException&) {
1378 }
1379 }
1380 } else {
1382 }
1383 }
1384 case 33: {
1385 // by edge data value
1387 }
1388 case 34: {
1389 return myEdge->getDistance();
1390 }
1391 case 35: {
1392 return fabs(myEdge->getDistance());
1393 }
1394 case 36: {
1395 return myReachability;
1396 }
1397 case 37: {
1399 }
1400 case 38: {
1401 if (myParkingAreas == nullptr) {
1402 // init
1403 myParkingAreas = new std::vector<MSParkingArea*>();
1405 if (&item.second->getLane().getEdge() == myEdge) {
1406 myParkingAreas->push_back(dynamic_cast<MSParkingArea*>(item.second));
1407 }
1408 }
1409 }
1410 int capacity = 0;
1411 for (MSParkingArea* pa : *myParkingAreas) {
1412 capacity += pa->getCapacity() - pa->getOccupancy();
1413 }
1414 return capacity;
1415 }
1416 case 39: {
1417 // by live edge data value
1419 }
1420 }
1421 return 0;
1422}
1423
1424
1425double
1426GUILane::getScaleValue(const GUIVisualizationSettings& s, int activeScheme, bool s2) const {
1427 switch (activeScheme) {
1428 case 0:
1429 return 0;
1430 case 1:
1431 return isLaneOrEdgeSelected();
1432 case 2:
1433 return getSpeedLimit();
1434 case 3:
1435 return getBruttoOccupancy();
1436 case 4:
1437 return getNettoOccupancy();
1438 case 5:
1439 return firstWaitingTime();
1440 case 6:
1441 return getEdgeLaneNumber();
1442 case 7:
1443 return getEmissions<PollutantsInterface::CO2>() / myLength;
1444 case 8:
1445 return getEmissions<PollutantsInterface::CO>() / myLength;
1446 case 9:
1447 return getEmissions<PollutantsInterface::PM_X>() / myLength;
1448 case 10:
1449 return getEmissions<PollutantsInterface::NO_X>() / myLength;
1450 case 11:
1451 return getEmissions<PollutantsInterface::HC>() / myLength;
1452 case 12:
1453 return getEmissions<PollutantsInterface::FUEL>() / myLength;
1454 case 13:
1456 case 14: {
1457 return getStoredEdgeTravelTime();
1458 }
1459 case 15: {
1461 if (!ews.knowsTravelTime(myEdge)) {
1462 return -1;
1463 } else {
1464 double value(0);
1465 ews.retrieveExistingTravelTime(myEdge, 0, value);
1466 return 100 * myLength / value / getSpeedLimit();
1467 }
1468 }
1469 case 16: {
1470 return 1 / getLengthGeometryFactor(s2);
1471 }
1472 case 17: {
1473 return getLoadedEdgeWeight();
1474 }
1475 case 18: {
1476 return myEdge->getPriority();
1477 }
1478 case 19: {
1479 // scale by average speed
1480 return getMeanSpeed();
1481 }
1482 case 20: {
1483 // scale by average relative speed
1484 return getMeanSpeed() / myMaxSpeed;
1485 }
1486 case 21:
1487 return getEmissions<PollutantsInterface::ELEC>() / myLength;
1488 case 22:
1490 case 23:
1491 // by edge data value
1493 }
1494 return 0;
1495}
1496
1497
1498bool
1502
1503
1504bool
1506 return isWaterway(myPermissions) && s.showRails && !s.drawForPositionSelection; // reusing the showRails setting
1507}
1508
1509
1510#ifdef HAVE_OSG
1511void
1512GUILane::updateColor(const GUIVisualizationSettings& s) {
1513 if (myGeom == 0) {
1514 // not drawn
1515 return;
1516 }
1517 const RGBColor col = setColor(s);
1518 osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
1519 (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
1520 myGeom->setColorArray(colors);
1521}
1522#endif
1523
1524
1525void
1526GUILane::closeTraffic(bool rebuildAllowed) {
1528 if (myAmClosed) {
1529 myPermissionChanges.clear(); // reset rerouters
1531 } else {
1533 }
1535 if (rebuildAllowed) {
1537 }
1538}
1539
1540
1543 assert(MSGlobals::gUseMesoSim);
1544 int no = MELoop::numSegmentsFor(myLength, OptionsCont::getOptions().getFloat("meso-edgelength"));
1545 const double slength = myLength / no;
1546 PositionVector result = shape;
1547 double offset = 0;
1548 for (int i = 0; i < no; ++i) {
1549 offset += slength;
1550 Position pos = shape.positionAtOffset(offset);
1551 int index = result.indexOfClosest(pos);
1552 if (pos.distanceTo(result[index]) > POSITION_EPS) {
1553 index = result.insertAtClosest(pos, false);
1554 }
1555 if (i != no - 1) {
1556 mySegmentStartIndex.push_back(index);
1557 }
1558 while ((int)myShapeSegments.size() < index) {
1559 myShapeSegments.push_back(i);
1560 }
1561 //std::cout << "splitAtSegments " << getID() << " no=" << no << " i=" << i << " offset=" << offset << " index=" << index << " segs=" << toString(myShapeSegments) << " resultSize=" << result.size() << " result=" << toString(result) << "\n";
1562 }
1563 while (myShapeSegments.size() < result.size()) {
1564 myShapeSegments.push_back(no - 1);
1565 }
1566 return result;
1567}
1568
1569bool
1573
1574bool
1576 return isSelected() || gSelected.isSelected(GLO_EDGE, dynamic_cast<GUIEdge*>(myEdge)->getGlID());
1577}
1578
1579double
1583
1584double
1587 // do not select lanes in meso mode
1588 return -std::numeric_limits<double>::max();
1589 }
1590 if (myEdge->isCrossing()) {
1591 return GLO_CROSSING;
1592 }
1593 return GLO_LANE;
1594}
1595
1596
1597/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ MID_COPY_EDGE_NAME
Copy edge name (for lanes only)
Definition GUIAppEnum.h:452
@ MID_REACHABILITY
show reachability from a given lane
Definition GUIAppEnum.h:524
@ MID_CLOSE_LANE
close lane
Definition GUIAppEnum.h:659
@ MID_CLOSE_EDGE
close edge
Definition GUIAppEnum.h:661
@ MID_ADD_REROUTER
add rerouter
Definition GUIAppEnum.h:663
@ GLO_JUNCTION
a junction
@ GLO_LANE
a lane
@ GLO_EDGE
an edge
@ GLO_SHAPE
reserved GLO type to pack shapes
@ GLO_CROSSING
a tl-logic
GUISelectedStorage gSelected
A global holder of selected objects.
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define STEPS2TIME(x)
Definition SUMOTime.h:55
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
@ SVC_SHIP
is an arbitrary ship
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_RAIL_FAST
vehicle that is allowed to drive on high-speed rail tracks
@ SVC_AUTHORITY
authorities vehicles
@ SVC_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_PARKING_AREA
A parking area.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ TURN
The link is a 180 degree turn.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ TURN_LEFTHAND
The link is a 180 degree turn (left-hand network)
@ PARTRIGHT
The link is a partial right direction.
@ NODIR
The link has no direction (is a dead end link)
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_TL_REDYELLOW
The link has red light (must brake) but indicates upcoming green.
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ LINKSTATE_MAJOR
This is an uncontrolled, major link, may pass.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_TL_YELLOW_MAJOR
The link has yellow light, may pass.
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_DEADEND
This is a dead end link.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
@ LINKSTATE_TL_YELLOW_MINOR
The link has yellow light, has to brake anyway.
@ LINKSTATE_TL_RED
The link has red light (must brake)
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
const double SUMO_const_laneWidth
Definition StdDefs.h:48
T MIN2(T a, T b)
Definition StdDefs.h:76
const double SUMO_const_laneMarkWidth
Definition StdDefs.h:51
T MAX2(T a, T b)
Definition StdDefs.h:82
const double SUMO_const_halfLaneWidth
Definition StdDefs.h:49
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:300
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition GLHelper.cpp:203
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition GLHelper.cpp:421
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:583
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
Definition GLHelper.cpp:558
static void drawTextAtEnd(const std::string &text, const PositionVector &shape, double x, const GUIVisualizationTextSettings &settings, const double scale)
draw text and the end of shape
Definition GLHelper.cpp:767
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition GLHelper.cpp:329
static void drawCrossTies(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double length, double spacing, double halfWidth, bool drawForSelection)
draw crossties for railroads or pedestrian crossings
Definition GLHelper.cpp:785
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:277
static void debugVertices(const PositionVector &shape, const GUIVisualizationTextSettings &settings, double scale, double layer=1024)
draw vertex numbers for the given shape (in a random color)
Definition GLHelper.cpp:883
static void popName()
pop Name
Definition GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
static void drawInverseMarkings(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double maxLength, double spacing, double halfWidth, bool cl, bool cr, bool lefthand, double scale)
@bried draw the space between markings (in road color)
Definition GLHelper.cpp:830
A MSVehicle extended by some values for usage within the gui.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
A road/street connecting two junctions (gui-version)
Definition GUIEdge.h:51
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition GUIEdge.cpp:579
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Representation of a lane in the micro simulation (gui-version)
Definition GUILane.h:60
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterway
Definition GUILane.cpp:1505
void debugDrawFoeIntersections() const
draw intersection positions of foe internal lanes with this one
Definition GUILane.cpp:934
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition GUILane.h:354
std::vector< MSParkingArea * > * myParkingAreas
list of parkingAreas on this lane
Definition GUILane.h:376
const VehCont & getVehiclesSecure() const override
Returns the vehicles container; locks it for microsimulation.
Definition GUILane.cpp:154
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition GUILane.h:397
bool isLaneOrEdgeSelected() const
whether this lane or its parent edge is selected in the GUI
Definition GUILane.cpp:1575
void initRotations(const PositionVector &shape, std::vector< double > &rotations, std::vector< double > &lengths, std::vector< RGBColor > &colors)
Definition GUILane.cpp:114
double myHalfLaneWidth
Half of lane width, for speed-up.
Definition GUILane.h:367
PositionVector splitAtSegments(const PositionVector &shape)
add intermediate points at segment borders
Definition GUILane.cpp:1542
std::vector< int > myShapeSegments
the meso segment index for each geometry segment
Definition GUILane.h:362
double firstWaitingTime() const
Definition GUILane.cpp:1084
double setPartialOccupation(MSVehicle *v) override
Sets the information about a vehicle lapping into this lane.
Definition GUILane.cpp:222
double myQuarterLaneWidth
Quarter of lane width, for speed-up.
Definition GUILane.h:370
void drawTLSLinkNo(const GUIVisualizationSettings &s, const GUINet &net) const
Definition GUILane.cpp:264
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUILane.cpp:1135
double getPendingEmits() const
get number of vehicles waiting for departure on this lane
Definition GUILane.cpp:1580
void drawLinkNo(const GUIVisualizationSettings &s) const
helper methods
Definition GUILane.cpp:237
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUILane.cpp:959
static GUIVisualizationSettings * myCachedGUISettings
cached for tracking color value
Definition GUILane.h:393
void drawJunctionChangeProhibitions() const
bike lane markings on top of an intersection
Definition GUILane.cpp:841
static const RGBColor MESO_USE_LANE_COLOR
special color to signify alternative coloring scheme
Definition GUILane.h:400
std::vector< double > myShapeLengths2
Definition GUILane.h:355
MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify) override
Definition GUILane.cpp:187
bool setMultiColor(const GUIVisualizationSettings &s, const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function
Definition GUILane.cpp:1204
void addSecondaryShape(const PositionVector &shape) override
Definition GUILane.cpp:135
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme, bool s2) const
gets the scaling value according to the current scheme index
Definition GUILane.cpp:1426
void resetPartialOccupation(MSVehicle *v) override
Removes the information about a vehicle lapping into this lane.
Definition GUILane.cpp:229
void integrateNewVehicles() override
Definition GUILane.cpp:208
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUILane.cpp:525
void drawArrows(bool secondaryShape) const
Definition GUILane.cpp:431
std::vector< int > mySegmentStartIndex
the shape indices where the meso segment changes (for segmentsIndex > 0)
Definition GUILane.h:364
void drawLinkRules(const GUIVisualizationSettings &s, const GUINet &net) const
Definition GUILane.cpp:303
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GUILane.h:358
bool neighLaneNotBidi() const
whether any of the neighboring lanes is not a bidi-lane
Definition GUILane.cpp:776
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUILane.cpp:1242
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1526
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition GUILane.cpp:1585
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUILane.cpp:1570
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUILane.cpp:1005
const std::vector< double > & getShapeRotations(bool secondary) const
Definition GUILane.cpp:1066
double getColorValueWithFunctional(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index including values for things that set the c...
Definition GUILane.cpp:1122
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition GUILane.cpp:1499
void removeParking(MSBaseVehicle *veh) override
remove parking vehicle
Definition GUILane.cpp:194
std::vector< double > myShapeRotations2
Definition GUILane.h:351
double myLengthGeometryFactor2
Definition GUILane.h:390
void planMovements(const SUMOTime t) override
Definition GUILane.cpp:167
double getColorValueForTracker() const
return color value based on cached settings
Definition GUILane.cpp:1230
std::vector< RGBColor > myShapeColors2
Definition GUILane.h:359
double getEdgeLaneNumber() const
Definition GUILane.cpp:1090
double myReachability
the time distance from a particular edge
Definition GUILane.h:373
double getLoadedEdgeWeight() const
Returns the loaded weight (effort) for the edge of this lane.
Definition GUILane.cpp:1109
std::vector< double > myShapeRotations
The rotations of the shape parts.
Definition GUILane.h:350
TesselatedPolygon * myTesselation
An object that stores the tesselation.
Definition GUILane.h:379
void setJunctionApproaches(const SUMOTime t) const override
Definition GUILane.cpp:173
void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED) override
Inserts the vehicle into this lane, and informs it about entering the network.
Definition GUILane.cpp:144
~GUILane()
Destructor.
Definition GUILane.cpp:103
const PositionVector & getShape(bool secondary) const override
Definition GUILane.cpp:1060
GUILane(const std::string &id, double maxSpeed, double friction, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type)
Constructor.
Definition GUILane.cpp:74
void drawLinkRule(const GUIVisualizationSettings &s, const GUINet &net, const MSLink *link, const PositionVector &shape, double x1, double x2) const
Definition GUILane.cpp:358
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUILane.cpp:1048
std::vector< RGBColor > & getShapeColors(bool secondary) const
Definition GUILane.cpp:1078
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition GUILane.cpp:1152
double getStoredEdgeTravelTime() const
Returns the stored traveltime for the edge of this lane.
Definition GUILane.cpp:1096
const std::vector< double > & getShapeLengths(bool secondary) const
Definition GUILane.cpp:1072
void drawMarkings(const GUIVisualizationSettings &s, double scale) const
draw lane borders and white markings
Definition GUILane.cpp:789
void drawBikeMarkings() const
bike lane markings on top of an intersection
Definition GUILane.cpp:812
void executeMovements(const SUMOTime t) override
Definition GUILane.cpp:180
PositionVector myShape2
secondary shape for visualization
Definition GUILane.h:389
bool myAmClosed
state for dynamic lane closings
Definition GUILane.h:386
void drawLane2LaneConnections(double exaggeration, bool s2) const
Definition GUILane.cpp:498
void releaseVehicles() const override
Allows to use the container for microsimulation again.
Definition GUILane.cpp:161
void drawDirectionIndicators(double exaggeration, bool spreadSuperposed, bool s2) const
direction indicators for lanes
Definition GUILane.cpp:906
void detectCollisions(SUMOTime timestep, const std::string &stage) override
Definition GUILane.cpp:215
void swapAfterLaneChange(SUMOTime t) override
moves myTmpVehicles int myVehicles after a lane change procedure
Definition GUILane.cpp:201
A MSNet extended by some values for usage within the gui.
Definition GUINet.h:82
int getLinkTLID(const MSLink *const link) const
Definition GUINet.cpp:197
double getMeanData(const MSLane *lane, const std::string &id, const std::string &attr)
retrieve live lane/edge weight for the given meanData id and attribute
Definition GUINet.cpp:621
int getLinkTLIndex(const MSLink *const link) const
Definition GUINet.cpp:212
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition GUINet.cpp:571
double getEdgeData(const MSEdge *edge, const std::string &attr)
retrieve loaded edged weight for the given attribute and the current simulation time
Definition GUINet.cpp:604
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void checkFont(const std::string &text)
ensure that the font covers the given text
T getColor(const double value) const
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
GUIVisualizationSettings * editVisualisationSettings() const
edit visualization settings (allow modify VisualizationSetings, use carefully)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A MSVehicle extended by some values for usage within the gui.
Definition GUIVehicle.h:51
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings vehicleSize
GUIVisualizationSizeSettings junctionSize
bool showBikeMarkings
Information whether bicycle lane marking shall be drawn.
std::string edgeDataID
id for coloring by live edgeData
GUIScaler laneScaler
The lane scaler.
bool showLinkRules
Information whether link rules (colored bars) shall be drawn.
bool drawJunctionShape
whether the shape of the junction should be drawn
std::string edgeData
key for coloring by edgeData
GUIVisualizationTextSettings geometryIndices
bool realisticLinkRules
Information whether link rules (colored bars) shall be drawn with a realistic color scheme.
GUIVisualizationTextSettings drawLinkJunctionIndex
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
bool showRails
Information whether rails shall be drawn.
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
bool showLane2Lane
Information whether lane-to-lane arrows shall be drawn.
bool showSublanes
Whether to show sublane boundaries.
static const RGBColor & getLinkColor(const LinkState &ls, bool realistic=false)
map from LinkState to color constants
double scale
information about a lane's width (temporary, used for a single view)
bool showLaneDirection
Whether to show direction indicators for lanes.
bool secondaryShape
whether secondary lane shape shall be drawn
GUIScaler edgeScaler
The mesoscopic edge scaler.
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
GUIColorer laneColorer
The lane colorer.
bool laneShowBorders
Information whether lane borders shall be drawn.
double laneMinSize
The minimum visual lane width for drawing.
GUIVisualizationTextSettings drawLinkTLIndex
bool drawCrossingsAndWalkingareas
whether crosings and walkingareas shall be drawn
bool spreadSuperposed
Whether to improve visualisation of superposed (rail) edges.
std::string edgeParam
key for coloring by edge parameter
std::string edgeDataScaling
key for scaling by edgeData
static double naviDegree(const double angle)
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length)
Definition MELoop.cpp:278
The base class for microscopic and mesoscopic vehicles.
A road/street connecting two junctions.
Definition MSEdge.h:77
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition MSEdge.h:270
int getPriority() const
Returns the priority of the edge.
Definition MSEdge.h:325
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:622
const std::string & getStreetName() const
Returns the street name of the edge.
Definition MSEdge.h:310
bool isWalkingArea() const
return whether this edge is walking area
Definition MSEdge.h:284
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
void rebuildAllowedLanes(const bool onInit=false)
Definition MSEdge.cpp:300
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition MSEdge.h:279
const MSJunction * getToJunction() const
Definition MSEdge.h:415
bool isTazConnector() const
Definition MSEdge.h:288
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:265
int getNumericalID() const
Returns the numerical id of the edge.
Definition MSEdge.h:303
double getTimePenalty() const
Definition MSEdge.h:483
const std::string & getEdgeType() const
Returns the type of the edge.
Definition MSEdge.h:316
const MSEdgeVector & getPredecessors() const
Definition MSEdge.h:406
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition MSEdge.cpp:939
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1156
double getDistance() const
Returns the kilometrage/mileage encoding at the start of the edge (negative values encode descending ...
Definition MSEdge.h:332
A storage for edge travel times and efforts.
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
static bool gUseMesoSim
Definition MSGlobals.h:103
static bool gCheckRoutes
Definition MSGlobals.h:88
static double gLateralResolution
Definition MSGlobals.h:97
static int gNumSimThreads
how many threads to use for simulation
Definition MSGlobals.h:143
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition MSGlobals.h:169
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
SumoXMLNodeType getType() const
return the type of this Junction
Definition MSJunction.h:135
const PositionVector & getShape() const
Returns this junction's shape.
Definition MSJunction.h:93
Representation of a lane in the micro simulation.
Definition MSLane.h:84
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition MSLane.h:1479
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition MSLane.cpp:1490
std::set< const MSBaseVehicle * > myParkingVehicles
Definition MSLane.h:1457
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition MSLane.cpp:2653
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition MSLane.cpp:3472
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition MSLane.cpp:2402
double myLength
Lane length [m].
Definition MSLane.h:1460
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition MSLane.cpp:3194
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition MSLane.cpp:2635
PositionVector myShape
The shape of the lane.
Definition MSLane.h:1408
std::map< long long, SVCPermissions > myPermissionChanges
Definition MSLane.h:1556
double getFrictionCoefficient() const
Returns the lane's friction coefficient.
Definition MSLane.h:586
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition MSLane.cpp:413
MSEdge *const myEdge
The lane's edge, for routing only.
Definition MSLane.h:1471
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:910
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition MSLane.h:1474
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition MSLane.cpp:2560
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:1450
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition MSLane.h:1424
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition MSLane.h:579
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition MSLane.h:119
MSLane * myBidiLane
Definition MSLane.h:1553
void resetPermissions(long long transientID)
Definition MSLane.cpp:4311
const std::string myLaneType
the type of this lane
Definition MSLane.h:1539
int myRNGIndex
Definition MSLane.h:1559
double getLength() const
Returns the lane's length.
Definition MSLane.h:593
const PositionVector & getShape() const
Returns this lane's shape.
Definition MSLane.h:524
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition MSLane.cpp:2621
StopOffset myLaneStopOffset
Definition MSLane.h:1468
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition MSLane.cpp:342
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition MSLane.cpp:4299
const double myWidth
Lane width [m].
Definition MSLane.h:1463
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition MSLane.cpp:2142
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition MSLane.cpp:2999
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition MSLane.cpp:3179
int myIndex
The lane index.
Definition MSLane.h:1411
bool isCrossing() const
Definition MSLane.cpp:2468
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition MSLane.cpp:1551
std::vector< MSLink * > myLinks
Definition MSLane.h:1517
bool isInternal() const
Definition MSLane.cpp:2456
static const long CHANGE_PERMISSIONS_GUI
Definition MSLane.h:1335
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition MSLane.h:557
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition MSLane.cpp:361
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition MSLane.cpp:3268
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition MSLane.cpp:4425
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition MSLane.h:529
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:293
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:745
double getWidth() const
Returns the lane's width.
Definition MSLane.h:622
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition MSLane.h:707
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition MSLane.cpp:3222
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:551
Notification
Definition of a vehicle state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:183
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
Definition MSNet.cpp:352
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition MSNet.cpp:1195
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:433
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1386
A lane area vehicles can halt at.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
const std::string & getID() const
Returns the id.
Definition Named.h:74
static OptionsCont & getOptions()
Retrieves the options.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:254
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition Position.h:244
double x() const
Returns the x-position.
Definition Position.h:55
double z() const
Returns the z-position.
Definition Position.h:65
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0, double deg=90) const
return orthogonal through p (extending this vector if necessary)
int indexOfClosest(const Position &p, bool twoD=false) const
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
int insertAtClosest(const Position &p, bool interpolateZ)
inserts p between the two closest positions
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
PositionVector reverse() const
reverse position vector
unsigned char red() const
Returns the red-amount of the color.
Definition RGBColor.cpp:74
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition RGBColor.cpp:92
static SumoRNG * getColorRNG()
get color RNG
Definition RGBColor.cpp:194
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition RGBColor.cpp:239
unsigned char green() const
Returns the green-amount of the color.
Definition RGBColor.cpp:80
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition RGBColor.cpp:371
unsigned char blue() const
Returns the blue-amount of the color.
Definition RGBColor.cpp:86
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
static const RGBColor MAGENTA
Definition RGBColor.h:190
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
bool isDefined() const
check if stopOffset was defined
SVCPermissions getPermissions() const
get permissions
double getOffset() const
get offset
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
void drawTesselation(const PositionVector &shape) const
perform the tesselation / drawing
static FXIcon * getVClassIcon(const SUMOVehicleClass vc)
returns icon associated to the given vClass
static const RGBColor SUMO_color_DEADEND_SHOW
color for highlighthing deadends
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double exaggeration
The size exaggeration (upscale)
bool constantSize
whether the object shall be drawn with constant size regardless of zoom
double minSize
The minimum size to draw this object.
bool show(const GUIGlObject *o) const
whether to show the text