Eclipse SUMO - Simulation of Urban MObility
GUIEdge.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/****************************************************************************/
21// A road/street connecting two junctions (gui-version)
22/****************************************************************************/
23#include <config.h>
24
25#include <vector>
26#include <cmath>
27#include <string>
28#include <algorithm>
39#include <microsim/MSEdge.h>
40#include <microsim/MSJunction.h>
43#include <microsim/MSGlobals.h>
49#include <mesosim/MESegment.h>
50#include <mesosim/MELoop.h>
51#include <mesosim/MEVehicle.h>
52
54#include "GUIEdge.h"
55#include "GUIVehicle.h"
56#include "GUINet.h"
57#include "GUILane.h"
58#include "GUIPerson.h"
59#include "GUIContainer.h"
60
61
62GUIEdge::GUIEdge(const std::string& id, int numericalID,
63 const SumoXMLEdgeFunc function,
64 const std::string& streetName, const std::string& edgeType, int priority,
65 double distance) :
66 MSEdge(id, numericalID, function, streetName, edgeType, priority, distance),
68 myLock(true)
69{}
70
71
73 // just to quit cleanly on a failure
74 if (myLock.locked()) {
75 myLock.unlock();
76 }
77}
78
79void
82 bool hasNormalSuccessors = false;
83 for (const MSEdge* out : getSuccessors()) {
84 if (!out->isTazConnector()) {
85 hasNormalSuccessors = true;
86 break;
87 }
88 }
89 myShowDeadEnd = (!isTazConnector() && !hasNormalSuccessors && getToJunction()->getOutgoing().size() > 0
90 && (getPermissions() & ~SVC_PEDESTRIAN) != 0
91 && (getToJunction()->getOutgoing().size() > 1 ||
92 getToJunction()->getOutgoing().front()->getToJunction() != getFromJunction()));
93}
94
95MSLane&
96GUIEdge::getLane(int laneNo) {
97 assert(laneNo < (int)myLanes->size());
98 return *((*myLanes)[laneNo]);
99}
100
101
102std::vector<GUIGlID>
103GUIEdge::getIDs(bool includeInternal) {
104 std::vector<GUIGlID> ret;
105 ret.reserve(MSEdge::myDict.size());
106 for (MSEdge::DictType::const_iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) {
107 const GUIEdge* edge = dynamic_cast<const GUIEdge*>(i->second);
108 assert(edge);
109 if (includeInternal || edge->isNormal()) {
110 ret.push_back(edge->getGlID());
111 }
112 }
113 return ret;
114}
115
116
117double
118GUIEdge::getTotalLength(bool includeInternal, bool eachLane) {
119 double result = 0;
120 for (MSEdge::DictType::const_iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) {
121 const MSEdge* edge = i->second;
122 if (includeInternal || !edge->isInternal()) {
123 // @note needs to be change once lanes may have different length
124 result += edge->getLength() * (eachLane ? (double)edge->getLanes().size() : 1.);
125 }
126 }
127 return result;
128}
129
130
133 Boundary ret;
134 if (!isTazConnector()) {
135 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
136 ret.add((*i)->getShape().getBoxBoundary());
137 }
138 } else {
139 // take the starting coordinates of all follower edges and the endpoints
140 // of all successor edges
141 for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
142 const std::vector<MSLane*>& lanes = (*it)->getLanes();
143 for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
144 ret.add((*it_lane)->getShape().front());
145 }
146 }
147 for (MSEdgeVector::const_iterator it = myPredecessors.begin(); it != myPredecessors.end(); ++it) {
148 const std::vector<MSLane*>& lanes = (*it)->getLanes();
149 for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
150 ret.add((*it_lane)->getShape().back());
151 }
152 }
153 }
154 ret.grow(10);
155 return ret;
156}
157
158
161 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
162 buildPopupHeader(ret, app);
169 }
171 GUIDesigns::buildFXMenuCommand(ret, "segment: " + toString(segment->getIndex()), nullptr, nullptr, 0);
172 buildPositionCopyEntry(ret, app);
173 return ret;
174}
175
176
179 GUISUMOAbstractView& parent) {
180 GUIParameterTableWindow* ret = nullptr;
181 ret = new GUIParameterTableWindow(app, *this);
182 // add edge items
183 ret->mkItem("maxspeed [m/s]", false, getAllowedSpeed());
184 ret->mkItem("length [m]", false, (*myLanes)[0]->getLength());
185 ret->mkItem("street name", false, getStreetName());
186 ret->mkItem("pending insertions [#]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getPendingEmits));
187 ret->mkItem("mean friction [%]", true, new FunctionBinding<GUIEdge, double>(this, &MSEdge::getMeanFriction, 100.));
188 ret->mkItem("mean vehicle speed [m/s]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getMeanSpeed));
189 ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getRoutingSpeed));
190 ret->mkItem("time penalty [s]", true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getTimePenalty));
191 ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getBruttoOccupancy, 100.));
192 ret->mkItem("flow [veh/h/lane]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getFlow));
194 // add segment items
196 ret->mkItem("segment index", false, segment->getIndex());
197 ret->mkItem("segment queues", false, segment->numQueues());
198 ret->mkItem("segment length [m]", false, segment->getLength());
199 ret->mkItem("segment allowed speed [m/s]", false, segment->getEdge().getSpeedLimit());
200 ret->mkItem("segment jam threshold [%]", false, segment->getRelativeJamThreshold() * 100);
201 ret->mkItem("segment brutto occupancy [%]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getRelativeOccupancy, 100));
202 ret->mkItem("segment mean vehicle speed [m/s]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getMeanSpeed));
203 ret->mkItem("segment flow [veh/h/lane]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getFlow));
204 ret->mkItem("segment #vehicles", true, new CastingFunctionBinding<MESegment, int, int>(segment, &MESegment::getCarNumber));
205 ret->mkItem("segment leader leave time", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEventTimeSeconds));
206 ret->mkItem("segment headway [s]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getLastHeadwaySeconds));
207 ret->mkItem("segment entry blocktime [s]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEntryBlockTimeSeconds));
208 // lane params
209 for (MSLane* lane : *myLanes) {
210 for (const auto& kv : lane->getParametersMap()) {
211 ret->mkItem(("laneParam " + toString(lane->getIndex()) + ":" + kv.first).c_str(), false, kv.second);
212 }
213 }
214 // close building
215 ret->closeBuilding();
216 return ret;
217}
218
224 // add items
225 ret->mkItem("Type Information:", false, "");
226 ret->mkItem("type [id]", false, getEdgeType());
227 ret->mkItem("tauff", false, STEPS2TIME(edgeType.tauff));
228 ret->mkItem("taufj", false, STEPS2TIME(edgeType.taufj));
229 ret->mkItem("taujf", false, STEPS2TIME(edgeType.taujf));
230 ret->mkItem("taujj", false, STEPS2TIME(edgeType.taujj));
231 ret->mkItem("jam threshold", false, edgeType.jamThreshold);
232 ret->mkItem("junction control", false, edgeType.junctionControl);
233 ret->mkItem("tls penalty", false, edgeType.tlsPenalty);
234 ret->mkItem("tls flow penalty", false, edgeType.tlsFlowPenalty);
235 ret->mkItem("minor penalty", false, STEPS2TIME(edgeType.minorPenalty));
236 ret->mkItem("overtaking", false, edgeType.overtaking);
237 // close building
238 ret->closeBuilding();
239 return ret;
240}
241
242
245 Boundary b = getBoundary();
246 // ensure that vehicles and persons on the side are drawn even if the edge
247 // is outside the view
248 b.grow(10);
249 return b;
250}
251
252const std::string
254 return myStreetName;
255}
256
257void
260 return;
261 }
263 // draw the lanes
265 setColor(s);
266 }
267 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
268 static_cast<GUILane*>(*i)->drawGL(s);
269 }
271 if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
273 }
274 }
276 // (optionally) draw the name and/or the street name
277 GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back());
278 const GUIGlObject* selCheck = gSelected.isSelected(this) ? (GUIGlObject*)this : (GUIGlObject*)lane2;
279 const bool drawEdgeName = s.edgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::NORMAL;
280 const bool drawInternalEdgeName = s.internalEdgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::INTERNAL;
281 const bool drawCwaEdgeName = s.cwaEdgeName.show(selCheck) && (myFunction == SumoXMLEdgeFunc::CROSSING || myFunction == SumoXMLEdgeFunc::WALKINGAREA);
282 const bool drawStreetName = s.streetName.show(selCheck) && myStreetName != "";
283 const bool drawEdgeValue = s.edgeValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
286 const bool drawEdgeScaleValue = s.edgeScaleValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
289 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName || drawEdgeValue || drawEdgeScaleValue) {
290 GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]);
291 if (lane1 != nullptr && lane2 != nullptr) {
292 const bool s2 = s.secondaryShape;
293 const bool spreadSuperposed = s.spreadSuperposed && getBidiEdge() != nullptr;
294 Position p = lane1->getShape(s2).positionAtOffset(lane1->getShape(s2).length() / (double) 2.);
295 p.add(lane2->getShape(s2).positionAtOffset(lane2->getShape(s2).length() / (double) 2.));
296 p.mul(.5);
297 if (spreadSuperposed) {
298 // move name to the right of the edge and towards its beginning
299 const double dist = 0.6 * s.edgeName.scaledSize(s.scale);
300 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(135);
301 Position shift(dist * cos(shiftA), dist * sin(shiftA));
302 p.add(shift);
303 }
304 double angle = s.getTextAngle(lane1->getShape(s2).rotationDegreeAtOffset(lane1->getShape(s2).length() / (double) 2.) + 90);
305 if (drawEdgeName) {
306 drawName(p, s.scale, s.edgeName, angle, true);
307 } else if (drawInternalEdgeName) {
308 drawName(p, s.scale, s.internalEdgeName, angle, true);
309 } else if (drawCwaEdgeName) {
310 drawName(p, s.scale, s.cwaEdgeName, angle, true);
311 }
312 if (drawStreetName) {
314 }
315 if (drawEdgeValue) {
316 const int activeScheme = s.getLaneEdgeMode();
317 std::string value = "";
318 if (activeScheme == 31) {
319 // edge param, could be non-numerical
320 value = getParameter(s.edgeParam, "");
321 } else if (activeScheme == 32) {
322 // lane param, could be non-numerical
323 value = lane2->getParameter(s.laneParam, "");
324 } else {
325 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
326 const double doubleValue = (MSGlobals::gUseMesoSim
327 ? getColorValue(s, activeScheme)
328 : lane2->getColorValueWithFunctional(s, activeScheme));
329 const RGBColor color = (MSGlobals::gUseMesoSim ? s.edgeColorer : s.laneColorer).getScheme().getColor(doubleValue);
330 if (doubleValue != s.MISSING_DATA
331 && color.alpha() != 0
332 && (!s.edgeValueHideCheck || doubleValue > s.edgeValueHideThreshold)
333 && (!s.edgeValueHideCheck2 || doubleValue < s.edgeValueHideThreshold2)
334 ) {
335 value = toString(doubleValue);
336 }
337 }
338 if (value != "") {
339 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName) {
340 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeValue.scaledSize(s.scale));
341 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
342 Position shift(dist * cos(shiftA), dist * sin(shiftA));
343 p.add(shift);
344 }
345 GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, angle);
346 }
347 }
348 if (drawEdgeScaleValue) {
349 const int activeScheme = s.getLaneEdgeScaleMode();
350 std::string value = "";
351 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
352 const double doubleValue = (MSGlobals::gUseMesoSim
353 ? getScaleValue(s, activeScheme)
354 : lane2->getScaleValue(s, activeScheme, s2));
355 if (doubleValue != s.MISSING_DATA) {
356 value = toString(doubleValue);
357 }
358 if (value != "") {
359 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawEdgeValue) {
360 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeScaleValue.scaledSize(s.scale));
361 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
362 Position shift(dist * cos(shiftA), dist * sin(shiftA));
363 p.add(shift);
364 }
365 GLHelper::drawTextSettings(s.edgeScaleValue, value, p, s.scale, angle);
366 }
367 }
368 }
369 }
370 if (s.scale * s.personSize.getExaggeration(s, nullptr) > s.personSize.minSize) {
371 FXMutexLock locker(myLock);
372 for (MSTransportable* t : myPersons) {
373 GUIPerson* person = dynamic_cast<GUIPerson*>(t);
374 assert(person != 0);
375 person->drawGL(s);
376 }
377 }
378 if (s.scale * s.containerSize.getExaggeration(s, nullptr) > s.containerSize.minSize) {
379 FXMutexLock locker(myLock);
380 for (MSTransportable* t : myContainers) {
381 GUIContainer* container = dynamic_cast<GUIContainer*>(t);
382 assert(container != 0);
383 container->drawGL(s);
384 }
385 }
386}
387
388
389void
392 const double now = SIMTIME;
393 if (vehicleControl != nullptr) {
394 // draw the meso vehicles
395 vehicleControl->secureVehicles();
396 FXMutexLock locker(myLock);
397 int laneIndex = 0;
398 for (std::vector<MSLane*>::const_iterator msl = myLanes->begin(); msl != myLanes->end(); ++msl, ++laneIndex) {
399 GUILane* l = static_cast<GUILane*>(*msl);
400 // go through the vehicles
401 double segmentOffset = 0; // offset at start of current segment
402 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
403 segment != nullptr; segment = segment->getNextSegment()) {
404 const double length = segment->getLength();
405 if (laneIndex < segment->numQueues()) {
406 // make a copy so we don't have to worry about synchronization
407 std::vector<MEVehicle*> queue = segment->getQueue(laneIndex);
408 const int queueSize = (int)queue.size();
409 double vehiclePosition = segmentOffset + length;
410 // draw vehicles beginning with the leader at the end of the segment
411 double latOff = 0.;
412 for (int i = 0; i < queueSize; ++i) {
413 const GUIMEVehicle* const veh = static_cast<GUIMEVehicle*>(queue[queueSize - i - 1]);
414 const double intendedLeave = MIN2(veh->getEventTimeSeconds(), veh->getBlockTimeSeconds());
415 const double entry = veh->getLastEntryTimeSeconds();
416 const double relPos = segmentOffset + length * (now - entry) / (intendedLeave - entry);
417 if (relPos < vehiclePosition) {
418 vehiclePosition = relPos;
419 }
420 while (vehiclePosition < segmentOffset) {
421 // if there is only a single queue for a
422 // multi-lane edge shift vehicles and start
423 // drawing again from the end of the segment
424 vehiclePosition += length;
425 latOff += 0.2;
426 }
428 const Position p = l->geometryPositionAtOffset(vehiclePosition, latOff);
429 const double angle = l->getShape(s.secondaryShape).rotationAtOffset(l->interpolateLanePosToGeometryPos(vehiclePosition));
430 veh->drawOnPos(s, p, angle);
431 vehiclePosition -= veh->getVehicleType().getLengthWithGap();
432 }
433 }
434 segmentOffset += length;
435 }
437 }
438 vehicleControl->releaseVehicles();
439 }
440}
441
442
443
444double
446 return (*myLanes)[0]->getSpeedLimit();
447}
448
449
450double
452 return getMeanSpeed() / getAllowedSpeed();
453}
454
455
456void
458 myMesoColor = RGBColor(0, 0, 0); // default background color when using multiColor
459 const GUIColorer& c = s.edgeColorer;
460 if (!setFunctionalColor(c) && !setMultiColor(c)) {
462 }
463}
464
465
466bool
468 const int activeScheme = c.getActive();
469 int activeMicroScheme = -1;
470 switch (activeScheme) {
471 case 0:
472 activeMicroScheme = 0; // color uniform
473 break;
474 case 9:
475 activeMicroScheme = 18; // color by angle
476 break;
477 case 17:
478 activeMicroScheme = 30; // color by TAZ
479 break;
480 default:
481 return false;
482 }
483 GUILane* guiLane = static_cast<GUILane*>(getLanes()[0]);
484 return guiLane->setFunctionalColor(c, myMesoColor, activeMicroScheme);
485}
486
487
488bool
490 const int activeScheme = c.getActive();
491 mySegmentColors.clear();
492 switch (activeScheme) {
493 case 10: // alternating segments
494 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
495 segment != nullptr; segment = segment->getNextSegment()) {
496 mySegmentColors.push_back(c.getScheme().getColor(segment->getIndex() % 2));
497 }
498 //std::cout << getID() << " scheme=" << c.getScheme().getName() << " schemeCols=" << c.getScheme().getColors().size() << " thresh=" << toString(c.getScheme().getThresholds()) << " segmentColors=" << mySegmentColors.size() << " [0]=" << mySegmentColors[0] << " [1]=" << mySegmentColors[1] << "\n";
499 return true;
500 case 11: // by segment jammed state
501 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
502 segment != nullptr; segment = segment->getNextSegment()) {
503 mySegmentColors.push_back(
504 c.getScheme().getColor(segment->getRelativeOccupancy() > segment->getRelativeJamThreshold() ? 2 :
505 (segment->getRelativeOccupancy() * 2 < segment->getRelativeJamThreshold() ? 0 : 1)));
506 }
507 return true;
508 case 12: // by segment occupancy
509 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
510 segment != nullptr; segment = segment->getNextSegment()) {
511 mySegmentColors.push_back(c.getScheme().getColor(segment->getRelativeOccupancy()));
512 }
513 return true;
514 case 13: // by segment speed
515 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
516 segment != nullptr; segment = segment->getNextSegment()) {
517 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed()));
518 }
519 return true;
520 case 14: // by segment flow
521 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
522 segment != nullptr; segment = segment->getNextSegment()) {
523 mySegmentColors.push_back(c.getScheme().getColor(3600 * segment->getCarNumber() * segment->getMeanSpeed() / segment->getLength()));
524 }
525 return true;
526 case 15: // by segment relative speed
527 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
528 segment != nullptr; segment = segment->getNextSegment()) {
529 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed() / getAllowedSpeed()));
530 }
531 return true;
532 default:
533 return false;
534 }
535}
536
537
538double
539GUIEdge::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
540 switch (activeScheme) {
541 case 1:
542 return gSelected.isSelected(getType(), getGlID());
543 case 2:
544 return (double)getFunction();
545 case 3:
546 return getAllowedSpeed();
547 case 4:
548 return getBruttoOccupancy();
549 case 5:
550 return getMeanSpeed();
551 case 6:
552 return getFlow();
553 case 7:
554 return getRelativeSpeed();
555 case 8:
556 return getRoutingSpeed();
557 case 16:
558 return getPendingEmits();
559 case 18:
560 // by numerical edge param value
561 try {
563 } catch (NumberFormatException&) {
564 try {
566 } catch (BoolFormatException&) {
567 return -1;
568 }
569 }
570 case 19:
571 // by edge data value
573 }
574 return 0;
575}
576
577
578double
579GUIEdge::getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const {
580 switch (activeScheme) {
581 case 1:
582 return gSelected.isSelected(getType(), getGlID());
583 case 2:
584 return getAllowedSpeed();
585 case 3:
586 return getBruttoOccupancy();
587 case 4:
588 return getMeanSpeed();
589 case 5:
590 return getFlow();
591 case 6:
592 return getRelativeSpeed();
593 case 7:
594 return getPendingEmits();
595 case 8:
596 // by edge data value
598 }
599 return 0;
600}
601
602
605 const PositionVector& shape = getLanes()[0]->getShape();
606 const double lanePos = shape.nearest_offset_to_point2D(pos);
607 return MSGlobals::gMesoNet->getSegmentForEdge(*this, lanePos);
608}
609
610
611
612void
614 const std::vector<MSLane*>& lanes = getLanes();
615 const bool isClosed = lane->isClosed();
616 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
617 GUILane* l = dynamic_cast<GUILane*>(*i);
618 if (l->isClosed() == isClosed) {
619 l->closeTraffic(false);
620 }
621 }
623}
624
625
626void
628 MSEdgeVector edges;
629 edges.push_back(this);
630 GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, 0, "",
631 GUINet::getGUIInstance()->getVisualisationSpeedUp());
632
635 ri.end = SUMOTime_MAX;
637 rr->myIntervals.push_back(ri);
638
639 // trigger rerouting for vehicles already on this edge
640 const std::vector<MSLane*>& lanes = getLanes();
641 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
642 const MSLane::VehCont& vehicles = (*i)->getVehiclesSecure();
643 for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
644 if ((*v)->getLane() == (*i)) {
646 } // else: this is the shadow during a continuous lane change
647 }
648 (*i)->releaseVehicles();
649 }
650}
651
652
653bool
656}
657
658double
661}
662
663/****************************************************************************/
@ GLO_EDGE
an edge
GUISelectedStorage gSelected
A global holder of selected objects.
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define DEG2RAD(x)
Definition: GeomHelper.h:35
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
#define SUMOTime_MAX
Definition: SUMOTime.h:34
#define SIMTIME
Definition: SUMOTime.h:62
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
T MIN2(T a, T b)
Definition: StdDefs.h:76
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 pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:716
void drawOnPos(const GUIVisualizationSettings &s, const Position &pos, const double angle) const
Draws the object on the specified position with the specified angle.
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:51
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:244
double getAllowedSpeed() const
Definition: GUIEdge.cpp:445
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:251
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:489
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:457
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:390
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUIEdge.cpp:160
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:539
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:96
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUIEdge.cpp:258
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:451
RGBColor myMesoColor
Definition: GUIEdge.h:253
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:613
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:604
virtual void closeBuilding() override
Has to be called after all edges were built and all connections were set.
Definition: GUIEdge.cpp:80
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:627
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:118
Boundary getBoundary() const
Returns the street's geometry.
Definition: GUIEdge.cpp:132
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:103
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUIEdge.cpp:178
const std::string getOptionalName() const override
Returns the street name.
Definition: GUIEdge.cpp:253
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:233
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:579
bool isSelected() const override
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:654
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition: GUIEdge.cpp:659
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:467
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition: GUIEdge.h:236
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:72
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own type parameter window.
Definition: GUIEdge.cpp:220
GUIEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority, double distance)
Constructor.
Definition: GUIEdge.cpp:62
The popup menu of a globject.
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
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.
Definition: GUIGlObject.h:154
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.
Definition: GUIGlObject.h:102
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:60
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 drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUILane.cpp:525
bool isClosed() const
Definition: GUILane.h:265
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1526
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
const PositionVector & getShape(bool secondary) const override
Definition: GUILane.cpp:1060
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1152
The class responsible for building and deletion of vehicles (gui-version)
void secureVehicles()
lock access to vehicle removal/additions for thread synchronization
void releaseVehicles()
unlock access to vehicle removal/additions for thread synchronization
A MSVehicle extended by some values for usage within the gui.
Definition: GUIMEVehicle.h:52
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
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:598
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 drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUIPerson.cpp:281
T getColor(const double value) const
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.
Reroutes vehicles passing an edge One rerouter can be active on multiple edges. To reduce drawing loa...
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings vehicleSize
GUIVisualizationSizeSettings containerSize
GUIVisualizationTextSettings internalEdgeName
GUIVisualizationTextSettings edgeScaleValue
GUIColorer edgeColorer
The mesoscopic edge colorer.
bool drawJunctionShape
whether the shape of the junction should be drawn
std::string edgeData
key for coloring by edgeData
GUIVisualizationTextSettings edgeValue
bool edgeValueHideCheck2
threshold above which edge data value should not be rendered
GUIVisualizationSizeSettings personSize
GUIVisualizationTextSettings cwaEdgeName
bool hideConnectors
flag to show or hide connectors
int getLaneEdgeMode() const
Returns the number of the active lane (edge) coloring schme.
double scale
information about a lane's width (temporary, used for a single view)
bool edgeValueHideCheck
threshold below which edge data value should not be rendered
bool secondaryShape
whether secondary lane shape shall be drawn
GUIVisualizationTextSettings streetName
int getLaneEdgeScaleMode() const
Returns the number of the active lane (edge) scaling schme.
GUIColorer laneColorer
The lane colorer.
GUIVisualizationTextSettings edgeName
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
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
std::string edgeDataScaling
key for scaling by edgeData
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:325
A single mesoscopic segment (cell)
Definition: MESegment.h:49
double getEntryBlockTimeSeconds() const
get the earliest entry time in seconds
Definition: MESegment.h:386
double getLastHeadwaySeconds() const
get the last headway time in seconds
Definition: MESegment.h:381
double getRelativeOccupancy() const
Returns the relative occupany of the segment (percentage of road used))
Definition: MESegment.h:269
double getLength() const
Returns the length of the segment in meters.
Definition: MESegment.h:242
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:359
int numQueues() const
return the number of queues
Definition: MESegment.h:211
double getRelativeJamThreshold() const
Returns the relative occupany of the segment (percentage of road used)) at which the segment is consi...
Definition: MESegment.h:277
double getEventTimeSeconds() const
Like getEventTime but returns seconds (for visualization)
Definition: MESegment.h:376
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition: MESegment.h:226
double getMeanSpeed() const
wrapper to satisfy the FunctionBinding signature
Definition: MESegment.h:294
int getCarNumber() const
Returns the total number of cars on the segment.
Definition: MESegment.h:206
double getFlow() const
returns flow based on headway
Definition: MESegment.cpp:827
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
Definition: MEVehicle.h:292
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
Definition: MEVehicle.h:297
double getEventTimeSeconds() const
Returns the earliest leave time for the current segment.
Definition: MEVehicle.h:287
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
A road/street connecting two junctions.
Definition: MSEdge.h:77
std::string myStreetName
the real-world name of this edge (need not be unique)
Definition: MSEdge.h:932
double getBruttoOccupancy() const
Definition: MSEdge.cpp:1475
double getFlow() const
return flow based on meanSpead
Definition: MSEdge.cpp:1462
std::set< MSTransportable *, ComparatorNumericalIdLess > myContainers
Containers on the edge.
Definition: MSEdge.h:911
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
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
bool isNormal() const
return whether this edge is an internal edge
Definition: MSEdge.h:260
const SumoXMLEdgeFunc myFunction
the purpose of the edge
Definition: MSEdge.h:879
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
Definition: MSEdge.cpp:1056
MSEdgeVector myPredecessors
The preceeding edges.
Definition: MSEdge.h:901
const MSJunction * getToJunction() const
Definition: MSEdge.h:415
double getLength() const
return the length of the edge
Definition: MSEdge.h:658
virtual void closeBuilding()
Definition: MSEdge.cpp:185
const MSJunction * getFromJunction() const
Definition: MSEdge.h:411
double getMeanSpeed() const
get the mean speed
Definition: MSEdge.cpp:855
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSEdge.h:976
std::set< MSTransportable *, ComparatorNumericalIdLess > myPersons
Persons on the edge for drawing and pushbutton.
Definition: MSEdge.h:908
bool isTazConnector() const
Definition: MSEdge.h:288
MSEdgeVector mySuccessors
The succeeding edges.
Definition: MSEdge.h:896
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:265
double getTimePenalty() const
Definition: MSEdge.h:483
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:316
double getMeanFriction() const
get the mean friction over the lanes
Definition: MSEdge.cpp:896
int getVehicleNumber() const
return total number of vehicles on this edges lanes or segments
Definition: MSEdge.cpp:1398
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
Definition: MSEdge.h:255
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
std::shared_ptr< const std::vector< MSLane * > > myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane,...
Definition: MSEdge.h:873
static bool gUseMesoSim
Definition: MSGlobals.h:103
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:109
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:116
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:119
double getLength() const
Returns the lane's length.
Definition: MSLane.h:593
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:545
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:551
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:322
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:433
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
Definition: MSNet.cpp:366
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
static MSEdge mySpecialDest_keepDestination
special destination values
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
const std::string & getID() const
Returns the id.
Definition: Named.h:74
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:125
void mul(double val)
Multiplies both positions with the given value.
Definition: Position.h:105
A list of positions.
double length() const
Returns the length.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.cpp:92
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
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
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double minSize
The minimum size to draw this object.
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size
edge type specific meso parameters
Definition: MESegment.h:55
SUMOTime begin
The begin time these definitions are valid.
SUMOTime end
The end time these definitions are valid.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.