Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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 <gui/GUIGlobals.h>
41#include <microsim/MSEdge.h>
42#include <microsim/MSJunction.h>
45#include <microsim/MSGlobals.h>
51#include <mesosim/MESegment.h>
52#include <mesosim/MELoop.h>
53#include <mesosim/MEVehicle.h>
54
56#include "GUIEdge.h"
57#include "GUIVehicle.h"
58#include "GUINet.h"
59#include "GUILane.h"
60#include "GUIPerson.h"
61#include "GUIContainer.h"
62
63
64GUIEdge::GUIEdge(const std::string& id, int numericalID,
65 const SumoXMLEdgeFunc function,
66 const std::string& streetName, const std::string& edgeType,
67 const std::string& routingType, int priority,
68 double distance) :
69 MSEdge(id, numericalID, function, streetName, edgeType, routingType, priority, distance),
71 myLock(true)
72{}
73
74
76 // just to quit cleanly on a failure
77 if (myLock.locked()) {
78 myLock.unlock();
79 }
80}
81
82void
85 bool hasNormalSuccessors = false;
86 for (const MSEdge* out : getSuccessors()) {
87 if (!out->isTazConnector()) {
88 hasNormalSuccessors = true;
89 break;
90 }
91 }
92 myShowDeadEnd = (!isTazConnector() && !hasNormalSuccessors && getToJunction()->getOutgoing().size() > 0
93 && (getPermissions() & ~SVC_PEDESTRIAN) != 0
94 && (getToJunction()->getOutgoing().size() > 1 ||
95 getToJunction()->getOutgoing().front()->getToJunction() != getFromJunction()));
96}
97
98MSLane&
99GUIEdge::getLane(int laneNo) {
100 assert(laneNo < (int)myLanes->size());
101 return *((*myLanes)[laneNo]);
102}
103
104
105std::vector<GUIGlID>
106GUIEdge::getIDs(bool includeInternal) {
107 std::vector<GUIGlID> ret;
108 ret.reserve(MSEdge::myDict.size());
109 for (MSEdge::DictType::const_iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) {
110 const GUIEdge* edge = dynamic_cast<const GUIEdge*>(i->second);
111 assert(edge);
112 if (includeInternal || edge->isNormal()) {
113 ret.push_back(edge->getGlID());
114 }
115 }
116 return ret;
117}
118
119
120double
121GUIEdge::getTotalLength(bool includeInternal, bool eachLane) {
122 double result = 0;
123 for (MSEdge::DictType::const_iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) {
124 const MSEdge* edge = i->second;
125 if (includeInternal || !edge->isInternal()) {
126 // @note needs to be change once lanes may have different length
127 result += edge->getLength() * (eachLane ? (double)edge->getLanes().size() : 1.);
128 }
129 }
130 return result;
131}
132
133
136 Boundary ret;
137 const bool s2 = GUIGlobals::gSecondaryShape;
138 if (!isTazConnector()) {
139 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
140 ret.add((*i)->getShape(s2).getBoxBoundary());
141 }
142 } else {
143 // take the starting coordinates of all follower edges and the endpoints
144 // of all successor edges
145 for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
146 const std::vector<MSLane*>& lanes = (*it)->getLanes();
147 for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
148 ret.add((*it_lane)->getShape(s2).front());
149 }
150 }
151 for (MSEdgeVector::const_iterator it = myPredecessors.begin(); it != myPredecessors.end(); ++it) {
152 const std::vector<MSLane*>& lanes = (*it)->getLanes();
153 for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
154 ret.add((*it_lane)->getShape(s2).back());
155 }
156 }
157 }
158 ret.grow(10);
159 return ret;
160}
161
162
165 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
166 buildPopupHeader(ret, app);
171 buildShowParamsPopupEntry(ret, false);
172 // find lane under cursor for building a lane-param menu entry
173 // @note: cannot use getLaneUnderCursor because this returns nullptr in meso
174 GUILane* lane = dynamic_cast<GUILane*>(myLanes->front());
175 const Position pos = parent.getPositionInformation();
176 for (MSLane* l : *myLanes) {
177 GUILane* cand = dynamic_cast<GUILane*>(l);
178 if (cand->getCenter().distanceTo2D(pos) < lane->getCenter().distanceTo2D(pos)) {
179 lane = cand;
180 }
181 }
182 setGLObjectParent(lane);
185 }
187 GUIDesigns::buildFXMenuCommand(ret, "segment: " + toString(segment->getIndex()), nullptr, nullptr, 0);
188 buildPositionCopyEntry(ret, app);
189 return ret;
190}
191
192
195 GUISUMOAbstractView& parent) {
196 GUIParameterTableWindow* ret = nullptr;
197 ret = new GUIParameterTableWindow(app, *this);
198 // add edge items
199 ret->mkItem(TL("max speed [m/s]"), false, getAllowedSpeed());
200 ret->mkItem(TL("length [m]"), false, (*myLanes)[0]->getLength());
201 ret->mkItem(TL("street name"), false, getStreetName());
202 ret->mkItem(TL("pending insertions [#]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getPendingEmits));
203 ret->mkItem(TL("mean friction [%]"), true, new FunctionBinding<GUIEdge, double>(this, &MSEdge::getMeanFriction, 100.));
204 ret->mkItem(TL("mean vehicle speed [m/s]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getMeanSpeed));
205 ret->mkItem(TL("routing speed [m/s]"), true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getRoutingSpeed));
206 ret->mkItem(TL("time penalty [s]"), true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getTimePenalty));
207 ret->mkItem(TL("brutto occupancy [%]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getBruttoOccupancy, 100.));
208 ret->mkItem(TL("edge flow [veh/h/m]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getFlow));
209 ret->mkItem(TL("vehicles [#]"), true, new CastingFunctionBinding<GUIEdge, int, int>(this, &MSEdge::getVehicleNumber));
210 // add segment items
212 ret->mkItem(TL("segment index"), false, segment->getIndex());
213 ret->mkItem(TL("segment queues"), false, segment->numQueues());
214 ret->mkItem(TL("segment length [m]"), false, segment->getLength());
215 ret->mkItem(TL("segment allowed speed [m/s]"), false, segment->getEdge().getSpeedLimit());
216 ret->mkItem(TL("segment jam threshold [%]"), false, segment->getRelativeJamThreshold() * 100);
217 ret->mkItem(TL("segment brutto occupancy [%]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getRelativeOccupancy, 100));
218 ret->mkItem(TL("segment mean vehicle speed [m/s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getMeanSpeed));
219 ret->mkItem(TL("segment flow [veh/h/m]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getFlow));
220 ret->mkItem(TL("segment vehicles [#]"), true, new CastingFunctionBinding<MESegment, int, int>(segment, &MESegment::getCarNumber));
221 ret->mkItem(TL("segment leader leave time"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEventTimeSeconds));
222 ret->mkItem(TL("segment headway [s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getLastHeadwaySeconds));
223 ret->mkItem(TL("segment entry block time [s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEntryBlockTimeSeconds));
224 // lane params
225 for (MSLane* lane : *myLanes) {
226 for (const auto& kv : lane->getParametersMap()) {
227 ret->mkItem(("laneParam " + toString(lane->getIndex()) + ":" + kv.first).c_str(), false, kv.second);
228 }
229 }
230 // close building
231 ret->closeBuilding();
232 return ret;
233}
234
240 // add items
241 ret->mkItem(TL("Type Information:"), false, "");
242 ret->mkItem(TL("type [id]"), false, getEdgeType());
243 ret->mkItem(TL("routing type [id]"), false, getRoutingType());
244 ret->mkItem(TL("tauff"), false, STEPS2TIME(edgeType.tauff));
245 ret->mkItem(TL("taufj"), false, STEPS2TIME(edgeType.taufj));
246 ret->mkItem(TL("taujf"), false, STEPS2TIME(edgeType.taujf));
247 ret->mkItem(TL("taujj"), false, STEPS2TIME(edgeType.taujj));
248 ret->mkItem(TL("jam threshold"), false, edgeType.jamThreshold);
249 ret->mkItem(TL("junction control"), false, edgeType.junctionControl);
250 ret->mkItem(TL("tls penalty"), false, edgeType.tlsPenalty);
251 ret->mkItem(TL("tls flow penalty"), false, edgeType.tlsFlowPenalty);
252 ret->mkItem(TL("minor penalty"), false, STEPS2TIME(edgeType.minorPenalty));
253 ret->mkItem(TL("overtaking"), false, edgeType.overtaking);
254 // close building
255 ret->closeBuilding();
256 return ret;
257}
258
259
262 Boundary b = getBoundary();
263 // ensure that vehicles and persons on the side are drawn even if the edge
264 // is outside the view
265 b.grow(10);
266 return b;
267}
268
269const std::string
271 return myStreetName;
272}
273
274void
277 return;
278 }
280 // draw the lanes
282 setColor(s);
283 }
284 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
285 static_cast<GUILane*>(*i)->drawGL(s);
286 }
288 if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
290 }
291 }
293 // (optionally) draw the name and/or the street name
294 GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back());
295 const GUIGlObject* selCheck = gSelected.isSelected(this) ? (GUIGlObject*)this : (GUIGlObject*)anySelectedLane();
296 const bool drawEdgeName = s.edgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::NORMAL;
297 const bool drawInternalEdgeName = s.internalEdgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::INTERNAL;
298 const bool drawCwaEdgeName = s.cwaEdgeName.show(selCheck) && (myFunction == SumoXMLEdgeFunc::CROSSING || myFunction == SumoXMLEdgeFunc::WALKINGAREA);
299 const bool drawStreetName = s.streetName.show(selCheck) && myStreetName != "";
300 const bool drawEdgeValue = s.edgeValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
303 const bool drawEdgeScaleValue = s.edgeScaleValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
306 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName || drawEdgeValue || drawEdgeScaleValue) {
307 GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]);
308 if (lane1 != nullptr && lane2 != nullptr) {
309 const bool s2 = s.secondaryShape;
310 const bool spreadSuperposed = s.spreadSuperposed && getBidiEdge() != nullptr;
311 Position p = lane1->getShape(s2).positionAtOffset(lane1->getShape(s2).length() / (double) 2.);
312 p.add(lane2->getShape(s2).positionAtOffset(lane2->getShape(s2).length() / (double) 2.));
313 p.mul(.5);
314 if (spreadSuperposed) {
315 // move name to the right of the edge and towards its beginning
316 const double dist = 0.6 * s.edgeName.scaledSize(s.scale);
317 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(135);
318 Position shift(dist * cos(shiftA), dist * sin(shiftA));
319 p.add(shift);
320 }
321 double angle = s.getTextAngle(lane1->getShape(s2).rotationDegreeAtOffset(lane1->getShape(s2).length() / (double) 2.) + 90);
322 if (drawEdgeName) {
323 drawName(p, s.scale, s.edgeName, angle, true);
324 } else if (drawInternalEdgeName) {
325 drawName(p, s.scale, s.internalEdgeName, angle, true);
326 } else if (drawCwaEdgeName) {
327 drawName(p, s.scale, s.cwaEdgeName, angle, true);
328 }
329 if (drawStreetName) {
331 }
332 if (drawEdgeValue) {
333 const int activeScheme = s.getLaneEdgeMode();
334 std::string value = "";
335 if (activeScheme == 31) {
336 // edge param, could be non-numerical
337 value = getParameter(s.edgeParam, "");
338 } else if (activeScheme == 32) {
339 // lane param, could be non-numerical
340 value = lane2->getParameter(s.laneParam, "");
341 } else {
342 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
343 const double doubleValue = (MSGlobals::gUseMesoSim
344 ? getColorValue(s, activeScheme)
345 : lane2->getColorValueWithFunctional(s, activeScheme));
346 const RGBColor color = (MSGlobals::gUseMesoSim ? s.edgeColorer : s.laneColorer).getScheme().getColor(doubleValue);
347 if (doubleValue != s.MISSING_DATA
348 && color.alpha() != 0
349 && (!s.edgeValueRainBow.hideMin || doubleValue > s.edgeValueRainBow.minThreshold)
350 && (!s.edgeValueRainBow.hideMax || doubleValue < s.edgeValueRainBow.maxThreshold)
351 ) {
352 value = toString(doubleValue);
353 }
354 }
355 if (value != "") {
356 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName) {
357 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeValue.scaledSize(s.scale));
358 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
359 Position shift(dist * cos(shiftA), dist * sin(shiftA));
360 p.add(shift);
361 }
362 GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, angle);
363 }
364 }
365 if (drawEdgeScaleValue) {
366 const int activeScheme = s.getLaneEdgeScaleMode();
367 std::string value = "";
368 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
369 const double doubleValue = (MSGlobals::gUseMesoSim
370 ? getScaleValue(s, activeScheme)
371 : lane2->getScaleValue(s, activeScheme, s2));
372 if (doubleValue != s.MISSING_DATA) {
373 value = toString(doubleValue);
374 }
375 if (value != "") {
376 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawEdgeValue) {
377 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeScaleValue.scaledSize(s.scale));
378 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
379 Position shift(dist * cos(shiftA), dist * sin(shiftA));
380 p.add(shift);
381 }
382 GLHelper::drawTextSettings(s.edgeScaleValue, value, p, s.scale, angle);
383 }
384 }
385 }
386 }
387 if (s.scale * s.personSize.getExaggeration(s, nullptr) > s.personSize.minSize) {
388 FXMutexLock locker(myLock);
389 for (MSTransportable* t : myPersons) {
390 GUIPerson* person = dynamic_cast<GUIPerson*>(t);
391 assert(person != 0);
392 person->drawGL(s);
393 }
394 }
395 if (s.scale * s.containerSize.getExaggeration(s, nullptr) > s.containerSize.minSize) {
396 FXMutexLock locker(myLock);
397 for (MSTransportable* t : myContainers) {
398 GUIContainer* container = dynamic_cast<GUIContainer*>(t);
399 assert(container != 0);
400 container->drawGL(s);
401 }
402 }
403}
404
405
406void
409 if (vehicleControl != nullptr) {
410 vehicleControl->secureVehicles();
411 FXMutexLock locker(myLock);
412 for (const auto& item : getMesoPositions()) {
413 const GUIMEVehicle* const veh = static_cast<const GUIMEVehicle*>(item.first);
414 const GUILane* const lane = static_cast<GUILane*>((*myLanes)[veh->getQueIndex()]);
415 assert(this == &veh->getSegment()->getEdge());
416 const Position p = lane->geometryPositionAtOffset(item.second.first, (double)item.second.second * 0.5);
417 const double angle = lane->getShape(s.secondaryShape).rotationAtOffset(lane->interpolateLanePosToGeometryPos(item.second.first));
418 veh->drawOnPos(s, p, angle);
419 }
420 vehicleControl->releaseVehicles();
421 }
422}
423
424
425
426double
428 return (*myLanes)[0]->getSpeedLimit();
429}
430
431
432double
436
437
438void
440 myMesoColor = RGBColor(0, 0, 0); // default background color when using multiColor
441 const GUIColorer& c = s.edgeColorer;
442 mySegmentColors.clear();
443 if (!setFunctionalColor(c) && !setMultiColor(c)) {
445 }
446}
447
448
449bool
451 const int activeScheme = c.getActive();
452 int activeMicroScheme = -1;
453 switch (activeScheme) {
454 case 0:
455 activeMicroScheme = 0; // color uniform
456 break;
457 case 9:
458 activeMicroScheme = 18; // color by angle
459 break;
460 case 17:
461 activeMicroScheme = 30; // color by TAZ
462 break;
463 default:
464 return false;
465 }
466 GUILane* guiLane = static_cast<GUILane*>(getLanes()[0]);
467 return guiLane->setFunctionalColor(c, myMesoColor, activeMicroScheme);
468}
469
470
471bool
473 const int activeScheme = c.getActive();
474 switch (activeScheme) {
475 case 10: // alternating segments
476 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
477 segment != nullptr; segment = segment->getNextSegment()) {
478 mySegmentColors.push_back(c.getScheme().getColor(segment->getIndex() % 2));
479 }
480 //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";
481 return true;
482 case 11: // by segment jammed state
483 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
484 segment != nullptr; segment = segment->getNextSegment()) {
485 mySegmentColors.push_back(
486 c.getScheme().getColor(segment->getRelativeOccupancy() > segment->getRelativeJamThreshold() ? 2 :
487 (segment->getRelativeOccupancy() * 2 < segment->getRelativeJamThreshold() ? 0 : 1)));
488 }
489 return true;
490 case 12: // by segment occupancy
491 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
492 segment != nullptr; segment = segment->getNextSegment()) {
493 mySegmentColors.push_back(c.getScheme().getColor(segment->getRelativeOccupancy()));
494 }
495 return true;
496 case 13: // by segment speed
497 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
498 segment != nullptr; segment = segment->getNextSegment()) {
499 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed()));
500 }
501 return true;
502 case 14: // by segment flow
503 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
504 segment != nullptr; segment = segment->getNextSegment()) {
505 mySegmentColors.push_back(c.getScheme().getColor(3600 * segment->getCarNumber() * segment->getMeanSpeed() / segment->getLength()));
506 }
507 return true;
508 case 15: // by segment relative speed
509 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
510 segment != nullptr; segment = segment->getNextSegment()) {
511 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed() / getAllowedSpeed()));
512 }
513 return true;
514 default:
515 return false;
516 }
517}
518
519
520double
521GUIEdge::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
522 switch (activeScheme) {
523 case 1:
524 return gSelected.isSelected(getType(), getGlID());
525 case 2:
526 return (double)getFunction();
527 case 3:
528 return getAllowedSpeed();
529 case 4:
530 return getBruttoOccupancy();
531 case 5:
532 return getMeanSpeed();
533 case 6:
534 return getFlow();
535 case 7:
536 return getRelativeSpeed();
537 case 8:
538 return getRoutingSpeed();
539 case 16:
540 return getPendingEmits();
541 case 18:
542 // by numerical edge param value
543 try {
545 } catch (NumberFormatException&) {
546 try {
548 } catch (BoolFormatException&) {
549 return -1;
550 }
551 }
552 case 19:
553 // by edge data value
555 }
556 return 0;
557}
558
559
560double
561GUIEdge::getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const {
562 switch (activeScheme) {
563 case 1:
564 return gSelected.isSelected(getType(), getGlID());
565 case 2:
566 return getAllowedSpeed();
567 case 3:
568 return getBruttoOccupancy();
569 case 4:
570 return getMeanSpeed();
571 case 5:
572 return getFlow();
573 case 6:
574 return getRelativeSpeed();
575 case 7:
576 return getPendingEmits();
577 case 8:
578 // by edge data value
580 }
581 return 0;
582}
583
584
587 const PositionVector& shape = getLanes()[0]->getShape();
588 const double lanePos = shape.nearest_offset_to_point2D(pos);
589 return MSGlobals::gMesoNet->getSegmentForEdge(*this, lanePos);
590}
591
592
593
594void
596 const std::vector<MSLane*>& lanes = getLanes();
597 const bool isClosed = lane->isClosed();
598 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
599 GUILane* l = dynamic_cast<GUILane*>(*i);
600 if (l->isClosed() == isClosed) {
601 l->closeTraffic(false);
602 }
603 }
605}
606
607
608void
610 MSEdgeVector edges;
611 edges.push_back(this);
612 GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, false, 0, "", Position::INVALID,
613 std::numeric_limits<double>::max(), GUINet::getGUIInstance()->getVisualisationSpeedUp());
614
617 ri.end = SUMOTime_MAX;
619 rr->myIntervals.push_back(ri);
620
621 // trigger rerouting for vehicles already on this edge
622 const std::vector<MSLane*>& lanes = getLanes();
623 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
624 const MSLane::VehCont& vehicles = (*i)->getVehiclesSecure();
625 for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
626 if ((*v)->getLane() == (*i)) {
628 } // else: this is the shadow during a continuous lane change
629 }
630 (*i)->releaseVehicles();
631 }
632}
633
634
635bool
639
640double
644
645double
648 // do not select edgse in meso mode
649 return INVALID_PRIORITY;
650 }
651 return GLO_EDGE;
652}
653
654
655GUILane*
657 MSLane* result = myLanes->back();
658 for (MSLane* lane : *myLanes) {
659 if (lane->isSelected()) {
660 result = lane;
661 break;
662 }
663 }
664 return dynamic_cast<GUILane*>(result);
665}
666/****************************************************************************/
@ MID_SHOWPARS_PARENT
Show object parent parameter - popup entry.
Definition GUIAppEnum.h:475
@ 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 TL(string)
Definition MsgHandler.h:304
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SUMOTime_MAX
Definition SUMOTime.h:34
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
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:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:140
static void popName()
pop Name
Definition GLHelper.cpp:149
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:773
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, const bool disable=false)
build menu command
A road/street connecting two junctions (gui-version)
Definition GUIEdge.h:51
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition GUIEdge.cpp:646
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUIEdge.cpp:261
double getAllowedSpeed() const
Definition GUIEdge.cpp:427
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition GUIEdge.h:259
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition GUIEdge.cpp:472
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUIEdge.cpp:439
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition GUIEdge.cpp:407
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUIEdge.cpp:164
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUIEdge.cpp:521
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition GUIEdge.cpp:99
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUIEdge.cpp:275
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition GUIEdge.cpp:433
RGBColor myMesoColor
Definition GUIEdge.h:261
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition GUIEdge.cpp:595
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition GUIEdge.cpp:586
virtual void closeBuilding() override
Has to be called after all edges were built and all connections were set.
Definition GUIEdge.cpp:83
GUIEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, const std::string &routingType, int priority, double distance)
Constructor.
Definition GUIEdge.cpp:64
void addRerouter()
add a rerouter
Definition GUIEdge.cpp:609
static double getTotalLength(bool includeInternal, bool eachLane)
Definition GUIEdge.cpp:121
GUILane * anySelectedLane() const
return any selected lane or the last lane if none are selected
Definition GUIEdge.cpp:656
Boundary getBoundary() const
Returns the street's geometry.
Definition GUIEdge.cpp:135
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition GUIEdge.cpp:106
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUIEdge.cpp:194
const std::string getOptionalName() const override
Returns the street name.
Definition GUIEdge.cpp:270
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition GUIEdge.h:236
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition GUIEdge.cpp:561
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUIEdge.cpp:636
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition GUIEdge.cpp:641
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition GUIEdge.cpp:450
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition GUIEdge.h:239
~GUIEdge()
Destructor.
Definition GUIEdge.cpp:75
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own type parameter window.
Definition GUIEdge.cpp:236
The popup menu of a globject.
static const double INVALID_PRIORITY
Definition GUIGlObject.h:74
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app, bool addSeparator=true) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the type parameter window.
void setGLObjectParent(GUIGlObject *parent)
notify object about popup menu removal
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.
virtual Position getCenter() const
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static bool gSecondaryShape
whether secondary shapes are currently being drawn
Definition GUIGlobals.h:49
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
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme, bool s2) const
gets the scaling value according to the current scheme index
Definition GUILane.cpp:1504
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUILane.cpp:546
bool isClosed() const
Definition GUILane.h:268
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1604
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:1191
const PositionVector & getShape(bool secondary) const override
Definition GUILane.cpp:1129
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition GUILane.cpp:1221
The class responsible for building and deletion of vehicles (gui-version)
void secureVehicles() override
lock access to vehicle removal/additions for thread synchronization
void releaseVehicles() override
unlock access to vehicle removal/additions for thread synchronization
A MSVehicle extended by some values for usage within the gui.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition GUINet.cpp:581
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:627
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition GUINet.cpp:621
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.
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
GUIVisualizationSizeSettings personSize
GUIVisualizationTextSettings cwaEdgeName
GUIVisualizationRainbowSettings edgeValueRainBow
checks and thresholds for rainbow coloring
bool hideConnectors
flag to show or hide connectors
int getLaneEdgeMode() const
Returns the number of the active lane (edge) coloring scheme.
double scale
information about a lane's width (temporary, used for a single view)
bool secondaryShape
whether secondary lane shape shall be drawn
GUIVisualizationTextSettings streetName
int getLaneEdgeScaleMode() const
Returns the number of the active lane (edge) scaling scheme.
GUIColorer laneColorer
The lane colorer.
GUIVisualizationTextSettings edgeName
Setting bundles for optional drawing names with size and color.
bool drawCrossingsAndWalkingareas
whether crossings 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:344
A single mesoscopic segment (cell)
Definition MESegment.h:50
double getEntryBlockTimeSeconds() const
get the earliest entry time in seconds
Definition MESegment.h:401
double getLastHeadwaySeconds() const
get the last headway time in seconds
Definition MESegment.h:396
double getRelativeOccupancy() const
Returns the relative occupany of the segment (percentage of road used))
Definition MESegment.h:281
double getLength() const
Returns the length of the segment in meters.
Definition MESegment.h:254
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition MESegment.h:374
int numQueues() const
return the number of queues
Definition MESegment.h:218
double getRelativeJamThreshold() const
Returns the relative occupany of the segment (percentage of road used)) at which the segment is consi...
Definition MESegment.h:289
double getEventTimeSeconds() const
Like getEventTime but returns seconds (for visualization)
Definition MESegment.h:391
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition MESegment.h:238
double getMeanSpeed() const
wrapper to satisfy the FunctionBinding signature
Definition MESegment.h:309
int getCarNumber() const
Returns the total number of cars on the segment.
Definition MESegment.h:213
double getFlow() const
returns flow based on headway
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition MEVehicle.h:246
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition MEVehicle.h:255
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:1009
double getBruttoOccupancy() const
Definition MSEdge.cpp:1658
double getFlow() const
return flow based on meanSpead
Definition MSEdge.cpp:1645
std::set< MSTransportable *, ComparatorNumericalIdLess > myContainers
Containers on the edge.
Definition MSEdge.h:978
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:658
const std::string & getStreetName() const
Returns the street name of the edge.
Definition MSEdge.h:314
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition MSEdge.h:283
bool isNormal() const
return whether this edge is an internal edge
Definition MSEdge.h:264
const SumoXMLEdgeFunc myFunction
the purpose of the edge
Definition MSEdge.h:946
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:1200
MSEdgeVector myPredecessors
The preceeding edges.
Definition MSEdge.h:968
const MSJunction * getToJunction() const
Definition MSEdge.h:427
double getLength() const
return the length of the edge
Definition MSEdge.h:694
virtual void closeBuilding()
Definition MSEdge.cpp:208
const MSJunction * getFromJunction() const
Definition MSEdge.h:423
double getMeanSpeed() const
get the mean speed
Definition MSEdge.cpp:999
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition MSEdge.h:1056
std::set< MSTransportable *, ComparatorNumericalIdLess > myPersons
Persons on the edge for drawing and pushbutton.
Definition MSEdge.h:975
bool isTazConnector() const
Definition MSEdge.h:292
const std::string & getRoutingType() const
Returns the type of the edge.
Definition MSEdge.h:326
MSEdgeVector mySuccessors
The succeeding edges.
Definition MSEdge.h:963
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:269
double getTimePenalty() const
Definition MSEdge.h:495
const std::string & getEdgeType() const
Returns the type of the edge.
Definition MSEdge.h:320
double getMeanFriction() const
get the mean friction over the lanes
Definition MSEdge.cpp:1040
int getVehicleNumber() const
return total number of vehicles on this edges lanes or segments
Definition MSEdge.cpp:1581
const std::map< const MEVehicle *, std::pair< double, int > > & getMesoPositions() const
Definition MSEdge.cpp:1749
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
Definition MSEdge.h:259
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition MSEdge.cpp:1083
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1307
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:940
void rebuildAllowedLanes(const bool onInit=false, bool updateVehicles=false)
Definition MSEdge.cpp:323
static bool gUseMesoSim
Definition MSGlobals.h:106
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:115
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
const ConstMSEdgeVector & getOutgoing() const
Definition MSJunction.h:114
Representation of a lane in the micro simulation.
Definition MSLane.h:84
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition MSLane.h:119
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:555
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:561
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:199
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:334
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:455
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:432
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.
const std::string & getID() const
Returns the id.
Definition Named.h:73
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
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:129
void mul(double val)
Multiplies position with the given value.
Definition Position.h:102
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:96
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
bool hideMax
whether data above threshold should not be colored
double minThreshold
threshold below which value should not be colored
bool hideMin
whether data below threshold should not be colored
double maxThreshold
threshold above which value should not be colored
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:58
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 or vias to use.