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