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-2024 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>
40#include <microsim/MSEdge.h>
41#include <microsim/MSJunction.h>
44#include <microsim/MSGlobals.h>
50#include <mesosim/MESegment.h>
51#include <mesosim/MELoop.h>
52#include <mesosim/MEVehicle.h>
53
55#include "GUIEdge.h"
56#include "GUIVehicle.h"
57#include "GUINet.h"
58#include "GUILane.h"
59#include "GUIPerson.h"
60#include "GUIContainer.h"
61
62
63GUIEdge::GUIEdge(const std::string& id, int numericalID,
64 const SumoXMLEdgeFunc function,
65 const std::string& streetName, const std::string& edgeType, int priority,
66 double distance) :
67 MSEdge(id, numericalID, function, streetName, edgeType, priority, distance),
69 myLock(true)
70{}
71
72
74 // just to quit cleanly on a failure
75 if (myLock.locked()) {
76 myLock.unlock();
77 }
78}
79
80void
83 bool hasNormalSuccessors = false;
84 for (const MSEdge* out : getSuccessors()) {
85 if (!out->isTazConnector()) {
86 hasNormalSuccessors = true;
87 break;
88 }
89 }
90 myShowDeadEnd = (!isTazConnector() && !hasNormalSuccessors && getToJunction()->getOutgoing().size() > 0
91 && (getPermissions() & ~SVC_PEDESTRIAN) != 0
92 && (getToJunction()->getOutgoing().size() > 1 ||
93 getToJunction()->getOutgoing().front()->getToJunction() != getFromJunction()));
94}
95
96MSLane&
97GUIEdge::getLane(int laneNo) {
98 assert(laneNo < (int)myLanes->size());
99 return *((*myLanes)[laneNo]);
100}
101
102
103std::vector<GUIGlID>
104GUIEdge::getIDs(bool includeInternal) {
105 std::vector<GUIGlID> ret;
106 ret.reserve(MSEdge::myDict.size());
107 for (MSEdge::DictType::const_iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) {
108 const GUIEdge* edge = dynamic_cast<const GUIEdge*>(i->second);
109 assert(edge);
110 if (includeInternal || edge->isNormal()) {
111 ret.push_back(edge->getGlID());
112 }
113 }
114 return ret;
115}
116
117
118double
119GUIEdge::getTotalLength(bool includeInternal, bool eachLane) {
120 double result = 0;
121 for (MSEdge::DictType::const_iterator i = MSEdge::myDict.begin(); i != MSEdge::myDict.end(); ++i) {
122 const MSEdge* edge = i->second;
123 if (includeInternal || !edge->isInternal()) {
124 // @note needs to be change once lanes may have different length
125 result += edge->getLength() * (eachLane ? (double)edge->getLanes().size() : 1.);
126 }
127 }
128 return result;
129}
130
131
134 Boundary ret;
135 if (!isTazConnector()) {
136 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
137 ret.add((*i)->getShape().getBoxBoundary());
138 }
139 } else {
140 // take the starting coordinates of all follower edges and the endpoints
141 // of all successor edges
142 for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
143 const std::vector<MSLane*>& lanes = (*it)->getLanes();
144 for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
145 ret.add((*it_lane)->getShape().front());
146 }
147 }
148 for (MSEdgeVector::const_iterator it = myPredecessors.begin(); it != myPredecessors.end(); ++it) {
149 const std::vector<MSLane*>& lanes = (*it)->getLanes();
150 for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
151 ret.add((*it_lane)->getShape().back());
152 }
153 }
154 }
155 ret.grow(10);
156 return ret;
157}
158
159
162 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
163 buildPopupHeader(ret, app);
170 }
172 GUIDesigns::buildFXMenuCommand(ret, "segment: " + toString(segment->getIndex()), nullptr, nullptr, 0);
173 buildPositionCopyEntry(ret, app);
174 return ret;
175}
176
177
180 GUISUMOAbstractView& parent) {
181 GUIParameterTableWindow* ret = nullptr;
182 ret = new GUIParameterTableWindow(app, *this);
183 // add edge items
184 ret->mkItem(TL("max speed [m/s]"), false, getAllowedSpeed());
185 ret->mkItem(TL("length [m]"), false, (*myLanes)[0]->getLength());
186 ret->mkItem(TL("street name"), false, getStreetName());
187 ret->mkItem(TL("pending insertions [#]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getPendingEmits));
188 ret->mkItem(TL("mean friction [%]"), true, new FunctionBinding<GUIEdge, double>(this, &MSEdge::getMeanFriction, 100.));
189 ret->mkItem(TL("mean vehicle speed [m/s]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getMeanSpeed));
190 ret->mkItem(TL("routing speed [m/s]"), true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getRoutingSpeed));
191 ret->mkItem(TL("time penalty [s]"), true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getTimePenalty));
192 ret->mkItem(TL("brutto occupancy [%]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getBruttoOccupancy, 100.));
193 ret->mkItem(TL("flow [veh/h/lane]"), true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getFlow));
194 ret->mkItem(TL("vehicles [#]"), true, new CastingFunctionBinding<GUIEdge, int, int>(this, &MSEdge::getVehicleNumber));
195 // add segment items
197 ret->mkItem(TL("segment index"), false, segment->getIndex());
198 ret->mkItem(TL("segment queues"), false, segment->numQueues());
199 ret->mkItem(TL("segment length [m]"), false, segment->getLength());
200 ret->mkItem(TL("segment allowed speed [m/s]"), false, segment->getEdge().getSpeedLimit());
201 ret->mkItem(TL("segment jam threshold [%]"), false, segment->getRelativeJamThreshold() * 100);
202 ret->mkItem(TL("segment brutto occupancy [%]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getRelativeOccupancy, 100));
203 ret->mkItem(TL("segment mean vehicle speed [m/s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getMeanSpeed));
204 ret->mkItem(TL("segment flow [veh/h/lane]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getFlow));
205 ret->mkItem(TL("segment vehicles [#]"), true, new CastingFunctionBinding<MESegment, int, int>(segment, &MESegment::getCarNumber));
206 ret->mkItem(TL("segment leader leave time"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEventTimeSeconds));
207 ret->mkItem(TL("segment headway [s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getLastHeadwaySeconds));
208 ret->mkItem(TL("segment entry block time [s]"), true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEntryBlockTimeSeconds));
209 // lane params
210 for (MSLane* lane : *myLanes) {
211 for (const auto& kv : lane->getParametersMap()) {
212 ret->mkItem(("laneParam " + toString(lane->getIndex()) + ":" + kv.first).c_str(), false, kv.second);
213 }
214 }
215 // close building
216 ret->closeBuilding();
217 return ret;
218}
219
225 // add items
226 ret->mkItem(TL("Type Information:"), false, "");
227 ret->mkItem(TL("type [id]"), false, getEdgeType());
228 ret->mkItem(TL("tauff"), false, STEPS2TIME(edgeType.tauff));
229 ret->mkItem(TL("taufj"), false, STEPS2TIME(edgeType.taufj));
230 ret->mkItem(TL("taujf"), false, STEPS2TIME(edgeType.taujf));
231 ret->mkItem(TL("taujj"), false, STEPS2TIME(edgeType.taujj));
232 ret->mkItem(TL("jam threshold"), false, edgeType.jamThreshold);
233 ret->mkItem(TL("junction control"), false, edgeType.junctionControl);
234 ret->mkItem(TL("tls penalty"), false, edgeType.tlsPenalty);
235 ret->mkItem(TL("tls flow penalty"), false, edgeType.tlsFlowPenalty);
236 ret->mkItem(TL("minor penalty"), false, STEPS2TIME(edgeType.minorPenalty));
237 ret->mkItem(TL("overtaking"), false, edgeType.overtaking);
238 // close building
239 ret->closeBuilding();
240 return ret;
241}
242
243
246 Boundary b = getBoundary();
247 // ensure that vehicles and persons on the side are drawn even if the edge
248 // is outside the view
249 b.grow(10);
250 return b;
251}
252
253const std::string
255 return myStreetName;
256}
257
258void
261 return;
262 }
264 // draw the lanes
266 setColor(s);
267 }
268 for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
269 static_cast<GUILane*>(*i)->drawGL(s);
270 }
272 if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
274 }
275 }
277 // (optionally) draw the name and/or the street name
278 GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back());
279 const GUIGlObject* selCheck = gSelected.isSelected(this) ? (GUIGlObject*)this : (GUIGlObject*)lane2;
280 const bool drawEdgeName = s.edgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::NORMAL;
281 const bool drawInternalEdgeName = s.internalEdgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::INTERNAL;
282 const bool drawCwaEdgeName = s.cwaEdgeName.show(selCheck) && (myFunction == SumoXMLEdgeFunc::CROSSING || myFunction == SumoXMLEdgeFunc::WALKINGAREA);
283 const bool drawStreetName = s.streetName.show(selCheck) && myStreetName != "";
284 const bool drawEdgeValue = s.edgeValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
287 const bool drawEdgeScaleValue = s.edgeScaleValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
290 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName || drawEdgeValue || drawEdgeScaleValue) {
291 GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]);
292 if (lane1 != nullptr && lane2 != nullptr) {
293 const bool s2 = s.secondaryShape;
294 const bool spreadSuperposed = s.spreadSuperposed && getBidiEdge() != nullptr;
295 Position p = lane1->getShape(s2).positionAtOffset(lane1->getShape(s2).length() / (double) 2.);
296 p.add(lane2->getShape(s2).positionAtOffset(lane2->getShape(s2).length() / (double) 2.));
297 p.mul(.5);
298 if (spreadSuperposed) {
299 // move name to the right of the edge and towards its beginning
300 const double dist = 0.6 * s.edgeName.scaledSize(s.scale);
301 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(135);
302 Position shift(dist * cos(shiftA), dist * sin(shiftA));
303 p.add(shift);
304 }
305 double angle = s.getTextAngle(lane1->getShape(s2).rotationDegreeAtOffset(lane1->getShape(s2).length() / (double) 2.) + 90);
306 if (drawEdgeName) {
307 drawName(p, s.scale, s.edgeName, angle, true);
308 } else if (drawInternalEdgeName) {
309 drawName(p, s.scale, s.internalEdgeName, angle, true);
310 } else if (drawCwaEdgeName) {
311 drawName(p, s.scale, s.cwaEdgeName, angle, true);
312 }
313 if (drawStreetName) {
315 }
316 if (drawEdgeValue) {
317 const int activeScheme = s.getLaneEdgeMode();
318 std::string value = "";
319 if (activeScheme == 31) {
320 // edge param, could be non-numerical
321 value = getParameter(s.edgeParam, "");
322 } else if (activeScheme == 32) {
323 // lane param, could be non-numerical
324 value = lane2->getParameter(s.laneParam, "");
325 } else {
326 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
327 const double doubleValue = (MSGlobals::gUseMesoSim
328 ? getColorValue(s, activeScheme)
329 : lane2->getColorValueWithFunctional(s, activeScheme));
330 const RGBColor color = (MSGlobals::gUseMesoSim ? s.edgeColorer : s.laneColorer).getScheme().getColor(doubleValue);
331 if (doubleValue != s.MISSING_DATA
332 && color.alpha() != 0
333 && (!s.edgeValueRainBow.hideMin || doubleValue > s.edgeValueRainBow.minThreshold)
334 && (!s.edgeValueRainBow.hideMax || doubleValue < s.edgeValueRainBow.maxThreshold)
335 ) {
336 value = toString(doubleValue);
337 }
338 }
339 if (value != "") {
340 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName) {
341 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeValue.scaledSize(s.scale));
342 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
343 Position shift(dist * cos(shiftA), dist * sin(shiftA));
344 p.add(shift);
345 }
346 GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, angle);
347 }
348 }
349 if (drawEdgeScaleValue) {
350 const int activeScheme = s.getLaneEdgeScaleMode();
351 std::string value = "";
352 // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
353 const double doubleValue = (MSGlobals::gUseMesoSim
354 ? getScaleValue(s, activeScheme)
355 : lane2->getScaleValue(s, activeScheme, s2));
356 if (doubleValue != s.MISSING_DATA) {
357 value = toString(doubleValue);
358 }
359 if (value != "") {
360 if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawEdgeValue) {
361 const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeScaleValue.scaledSize(s.scale));
362 const double shiftA = lane1->getShape(s2).rotationAtOffset(lane1->getShape(s2).length() / (double) 2.) - DEG2RAD(90);
363 Position shift(dist * cos(shiftA), dist * sin(shiftA));
364 p.add(shift);
365 }
366 GLHelper::drawTextSettings(s.edgeScaleValue, value, p, s.scale, angle);
367 }
368 }
369 }
370 }
371 if (s.scale * s.personSize.getExaggeration(s, nullptr) > s.personSize.minSize) {
372 FXMutexLock locker(myLock);
373 for (MSTransportable* t : myPersons) {
374 GUIPerson* person = dynamic_cast<GUIPerson*>(t);
375 assert(person != 0);
376 person->drawGL(s);
377 }
378 }
379 if (s.scale * s.containerSize.getExaggeration(s, nullptr) > s.containerSize.minSize) {
380 FXMutexLock locker(myLock);
381 for (MSTransportable* t : myContainers) {
382 GUIContainer* container = dynamic_cast<GUIContainer*>(t);
383 assert(container != 0);
384 container->drawGL(s);
385 }
386 }
387}
388
389
390void
393 const double now = SIMTIME;
394 if (vehicleControl != nullptr) {
395 // draw the meso vehicles
396 vehicleControl->secureVehicles();
397 FXMutexLock locker(myLock);
398 int laneIndex = 0;
399 for (std::vector<MSLane*>::const_iterator msl = myLanes->begin(); msl != myLanes->end(); ++msl, ++laneIndex) {
400 GUILane* l = static_cast<GUILane*>(*msl);
401 // go through the vehicles
402 double segmentOffset = 0; // offset at start of current segment
403 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
404 segment != nullptr; segment = segment->getNextSegment()) {
405 const double length = segment->getLength();
406 if (laneIndex < segment->numQueues()) {
407 // make a copy so we don't have to worry about synchronization
408 std::vector<MEVehicle*> queue = segment->getQueue(laneIndex);
409 const int queueSize = (int)queue.size();
410 double vehiclePosition = segmentOffset + length;
411 // draw vehicles beginning with the leader at the end of the segment
412 double latOff = 0.;
413 for (int i = 0; i < queueSize; ++i) {
414 const GUIMEVehicle* const veh = static_cast<GUIMEVehicle*>(queue[queueSize - i - 1]);
415 const double intendedLeave = MIN2(veh->getEventTimeSeconds(), veh->getBlockTimeSeconds());
416 const double entry = veh->getLastEntryTimeSeconds();
417 const double relPos = segmentOffset + length * (now - entry) / (intendedLeave - entry);
418 if (relPos < vehiclePosition) {
419 vehiclePosition = relPos;
420 }
421 while (vehiclePosition < segmentOffset) {
422 // if there is only a single queue for a
423 // multi-lane edge shift vehicles and start
424 // drawing again from the end of the segment
425 vehiclePosition += length;
426 latOff += 0.2;
427 }
429 const Position p = l->geometryPositionAtOffset(vehiclePosition, latOff);
430 const double angle = l->getShape(s.secondaryShape).rotationAtOffset(l->interpolateLanePosToGeometryPos(vehiclePosition));
431 veh->drawOnPos(s, p, angle);
432 vehiclePosition -= veh->getVehicleType().getLengthWithGap();
433 }
434 }
435 segmentOffset += length;
436 }
438 }
439 vehicleControl->releaseVehicles();
440 }
441}
442
443
444
445double
447 return (*myLanes)[0]->getSpeedLimit();
448}
449
450
451double
455
456
457void
459 myMesoColor = RGBColor(0, 0, 0); // default background color when using multiColor
460 const GUIColorer& c = s.edgeColorer;
461 if (!setFunctionalColor(c) && !setMultiColor(c)) {
463 }
464}
465
466
467bool
469 const int activeScheme = c.getActive();
470 int activeMicroScheme = -1;
471 switch (activeScheme) {
472 case 0:
473 activeMicroScheme = 0; // color uniform
474 break;
475 case 9:
476 activeMicroScheme = 18; // color by angle
477 break;
478 case 17:
479 activeMicroScheme = 30; // color by TAZ
480 break;
481 default:
482 return false;
483 }
484 GUILane* guiLane = static_cast<GUILane*>(getLanes()[0]);
485 return guiLane->setFunctionalColor(c, myMesoColor, activeMicroScheme);
486}
487
488
489bool
491 const int activeScheme = c.getActive();
492 mySegmentColors.clear();
493 switch (activeScheme) {
494 case 10: // alternating segments
495 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
496 segment != nullptr; segment = segment->getNextSegment()) {
497 mySegmentColors.push_back(c.getScheme().getColor(segment->getIndex() % 2));
498 }
499 //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";
500 return true;
501 case 11: // by segment jammed state
502 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
503 segment != nullptr; segment = segment->getNextSegment()) {
504 mySegmentColors.push_back(
505 c.getScheme().getColor(segment->getRelativeOccupancy() > segment->getRelativeJamThreshold() ? 2 :
506 (segment->getRelativeOccupancy() * 2 < segment->getRelativeJamThreshold() ? 0 : 1)));
507 }
508 return true;
509 case 12: // by segment occupancy
510 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
511 segment != nullptr; segment = segment->getNextSegment()) {
512 mySegmentColors.push_back(c.getScheme().getColor(segment->getRelativeOccupancy()));
513 }
514 return true;
515 case 13: // by segment speed
516 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
517 segment != nullptr; segment = segment->getNextSegment()) {
518 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed()));
519 }
520 return true;
521 case 14: // by segment flow
522 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
523 segment != nullptr; segment = segment->getNextSegment()) {
524 mySegmentColors.push_back(c.getScheme().getColor(3600 * segment->getCarNumber() * segment->getMeanSpeed() / segment->getLength()));
525 }
526 return true;
527 case 15: // by segment relative speed
528 for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
529 segment != nullptr; segment = segment->getNextSegment()) {
530 mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed() / getAllowedSpeed()));
531 }
532 return true;
533 default:
534 return false;
535 }
536}
537
538
539double
540GUIEdge::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
541 switch (activeScheme) {
542 case 1:
543 return gSelected.isSelected(getType(), getGlID());
544 case 2:
545 return (double)getFunction();
546 case 3:
547 return getAllowedSpeed();
548 case 4:
549 return getBruttoOccupancy();
550 case 5:
551 return getMeanSpeed();
552 case 6:
553 return getFlow();
554 case 7:
555 return getRelativeSpeed();
556 case 8:
557 return getRoutingSpeed();
558 case 16:
559 return getPendingEmits();
560 case 18:
561 // by numerical edge param value
562 try {
564 } catch (NumberFormatException&) {
565 try {
567 } catch (BoolFormatException&) {
568 return -1;
569 }
570 }
571 case 19:
572 // by edge data value
574 }
575 return 0;
576}
577
578
579double
580GUIEdge::getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const {
581 switch (activeScheme) {
582 case 1:
583 return gSelected.isSelected(getType(), getGlID());
584 case 2:
585 return getAllowedSpeed();
586 case 3:
587 return getBruttoOccupancy();
588 case 4:
589 return getMeanSpeed();
590 case 5:
591 return getFlow();
592 case 6:
593 return getRelativeSpeed();
594 case 7:
595 return getPendingEmits();
596 case 8:
597 // by edge data value
599 }
600 return 0;
601}
602
603
606 const PositionVector& shape = getLanes()[0]->getShape();
607 const double lanePos = shape.nearest_offset_to_point2D(pos);
608 return MSGlobals::gMesoNet->getSegmentForEdge(*this, lanePos);
609}
610
611
612
613void
615 const std::vector<MSLane*>& lanes = getLanes();
616 const bool isClosed = lane->isClosed();
617 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
618 GUILane* l = dynamic_cast<GUILane*>(*i);
619 if (l->isClosed() == isClosed) {
620 l->closeTraffic(false);
621 }
622 }
624}
625
626
627void
629 MSEdgeVector edges;
630 edges.push_back(this);
631 GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, false, false, 0, "", Position::INVALID,
632 GUINet::getGUIInstance()->getVisualisationSpeedUp());
633
636 ri.end = SUMOTime_MAX;
638 rr->myIntervals.push_back(ri);
639
640 // trigger rerouting for vehicles already on this edge
641 const std::vector<MSLane*>& lanes = getLanes();
642 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
643 const MSLane::VehCont& vehicles = (*i)->getVehiclesSecure();
644 for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
645 if ((*v)->getLane() == (*i)) {
647 } // else: this is the shadow during a continuous lane change
648 }
649 (*i)->releaseVehicles();
650 }
651}
652
653
654bool
658
659double
663
664double
667 // do not select edgse in meso mode
668 return INVALID_PRIORITY;
669 }
670 return GLO_EDGE;
671}
672/****************************************************************************/
@ 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:315
#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:343
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:787
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:665
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GUIEdge.cpp:245
double getAllowedSpeed() const
Definition GUIEdge.cpp:446
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition GUIEdge.h:253
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition GUIEdge.cpp:490
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition GUIEdge.cpp:458
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition GUIEdge.cpp:391
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GUIEdge.cpp:161
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUIEdge.cpp:540
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition GUIEdge.cpp:97
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUIEdge.cpp:259
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition GUIEdge.cpp:452
RGBColor myMesoColor
Definition GUIEdge.h:255
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition GUIEdge.cpp:614
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition GUIEdge.cpp:605
virtual void closeBuilding() override
Has to be called after all edges were built and all connections were set.
Definition GUIEdge.cpp:81
void addRerouter()
add a rerouter
Definition GUIEdge.cpp:628
static double getTotalLength(bool includeInternal, bool eachLane)
Definition GUIEdge.cpp:119
Boundary getBoundary() const
Returns the street's geometry.
Definition GUIEdge.cpp:133
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition GUIEdge.cpp:104
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition GUIEdge.cpp:179
const std::string getOptionalName() const override
Returns the street name.
Definition GUIEdge.cpp:254
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition GUIEdge.h:235
double getScaleValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the scaling value according to the current scheme index
Definition GUIEdge.cpp:580
bool isSelected() const override
whether this lane is selected in the GUI
Definition GUIEdge.cpp:655
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition GUIEdge.cpp:660
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition GUIEdge.cpp:468
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition GUIEdge.h:238
~GUIEdge()
Destructor.
Definition GUIEdge.cpp:73
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own type parameter window.
Definition GUIEdge.cpp:221
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:63
The popup menu of a globject.
static const double INVALID_PRIORITY
Definition GUIGlObject.h:73
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.
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.
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:1460
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GUILane.cpp:529
bool isClosed() const
Definition GUILane.h:266
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1560
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:1153
const PositionVector & getShape(bool secondary) const override
Definition GUILane.cpp:1091
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition GUILane.cpp:1183
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.
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition GUINet.cpp:572
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:605
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition GUINet.cpp:599
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 schme.
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 schme.
GUIColorer laneColorer
The lane colorer.
GUIVisualizationTextSettings edgeName
Setting bundles for optional drawing names with size and color.
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:333
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
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:972
double getBruttoOccupancy() const
Definition MSEdge.cpp:1609
double getFlow() const
return flow based on meanSpead
Definition MSEdge.cpp:1596
std::set< MSTransportable *, ComparatorNumericalIdLess > myContainers
Containers on the edge.
Definition MSEdge.h:941
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:649
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
void rebuildAllowedLanes(const bool onInit=false)
Definition MSEdge.cpp:322
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:909
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:1158
MSEdgeVector myPredecessors
The preceeding edges.
Definition MSEdge.h:931
const MSJunction * getToJunction() const
Definition MSEdge.h:418
double getLength() const
return the length of the edge
Definition MSEdge.h:685
virtual void closeBuilding()
Definition MSEdge.cpp:205
const MSJunction * getFromJunction() const
Definition MSEdge.h:414
double getMeanSpeed() const
get the mean speed
Definition MSEdge.cpp:957
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition MSEdge.h:1016
std::set< MSTransportable *, ComparatorNumericalIdLess > myPersons
Persons on the edge for drawing and pushbutton.
Definition MSEdge.h:938
bool isTazConnector() const
Definition MSEdge.h:291
MSEdgeVector mySuccessors
The succeeding edges.
Definition MSEdge.h:926
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:268
double getTimePenalty() const
Definition MSEdge.h:486
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:998
int getVehicleNumber() const
return total number of vehicles on this edges lanes or segments
Definition MSEdge.cpp:1532
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:1041
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1258
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:903
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:606
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:185
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:320
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:431
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
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:322
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:132
void mul(double val)
Multiplies position 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
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: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 or vias to use.