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-2025 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);
173 }
175 GUIDesigns::buildFXMenuCommand(ret, "segment: " + toString(segment->getIndex()), nullptr, nullptr, 0);
176 buildPositionCopyEntry(ret, app);
177 return ret;
178}
179
180
183 GUISUMOAbstractView& parent) {
184 GUIParameterTableWindow* ret = nullptr;
185 ret = new GUIParameterTableWindow(app, *this);
186 // add edge items
187 ret->mkItem(TL("max speed [m/s]"), false, getAllowedSpeed());
188 ret->mkItem(TL("length [m]"), false, (*myLanes)[0]->getLength());
189 ret->mkItem(TL("street name"), false, getStreetName());
190 ret->mkItem(TL("pending insertions [#]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getPendingEmits));
191 ret->mkItem(TL("mean friction [%]"), true, new FunctionBinding<GUIEdge, double>(this, &MSEdge::getMeanFriction, 100.));
192 ret->mkItem(TL("mean vehicle speed [m/s]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getMeanSpeed));
193 ret->mkItem(TL("routing speed [m/s]"), true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getRoutingSpeed));
194 ret->mkItem(TL("time penalty [s]"), true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getTimePenalty));
195 ret->mkItem(TL("brutto occupancy [%]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getBruttoOccupancy, 100.));
196 ret->mkItem(TL("edge flow [veh/h/m]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getFlow));
197 ret->mkItem(TL("vehicles [#]"), true, new CastingFunctionBinding<GUIEdge, int, int>(this, &MSEdge::getVehicleNumber));
198 // add segment items
200 ret->mkItem(TL("segment index"), false, segment->getIndex());
201 ret->mkItem(TL("segment queues"), false, segment->numQueues());
202 ret->mkItem(TL("segment length [m]"), false, segment->getLength());
203 ret->mkItem(TL("segment allowed speed [m/s]"), false, segment->getEdge().getSpeedLimit());
204 ret->mkItem(TL("segment jam threshold [%]"), false, segment->getRelativeJamThreshold() * 100);
205 ret->mkItem(TL("segment brutto occupancy [%]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getRelativeOccupancy, 100));
206 ret->mkItem(TL("segment mean vehicle speed [m/s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getMeanSpeed));
207 ret->mkItem(TL("segment flow [veh/h/m]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getFlow));
208 ret->mkItem(TL("segment vehicles [#]"), true, new CastingFunctionBinding<MESegment, int, int>(segment, &MESegment::getCarNumber));
209 ret->mkItem(TL("segment leader leave time"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEventTimeSeconds));
210 ret->mkItem(TL("segment headway [s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getLastHeadwaySeconds));
211 ret->mkItem(TL("segment entry block time [s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEntryBlockTimeSeconds));
212 // lane params
213 for (MSLane* lane : *myLanes) {
214 for (const auto& kv : lane->getParametersMap()) {
215 ret->mkItem(("laneParam " + toString(lane->getIndex()) + ":" + kv.first).c_str(), false, kv.second);
216 }
217 }
218 // close building
219 ret->closeBuilding();
220 return ret;
221}
222
228 // add items
229 ret->mkItem(TL("Type Information:"), false, "");
230 ret->mkItem(TL("type [id]"), false, getEdgeType());
231 ret->mkItem(TL("routing type [id]"), false, getRoutingType());
232 ret->mkItem(TL("tauff"), false, STEPS2TIME(edgeType.tauff));
233 ret->mkItem(TL("taufj"), false, STEPS2TIME(edgeType.taufj));
234 ret->mkItem(TL("taujf"), false, STEPS2TIME(edgeType.taujf));
235 ret->mkItem(TL("taujj"), false, STEPS2TIME(edgeType.taujj));
236 ret->mkItem(TL("jam threshold"), false, edgeType.jamThreshold);
237 ret->mkItem(TL("junction control"), false, edgeType.junctionControl);
238 ret->mkItem(TL("tls penalty"), false, edgeType.tlsPenalty);
239 ret->mkItem(TL("tls flow penalty"), false, edgeType.tlsFlowPenalty);
240 ret->mkItem(TL("minor penalty"), false, STEPS2TIME(edgeType.minorPenalty));
241 ret->mkItem(TL("overtaking"), false, edgeType.overtaking);
242 // close building
243 ret->closeBuilding();
244 return ret;
245}
246
247
250 Boundary b = getBoundary();
251 // ensure that vehicles and persons on the side are drawn even if the edge
252 // is outside the view
253 b.grow(10);
254 return b;
255}
256
257const std::string
259 return myStreetName;
260}
261
262void
265 return;
266 }
268 // draw the lanes
270 setColor(s);
271 }
272 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
273 static_cast<GUILane*>(*i)->drawGL(s);
274 }
276 if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
278 }
279 }
281 // (optionally) draw the name and/or the street name
282 GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back());
283 const GUIGlObject* selCheck = gSelected.isSelected(this) ? (GUIGlObject*)this : (GUIGlObject*)lane2;
284 const bool drawEdgeName = s.edgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::NORMAL;
285 const bool drawInternalEdgeName = s.internalEdgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::INTERNAL;
286 const bool drawCwaEdgeName = s.cwaEdgeName.show(selCheck) && (myFunction == SumoXMLEdgeFunc::CROSSING || myFunction == SumoXMLEdgeFunc::WALKINGAREA);
287 const bool drawStreetName = s.streetName.show(selCheck) && myStreetName != "";
288 const bool drawEdgeValue = s.edgeValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
291 const bool drawEdgeScaleValue = s.edgeScaleValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
294 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName || drawEdgeValue || drawEdgeScaleValue) {
295 GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]);
296 if (lane1 != nullptr && lane2 != nullptr) {
297 const bool s2 = s.secondaryShape;
298 const bool spreadSuperposed = s.spreadSuperposed && getBidiEdge() != nullptr;
299 Position p = lane1->getShape(s2).positionAtOffset(lane1->getShape(s2).length() / (double) 2.);
300 p.add(lane2->getShape(s2).positionAtOffset(lane2->getShape(s2).length() / (double) 2.));
301 p.mul(.5);
302 if (spreadSuperposed) {
303 // move name to the right of the edge and towards its beginning
304 const double dist = 0.6 * s.edgeName.scaledSize(s.scale);
305 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(135);
306 Position shift(dist * cos(shiftA), dist * sin(shiftA));
307 p.add(shift);
308 }
309 double angle = s.getTextAngle(lane1->getShape(s2).rotationDegreeAtOffset(lane1->getShape(s2).length() / (double) 2.) + 90);
310 if (drawEdgeName) {
311 drawName(p, s.scale, s.edgeName, angle, true);
312 } else if (drawInternalEdgeName) {
313 drawName(p, s.scale, s.internalEdgeName, angle, true);
314 } else if (drawCwaEdgeName) {
315 drawName(p, s.scale, s.cwaEdgeName, angle, true);
316 }
317 if (drawStreetName) {
319 }
320 if (drawEdgeValue) {
321 const int activeScheme = s.getLaneEdgeMode();
322 std::string value = "";
323 if (activeScheme == 31) {
324 // edge param, could be non-numerical
325 value = getParameter(s.edgeParam, "");
326 } else if (activeScheme == 32) {
327 // lane param, could be non-numerical
328 value = lane2->getParameter(s.laneParam, "");
329 } else {
330 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
331 const double doubleValue = (MSGlobals::gUseMesoSim
332 ? getColorValue(s, activeScheme)
333 : lane2->getColorValueWithFunctional(s, activeScheme));
334 const RGBColor color = (MSGlobals::gUseMesoSim ? s.edgeColorer : s.laneColorer).getScheme().getColor(doubleValue);
335 if (doubleValue != s.MISSING_DATA
336 && color.alpha() != 0
337 && (!s.edgeValueRainBow.hideMin || doubleValue > s.edgeValueRainBow.minThreshold)
338 && (!s.edgeValueRainBow.hideMax || doubleValue < s.edgeValueRainBow.maxThreshold)
339 ) {
340 value = toString(doubleValue);
341 }
342 }
343 if (value != "") {
344 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName) {
345 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeValue.scaledSize(s.scale));
346 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
347 Position shift(dist * cos(shiftA), dist * sin(shiftA));
348 p.add(shift);
349 }
350 GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, angle);
351 }
352 }
353 if (drawEdgeScaleValue) {
354 const int activeScheme = s.getLaneEdgeScaleMode();
355 std::string value = "";
356 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
357 const double doubleValue = (MSGlobals::gUseMesoSim
358 ? getScaleValue(s, activeScheme)
359 : lane2->getScaleValue(s, activeScheme, s2));
360 if (doubleValue != s.MISSING_DATA) {
361 value = toString(doubleValue);
362 }
363 if (value != "") {
364 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawEdgeValue) {
365 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeScaleValue.scaledSize(s.scale));
366 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
367 Position shift(dist * cos(shiftA), dist * sin(shiftA));
368 p.add(shift);
369 }
370 GLHelper::drawTextSettings(s.edgeScaleValue, value, p, s.scale, angle);
371 }
372 }
373 }
374 }
375 if (s.scale * s.personSize.getExaggeration(s, nullptr) > s.personSize.minSize) {
376 FXMutexLock locker(myLock);
377 for (MSTransportable* t : myPersons) {
378 GUIPerson* person = dynamic_cast<GUIPerson*>(t);
379 assert(person != 0);
380 person->drawGL(s);
381 }
382 }
383 if (s.scale * s.containerSize.getExaggeration(s, nullptr) > s.containerSize.minSize) {
384 FXMutexLock locker(myLock);
385 for (MSTransportable* t : myContainers) {
386 GUIContainer* container = dynamic_cast<GUIContainer*>(t);
387 assert(container != 0);
388 container->drawGL(s);
389 }
390 }
391}
392
393
394void
397 const double now = SIMTIME;
398 if (vehicleControl != nullptr) {
399 // draw the meso vehicles
400 vehicleControl->secureVehicles();
401 FXMutexLock locker(myLock);
402 int laneIndex = 0;
403 for (std::vector<MSLane*>::const_iterator msl = myLanes->begin(); msl != myLanes->end(); ++msl, ++laneIndex) {
404 GUILane* l = static_cast<GUILane*>(*msl);
405 // go through the vehicles
406 double segmentOffset = 0; // offset at start of current segment
407 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
408 segment != nullptr; segment = segment->getNextSegment()) {
409 const double length = segment->getLength();
410 if (laneIndex < segment->numQueues()) {
411 // make a copy so we don't have to worry about synchronization
412 std::vector<MEVehicle*> queue = segment->getQueue(laneIndex);
413 const int queueSize = (int)queue.size();
414 double vehiclePosition = segmentOffset + length;
415 // draw vehicles beginning with the leader at the end of the segment
416 double latOff = 0.;
417 for (int i = 0; i < queueSize; ++i) {
418 const GUIMEVehicle* const veh = static_cast<GUIMEVehicle*>(queue[queueSize - i - 1]);
419 const double intendedLeave = MIN2(veh->getEventTimeSeconds(), veh->getBlockTimeSeconds());
420 const double entry = veh->getLastEntryTimeSeconds();
421 const double relPos = segmentOffset + length * (now - entry) / (intendedLeave - entry);
422 if (relPos < vehiclePosition) {
423 vehiclePosition = relPos;
424 }
425 while (vehiclePosition < segmentOffset) {
426 // if there is only a single queue for a
427 // multi-lane edge shift vehicles and start
428 // drawing again from the end of the segment
429 vehiclePosition += length;
430 latOff += 0.2;
431 }
433 const Position p = l->geometryPositionAtOffset(vehiclePosition, latOff);
434 const double angle = l->getShape(s.secondaryShape).rotationAtOffset(l->interpolateLanePosToGeometryPos(vehiclePosition));
435 veh->drawOnPos(s, p, angle);
436 vehiclePosition -= veh->getVehicleType().getLengthWithGap();
437 }
438 }
439 segmentOffset += length;
440 }
442 }
443 vehicleControl->releaseVehicles();
444 }
445}
446
447
448
449double
451 return (*myLanes)[0]->getSpeedLimit();
452}
453
454
455double
459
460
461void
463 myMesoColor = RGBColor(0, 0, 0); // default background color when using multiColor
464 const GUIColorer& c = s.edgeColorer;
465 if (!setFunctionalColor(c) && !setMultiColor(c)) {
467 }
468}
469
470
471bool
473 const int activeScheme = c.getActive();
474 int activeMicroScheme = -1;
475 switch (activeScheme) {
476 case 0:
477 activeMicroScheme = 0; // color uniform
478 break;
479 case 9:
480 activeMicroScheme = 18; // color by angle
481 break;
482 case 17:
483 activeMicroScheme = 30; // color by TAZ
484 break;
485 default:
486 return false;
487 }
488 GUILane* guiLane = static_cast<GUILane*>(getLanes()[0]);
489 return guiLane->setFunctionalColor(c, myMesoColor, activeMicroScheme);
490}
491
492
493bool
495 const int activeScheme = c.getActive();
496 mySegmentColors.clear();
497 switch (activeScheme) {
498 case 10: // alternating segments
499 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
500 segment != nullptr; segment = segment->getNextSegment()) {
501 mySegmentColors.push_back(c.getScheme().getColor(segment->getIndex() % 2));
502 }
503 //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";
504 return true;
505 case 11: // by segment jammed state
506 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
507 segment != nullptr; segment = segment->getNextSegment()) {
508 mySegmentColors.push_back(
509 c.getScheme().getColor(segment->getRelativeOccupancy() > segment->getRelativeJamThreshold() ? 2 :
510 (segment->getRelativeOccupancy() * 2 < segment->getRelativeJamThreshold() ? 0 : 1)));
511 }
512 return true;
513 case 12: // by segment occupancy
514 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
515 segment != nullptr; segment = segment->getNextSegment()) {
516 mySegmentColors.push_back(c.getScheme().getColor(segment->getRelativeOccupancy()));
517 }
518 return true;
519 case 13: // by segment speed
520 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
521 segment != nullptr; segment = segment->getNextSegment()) {
522 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed()));
523 }
524 return true;
525 case 14: // by segment flow
526 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
527 segment != nullptr; segment = segment->getNextSegment()) {
528 mySegmentColors.push_back(c.getScheme().getColor(3600 * segment->getCarNumber() * segment->getMeanSpeed() / segment->getLength()));
529 }
530 return true;
531 case 15: // by segment relative speed
532 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
533 segment != nullptr; segment = segment->getNextSegment()) {
534 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed() / getAllowedSpeed()));
535 }
536 return true;
537 default:
538 return false;
539 }
540}
541
542
543double
544GUIEdge::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
545 switch (activeScheme) {
546 case 1:
547 return gSelected.isSelected(getType(), getGlID());
548 case 2:
549 return (double)getFunction();
550 case 3:
551 return getAllowedSpeed();
552 case 4:
553 return getBruttoOccupancy();
554 case 5:
555 return getMeanSpeed();
556 case 6:
557 return getFlow();
558 case 7:
559 return getRelativeSpeed();
560 case 8:
561 return getRoutingSpeed();
562 case 16:
563 return getPendingEmits();
564 case 18:
565 // by numerical edge param value
566 try {
568 } catch (NumberFormatException&) {
569 try {
571 } catch (BoolFormatException&) {
572 return -1;
573 }
574 }
575 case 19:
576 // by edge data value
578 }
579 return 0;
580}
581
582
583double
584GUIEdge::getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const {
585 switch (activeScheme) {
586 case 1:
587 return gSelected.isSelected(getType(), getGlID());
588 case 2:
589 return getAllowedSpeed();
590 case 3:
591 return getBruttoOccupancy();
592 case 4:
593 return getMeanSpeed();
594 case 5:
595 return getFlow();
596 case 6:
597 return getRelativeSpeed();
598 case 7:
599 return getPendingEmits();
600 case 8:
601 // by edge data value
603 }
604 return 0;
605}
606
607
610 const PositionVector& shape = getLanes()[0]->getShape();
611 const double lanePos = shape.nearest_offset_to_point2D(pos);
612 return MSGlobals::gMesoNet->getSegmentForEdge(*this, lanePos);
613}
614
615
616
617void
619 const std::vector<MSLane*>& lanes = getLanes();
620 const bool isClosed = lane->isClosed();
621 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
622 GUILane* l = dynamic_cast<GUILane*>(*i);
623 if (l->isClosed() == isClosed) {
624 l->closeTraffic(false);
625 }
626 }
628}
629
630
631void
633 MSEdgeVector edges;
634 edges.push_back(this);
635 GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, false, 0, "", Position::INVALID,
636 std::numeric_limits<double>::max(), GUINet::getGUIInstance()->getVisualisationSpeedUp());
637
640 ri.end = SUMOTime_MAX;
642 rr->myIntervals.push_back(ri);
643
644 // trigger rerouting for vehicles already on this edge
645 const std::vector<MSLane*>& lanes = getLanes();
646 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
647 const MSLane::VehCont& vehicles = (*i)->getVehiclesSecure();
648 for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
649 if ((*v)->getLane() == (*i)) {
651 } // else: this is the shadow during a continuous lane change
652 }
653 (*i)->releaseVehicles();
654 }
655}
656
657
658bool
662
663double
667
668double
671 // do not select edgse in meso mode
672 return INVALID_PRIORITY;
673 }
674 return GLO_EDGE;
675}
676/****************************************************************************/
@ 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: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:80
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: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 popMatrix()
pop matrix
Definition GLHelper.cpp:131
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:669
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUIEdge.cpp:249
double getAllowedSpeed() const
Definition GUIEdge.cpp:450
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition GUIEdge.h:254
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition GUIEdge.cpp:494
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUIEdge.cpp:462
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition GUIEdge.cpp:395
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:544
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:263
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition GUIEdge.cpp:456
RGBColor myMesoColor
Definition GUIEdge.h:256
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition GUIEdge.cpp:618
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition GUIEdge.cpp:609
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:632
static double getTotalLength(bool includeInternal, bool eachLane)
Definition GUIEdge.cpp:121
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:182
const std::string getOptionalName() const override
Returns the street name.
Definition GUIEdge.cpp:258
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:584
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUIEdge.cpp:659
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition GUIEdge.cpp:664
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition GUIEdge.cpp:472
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:224
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 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.
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
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:1494
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUILane.cpp:539
bool isClosed() const
Definition GUILane.h:266
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1594
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:1181
const PositionVector & getShape(bool secondary) const override
Definition GUILane.cpp:1119
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition GUILane.cpp:1211
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:614
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition GUINet.cpp:608
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:340
A single mesoscopic segment (cell)
Definition MESegment.h:50
double getEntryBlockTimeSeconds() const
get the earliest entry time in seconds
Definition MESegment.h:391
double getLastHeadwaySeconds() const
get the last headway time in seconds
Definition MESegment.h:386
double getRelativeOccupancy() const
Returns the relative occupany of the segment (percentage of road used))
Definition MESegment.h:271
double getLength() const
Returns the length of the segment in meters.
Definition MESegment.h:244
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition MESegment.h:364
int numQueues() const
return the number of queues
Definition MESegment.h:213
double getRelativeJamThreshold() const
Returns the relative occupany of the segment (percentage of road used)) at which the segment is consi...
Definition MESegment.h:279
double getEventTimeSeconds() const
Like getEventTime but returns seconds (for visualization)
Definition MESegment.h:381
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition MESegment.h:228
double getMeanSpeed() const
wrapper to satisfy the FunctionBinding signature
Definition MESegment.h:299
int getCarNumber() const
Returns the total number of cars on the segment.
Definition MESegment.h:208
double getFlow() const
returns flow based on headway
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
Definition MEVehicle.h:300
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
Definition MEVehicle.h:305
double getEventTimeSeconds() const
Returns the earliest leave time for the current segment.
Definition MEVehicle.h:295
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:991
double getBruttoOccupancy() const
Definition MSEdge.cpp:1619
double getFlow() const
return flow based on meanSpead
Definition MSEdge.cpp:1606
std::set< MSTransportable *, ComparatorNumericalIdLess > myContainers
Containers on the edge.
Definition MSEdge.h:960
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:657
const std::string & getStreetName() const
Returns the street name of the edge.
Definition MSEdge.h:313
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:282
bool isNormal() const
return whether this edge is an internal edge
Definition MSEdge.h:263
const SumoXMLEdgeFunc myFunction
the purpose of the edge
Definition MSEdge.h:928
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:1168
MSEdgeVector myPredecessors
The preceeding edges.
Definition MSEdge.h:950
const MSJunction * getToJunction() const
Definition MSEdge.h:426
double getLength() const
return the length of the edge
Definition MSEdge.h:693
virtual void closeBuilding()
Definition MSEdge.cpp:208
const MSJunction * getFromJunction() const
Definition MSEdge.h:422
double getMeanSpeed() const
get the mean speed
Definition MSEdge.cpp:967
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition MSEdge.h:1038
std::set< MSTransportable *, ComparatorNumericalIdLess > myPersons
Persons on the edge for drawing and pushbutton.
Definition MSEdge.h:957
bool isTazConnector() const
Definition MSEdge.h:291
const std::string & getRoutingType() const
Returns the type of the edge.
Definition MSEdge.h:325
MSEdgeVector mySuccessors
The succeeding edges.
Definition MSEdge.h:945
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:268
double getTimePenalty() const
Definition MSEdge.h:494
const std::string & getEdgeType() const
Returns the type of the edge.
Definition MSEdge.h:319
double getMeanFriction() const
get the mean friction over the lanes
Definition MSEdge.cpp:1008
int getVehicleNumber() const
return total number of vehicles on this edges lanes or segments
Definition MSEdge.cpp:1542
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
Definition MSEdge.h:258
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition MSEdge.cpp:1051
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1268
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:922
void rebuildAllowedLanes(const bool onInit=false, bool updateVehicles=false)
Definition MSEdge.cpp:325
static bool gUseMesoSim
Definition MSGlobals.h:106
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition MSGlobals.h:112
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 getLength() const
Returns the lane's length.
Definition MSLane.h:611
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:554
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:334
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:445
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:412
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
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
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: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
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:57
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.