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>
33 #include <utils/geom/GeomHelper.h>
35 #include <utils/gui/div/GLHelper.h>
38 #include <microsim/MSBaseVehicle.h>
39 #include <microsim/MSEdge.h>
40 #include <microsim/MSJunction.h>
41 #include <microsim/MSLaneChanger.h>
43 #include <microsim/MSGlobals.h>
48 #include <mesogui/GUIMEVehicle.h>
49 #include <mesosim/MESegment.h>
50 #include <mesosim/MELoop.h>
51 #include <mesosim/MEVehicle.h>
52 
53 #include "GUITriggeredRerouter.h"
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 
62 GUIEdge::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),
67  GUIGlObject(GLO_EDGE, id),
68  myLock(true)
69 {}
70 
71 
73  // just to quit cleanly on a failure
74  if (myLock.locked()) {
75  myLock.unlock();
76  }
77 }
78 
79 void
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 
95 MSLane&
96 GUIEdge::getLane(int laneNo) {
97  assert(laneNo < (int)myLanes->size());
98  return *((*myLanes)[laneNo]);
99 }
100 
101 
102 std::vector<GUIGlID>
103 GUIEdge::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 
117 double
118 GUIEdge::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 ? edge->getLanes().size() : 1);
125  }
126  }
127  return result;
128 }
129 
130 
131 Boundary
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, false);
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 vehicle speed [m/s]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getMeanSpeed));
188  ret->mkItem("routing speed [m/s]", true, new FunctionBinding<MSEdge, double>(this, &MSEdge::getRoutingSpeed));
189  ret->mkItem("brutto occupancy [%]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getBruttoOccupancy, 100.));
190  ret->mkItem("flow [veh/h/lane]", true, new FunctionBinding<GUIEdge, double>(this, &GUIEdge::getFlow));
192  // add segment items
194  ret->mkItem("segment index", false, segment->getIndex());
195  ret->mkItem("segment queues", false, segment->numQueues());
196  ret->mkItem("segment length [m]", false, segment->getLength());
197  ret->mkItem("segment allowed speed [m/s]", false, segment->getEdge().getSpeedLimit());
198  ret->mkItem("segment jam threshold [%]", false, segment->getRelativeJamThreshold() * 100);
199  ret->mkItem("segment brutto occupancy [%]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getRelativeOccupancy, 100));
200  ret->mkItem("segment mean vehicle speed [m/s]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getMeanSpeed));
201  ret->mkItem("segment flow [veh/h/lane]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getFlow));
202  ret->mkItem("segment #vehicles", true, new CastingFunctionBinding<MESegment, int, int>(segment, &MESegment::getCarNumber));
203  ret->mkItem("segment leader leave time", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEventTimeSeconds));
204  ret->mkItem("segment headway [s]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getLastHeadwaySeconds));
205  ret->mkItem("segment entry blocktime [s]", true, new FunctionBinding<MESegment, double>(segment, &MESegment::getEntryBlockTimeSeconds));
206  // lane params
207  for (MSLane* lane : *myLanes) {
208  for (const auto& kv : lane->getParametersMap()) {
209  ret->mkItem(("laneParam " + toString(lane->getIndex()) + ":" + kv.first).c_str(), false, kv.second);
210  }
211  }
212  // close building
213  ret->closeBuilding();
214  return ret;
215 }
216 
220  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
222  // add items
223  ret->mkItem("Type Information:", false, "");
224  ret->mkItem("type [id]", false, getEdgeType());
225  ret->mkItem("tauff", false, STEPS2TIME(edgeType.tauff));
226  ret->mkItem("taufj", false, STEPS2TIME(edgeType.taufj));
227  ret->mkItem("taujf", false, STEPS2TIME(edgeType.taujf));
228  ret->mkItem("taujj", false, STEPS2TIME(edgeType.taujj));
229  ret->mkItem("jam threshold", false, edgeType.jamThreshold);
230  ret->mkItem("junction control", false, edgeType.junctionControl);
231  ret->mkItem("tls penalty", false, edgeType.tlsPenalty);
232  ret->mkItem("tls flow penalty", false, edgeType.tlsFlowPenalty);
233  ret->mkItem("minor penalty", false, STEPS2TIME(edgeType.minorPenalty));
234  ret->mkItem("overtaking", false, edgeType.overtaking);
235  // close building
236  ret->closeBuilding();
237  return ret;
238 }
239 
240 
241 double
243  return 1;
244 }
245 
246 
247 Boundary
249  Boundary b = getBoundary();
250  // ensure that vehicles and persons on the side are drawn even if the edge
251  // is outside the view
252  b.grow(10);
253  return b;
254 }
255 
256 const std::string
258  return myStreetName;
259 }
260 
261 void
264  return;
265  }
267  // draw the lanes
269  setColor(s);
270  }
271  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
272  static_cast<GUILane*>(*i)->drawGL(s);
273  }
275  if (s.scale * s.vehicleSize.getExaggeration(s, nullptr) > s.vehicleSize.minSize) {
276  drawMesoVehicles(s);
277  }
278  }
280  // (optionally) draw the name and/or the street name
281  GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back());
282  const GUIGlObject* selCheck = gSelected.isSelected(this) ? (GUIGlObject*)this : (GUIGlObject*)lane2;
283  const bool drawEdgeName = s.edgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::NORMAL;
284  const bool drawInternalEdgeName = s.internalEdgeName.show(selCheck) && myFunction == SumoXMLEdgeFunc::INTERNAL;
285  const bool drawCwaEdgeName = s.cwaEdgeName.show(selCheck) && (myFunction == SumoXMLEdgeFunc::CROSSING || myFunction == SumoXMLEdgeFunc::WALKINGAREA);
286  const bool drawStreetName = s.streetName.show(selCheck) && myStreetName != "";
287  const bool drawEdgeValue = s.edgeValue.show(selCheck) && (myFunction == SumoXMLEdgeFunc::NORMAL
290  if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName || drawEdgeValue) {
291  GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]);
292  if (lane1 != nullptr && lane2 != nullptr) {
293  const bool spreadSuperposed = s.spreadSuperposed && getBidiEdge() != nullptr && lane2->drawAsRailway(s);
294  Position p = lane1->getShape().positionAtOffset(lane1->getShape().length() / (double) 2.);
295  p.add(lane2->getShape().positionAtOffset(lane2->getShape().length() / (double) 2.));
296  p.mul(.5);
297  if (spreadSuperposed) {
298  // move name to the right of the edge and towards its beginning
299  const double dist = 0.6 * s.edgeName.scaledSize(s.scale);
300  const double shiftA = lane1->getShape().rotationAtOffset(lane1->getShape().length() / (double) 2.) - DEG2RAD(135);
301  Position shift(dist * cos(shiftA), dist * sin(shiftA));
302  p.add(shift);
303  }
304  double angle = s.getTextAngle(lane1->getShape().rotationDegreeAtOffset(lane1->getShape().length() / (double) 2.) + 90);
305  if (drawEdgeName) {
306  drawName(p, s.scale, s.edgeName, angle, true);
307  } else if (drawInternalEdgeName) {
308  drawName(p, s.scale, s.internalEdgeName, angle, true);
309  } else if (drawCwaEdgeName) {
310  drawName(p, s.scale, s.cwaEdgeName, angle, true);
311  }
312  if (drawStreetName) {
314  }
315  if (drawEdgeValue) {
316  const int activeScheme = s.getLaneEdgeMode();
317  std::string value = "";
318  if (activeScheme == 31) {
319  // edge param, could be non-numerical
320  value = getParameter(s.edgeParam, "");
321  } else if (activeScheme == 32) {
322  // lane param, could be non-numerical
323  value = lane2->getParameter(s.laneParam, "");
324  } else {
325  // use numerical value value of leftmost lane to hopefully avoid sidewalks, bikelanes etc
326  const double doubleValue = (MSGlobals::gUseMesoSim
327  ? getColorValue(s, activeScheme)
328  : lane2->getColorValueWithFunctional(s, activeScheme));
329  const RGBColor color = (MSGlobals::gUseMesoSim ? s.edgeColorer : s.laneColorer).getScheme().getColor(doubleValue);
330  if (doubleValue != s.MISSING_DATA
331  && color.alpha() != 0
332  && (!s.edgeValueHideCheck || doubleValue > s.edgeValueHideThreshold)) {
333  value = toString(doubleValue);
334  }
335  }
336  if (value != "") {
337  if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName) {
338  const double dist = 0.4 * (s.edgeName.scaledSize(s.scale) + s.edgeValue.scaledSize(s.scale));
339  const double shiftA = lane1->getShape().rotationAtOffset(lane1->getShape().length() / (double) 2.) - DEG2RAD(90);
340  Position shift(dist * cos(shiftA), dist * sin(shiftA));
341  p.add(shift);
342  }
343  GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, angle);
344  }
345  }
346  }
347  }
348  if (s.scale * s.personSize.getExaggeration(s, nullptr) > s.personSize.minSize) {
349  FXMutexLock locker(myLock);
350  for (MSTransportable* t : myPersons) {
351  GUIPerson* person = dynamic_cast<GUIPerson*>(t);
352  assert(person != 0);
353  person->drawGL(s);
354  }
355  }
356  if (s.scale * s.containerSize.getExaggeration(s, nullptr) > s.containerSize.minSize) {
357  FXMutexLock locker(myLock);
358  for (MSTransportable* t : myContainers) {
359  GUIContainer* container = dynamic_cast<GUIContainer*>(t);
360  assert(container != 0);
361  container->drawGL(s);
362  }
363  }
364 }
365 
366 
367 void
370  const double now = SIMTIME;
371  if (vehicleControl != nullptr) {
372  // draw the meso vehicles
373  vehicleControl->secureVehicles();
374  FXMutexLock locker(myLock);
375  int laneIndex = 0;
376  for (std::vector<MSLane*>::const_iterator msl = myLanes->begin(); msl != myLanes->end(); ++msl, ++laneIndex) {
377  GUILane* l = static_cast<GUILane*>(*msl);
378  // go through the vehicles
379  double segmentOffset = 0; // offset at start of current segment
380  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
381  segment != nullptr; segment = segment->getNextSegment()) {
382  const double length = segment->getLength();
383  if (laneIndex < segment->numQueues()) {
384  // make a copy so we don't have to worry about synchronization
385  std::vector<MEVehicle*> queue = segment->getQueue(laneIndex);
386  const int queueSize = (int)queue.size();
387  double vehiclePosition = segmentOffset + length;
388  // draw vehicles beginning with the leader at the end of the segment
389  double latOff = 0.;
390  for (int i = 0; i < queueSize; ++i) {
391  const GUIMEVehicle* const veh = static_cast<GUIMEVehicle*>(queue[queueSize - i - 1]);
392  const double intendedLeave = MIN2(veh->getEventTimeSeconds(), veh->getBlockTimeSeconds());
393  const double entry = veh->getLastEntryTimeSeconds();
394  const double relPos = segmentOffset + length * (now - entry) / (intendedLeave - entry);
395  if (relPos < vehiclePosition) {
396  vehiclePosition = relPos;
397  }
398  while (vehiclePosition < segmentOffset) {
399  // if there is only a single queue for a
400  // multi-lane edge shift vehicles and start
401  // drawing again from the end of the segment
402  vehiclePosition += length;
403  latOff += 0.2;
404  }
405  const Position p = l->geometryPositionAtOffset(vehiclePosition, latOff);
406  const double angle = l->getShape().rotationAtOffset(l->interpolateLanePosToGeometryPos(vehiclePosition));
407  veh->drawOnPos(s, p, angle);
408  vehiclePosition -= veh->getVehicleType().getLengthWithGap();
409  }
410  }
411  segmentOffset += length;
412  }
414  }
415  vehicleControl->releaseVehicles();
416  }
417 }
418 
419 
420 
421 double
423  return (*myLanes)[0]->getSpeedLimit();
424 }
425 
426 
427 double
429  return getMeanSpeed() / getAllowedSpeed();
430 }
431 
432 
433 void
435  myMesoColor = RGBColor(0, 0, 0); // default background color when using multiColor
436  const GUIColorer& c = s.edgeColorer;
437  if (!setFunctionalColor(c) && !setMultiColor(c)) {
439  }
440 }
441 
442 
443 bool
445  const int activeScheme = c.getActive();
446  int activeMicroScheme = -1;
447  switch (activeScheme) {
448  case 0:
449  activeMicroScheme = 0; // color uniform
450  break;
451  case 9:
452  activeMicroScheme = 18; // color by angle
453  break;
454  case 17:
455  activeMicroScheme = 30; // color by TAZ
456  break;
457  default:
458  return false;
459  }
460  GUILane* guiLane = static_cast<GUILane*>(getLanes()[0]);
461  return guiLane->setFunctionalColor(c, myMesoColor, activeMicroScheme);
462 }
463 
464 
465 bool
467  const int activeScheme = c.getActive();
468  mySegmentColors.clear();
469  switch (activeScheme) {
470  case 10: // alternating segments
471  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
472  segment != nullptr; segment = segment->getNextSegment()) {
473  mySegmentColors.push_back(c.getScheme().getColor(segment->getIndex() % 2));
474  }
475  //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";
476  return true;
477  case 11: // by segment jammed state
478  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
479  segment != nullptr; segment = segment->getNextSegment()) {
480  mySegmentColors.push_back(
481  c.getScheme().getColor(segment->getRelativeOccupancy() > segment->getRelativeJamThreshold() ? 2 :
482  (segment->getRelativeOccupancy() * 2 < segment->getRelativeJamThreshold() ? 0 : 1)));
483  }
484  return true;
485  case 12: // by segment occupancy
486  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
487  segment != nullptr; segment = segment->getNextSegment()) {
488  mySegmentColors.push_back(c.getScheme().getColor(segment->getRelativeOccupancy()));
489  }
490  return true;
491  case 13: // by segment speed
492  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
493  segment != nullptr; segment = segment->getNextSegment()) {
494  mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed()));
495  }
496  return true;
497  case 14: // by segment flow
498  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
499  segment != nullptr; segment = segment->getNextSegment()) {
500  mySegmentColors.push_back(c.getScheme().getColor(3600 * segment->getCarNumber() * segment->getMeanSpeed() / segment->getLength()));
501  }
502  return true;
503  case 15: // by segment relative speed
504  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
505  segment != nullptr; segment = segment->getNextSegment()) {
506  mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed() / getAllowedSpeed()));
507  }
508  return true;
509  default:
510  return false;
511  }
512 }
513 
514 
515 double
516 GUIEdge::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
517  switch (activeScheme) {
518  case 1:
519  return gSelected.isSelected(getType(), getGlID());
520  case 2:
521  return (double)getFunction();
522  case 3:
523  return getAllowedSpeed();
524  case 4:
525  return getBruttoOccupancy();
526  case 5:
527  return getMeanSpeed();
528  case 6:
529  return getFlow();
530  case 7:
531  return getRelativeSpeed();
532  case 8:
533  return getRoutingSpeed();
534  case 16:
535  return getPendingEmits();
536  case 18:
537  // by numerical edge param value
538  try {
540  } catch (NumberFormatException&) {
541  try {
543  } catch (BoolFormatException&) {
544  return -1;
545  }
546  }
547  case 19:
548  // by edge data value
549  return GUINet::getGUIInstance()->getEdgeData(this, s.edgeData);
550  }
551  return 0;
552 }
553 
554 
555 double
556 GUIEdge::getScaleValue(int activeScheme) const {
557  switch (activeScheme) {
558  case 1:
559  return gSelected.isSelected(getType(), getGlID());
560  case 2:
561  return getAllowedSpeed();
562  case 3:
563  return getBruttoOccupancy();
564  case 4:
565  return getMeanSpeed();
566  case 5:
567  return getFlow();
568  case 6:
569  return getRelativeSpeed();
570  case 7:
571  return getPendingEmits();
572  }
573  return 0;
574 }
575 
576 
577 MESegment*
579  const PositionVector& shape = getLanes()[0]->getShape();
580  const double lanePos = shape.nearest_offset_to_point2D(pos);
581  return MSGlobals::gMesoNet->getSegmentForEdge(*this, lanePos);
582 }
583 
584 
585 
586 void
588  const std::vector<MSLane*>& lanes = getLanes();
589  const bool isClosed = lane->isClosed();
590  for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
591  GUILane* l = dynamic_cast<GUILane*>(*i);
592  if (l->isClosed() == isClosed) {
593  l->closeTraffic(false);
594  }
595  }
597 }
598 
599 
600 void
602  MSEdgeVector edges;
603  edges.push_back(this);
604  GUITriggeredRerouter* rr = new GUITriggeredRerouter(getID() + "_dynamic_rerouter", edges, 1, "", false, 0, "",
605  GUINet::getGUIInstance()->getVisualisationSpeedUp());
606 
609  ri.end = SUMOTime_MAX;
611  rr->myIntervals.push_back(ri);
612 
613  // trigger rerouting for vehicles already on this edge
614  const std::vector<MSLane*>& lanes = getLanes();
615  for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
616  const MSLane::VehCont& vehicles = (*i)->getVehiclesSecure();
617  for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
618  if ((*v)->getLane() == (*i)) {
620  } // else: this is the shadow during a continuous lane change
621  }
622  (*i)->releaseVehicles();
623  }
624 }
625 
626 
627 bool
630 }
631 
632 double
635 }
636 
637 /****************************************************************************/
@ GLO_EDGE
an edge
GUISelectedStorage gSelected
A global holder of selected objects.
#define DEG2RAD(x)
Definition: GeomHelper.h:35
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SUMOTime_MAX
Definition: SUMOTime.h:33
#define SIMTIME
Definition: SUMOTime.h:60
@ SVC_PEDESTRIAN
pedestrian
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
T MIN2(T a, T b)
Definition: StdDefs.h:74
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:77
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void popName()
pop Name
Definition: GLHelper.cpp:141
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:640
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
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:516
double getAllowedSpeed() const
Definition: GUIEdge.cpp:422
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIEdge.cpp:178
FXMutex myLock
The mutex used to avoid concurrent updates of myPersons/ myContainers.
Definition: GUIEdge.h:242
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and edge function
Definition: GUIEdge.cpp:466
GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window.
Definition: GUIEdge.cpp:218
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GUIEdge.cpp:434
void drawMesoVehicles(const GUIVisualizationSettings &s) const
Definition: GUIEdge.cpp:368
virtual void closeBuilding()
Has to be called after all edges were built and all connections were set.
Definition: GUIEdge.cpp:80
double getScaleValue(int activeScheme) const
gets the scaling value according to the current scheme index
Definition: GUIEdge.cpp:556
MSLane & getLane(int laneNo)
returns the enumerated lane (!!! why not private with a friend?)
Definition: GUIEdge.cpp:96
double getRelativeSpeed() const
return meanSpead divided by allowedSpeed
Definition: GUIEdge.cpp:428
RGBColor myMesoColor
Definition: GUIEdge.h:244
void closeTraffic(const GUILane *lane)
close this edge for traffic
Definition: GUIEdge.cpp:587
MESegment * getSegmentAtPosition(const Position &pos)
returns the segment closest to the given position
Definition: GUIEdge.cpp:578
const std::string getOptionalName() const
Returns the street name.
Definition: GUIEdge.cpp:257
bool isSelected() const
whether this lane is selected in the GUI
Definition: GUIEdge.cpp:628
void addRerouter()
add a rerouter
Definition: GUIEdge.cpp:601
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:118
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIEdge.cpp:248
Boundary getBoundary() const
Returns the street's geometry.
Definition: GUIEdge.cpp:132
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:103
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GUIEdge.cpp:242
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIEdge.cpp:262
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIEdge.cpp:160
std::vector< RGBColor > mySegmentColors
The color of the segments (cached)
Definition: GUIEdge.h:224
double getPendingEmits() const
get number of vehicles waiting for departure on this edge
Definition: GUIEdge.cpp:633
bool setFunctionalColor(const GUIColorer &c) const
sets the color according to the current scheme index and some edge function
Definition: GUIEdge.cpp:444
bool myShowDeadEnd
whether to highlight this edge as a dead-end edge
Definition: GUIEdge.h:227
~GUIEdge()
Destructor.
Definition: GUIEdge.cpp:72
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 buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
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
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:59
const PositionVector & getShape() const
Definition: GUILane.cpp:987
bool isClosed() const
Definition: GUILane.h:265
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1430
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:1043
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GUILane.cpp:1403
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUILane.cpp:489
bool setFunctionalColor(const GUIColorer &c, RGBColor &col, int activeScheme=-1) const
Definition: GUILane.cpp:1073
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:533
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:566
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:560
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:283
const T getColor(const double value) const
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
GUIVisualizationSizeSettings personSize
GUIVisualizationTextSettings cwaEdgeName
bool hideConnectors
flag to show or hidde 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
value 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:379
double getLastHeadwaySeconds() const
get the last headway time in seconds
Definition: MESegment.h:374
double getRelativeOccupancy() const
Returns the relative occupany of the segment (percentage of road used))
Definition: MESegment.h:262
double getLength() const
Returns the length of the segment in meters.
Definition: MESegment.h:235
int numQueues() const
return the number of queues
Definition: MESegment.h:204
double getRelativeJamThreshold() const
Returns the relative occupany of the segment (percentage of road used)) at which the segment is consi...
Definition: MESegment.h:270
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:352
double getEventTimeSeconds() const
Like getEventTime but returns seconds (for visualization)
Definition: MESegment.h:369
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition: MESegment.h:219
double getMeanSpeed() const
wrapper to satisfy the FunctionBinding signature
Definition: MESegment.h:287
int getCarNumber() const
Returns the total number of cars on the segment.
Definition: MESegment.h:199
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:307
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
Definition: MEVehicle.h:312
double getEventTimeSeconds() const
Returns the earliest leave time for the current segment.
Definition: MEVehicle.h:302
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:917
double getBruttoOccupancy() const
Definition: MSEdge.cpp:1351
double getFlow() const
return flow based on meanSpead
Definition: MSEdge.cpp:1338
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition: MSEdge.h:605
const std::string & getStreetName() const
Returns the street name of the edge.
Definition: MSEdge.h:307
bool isNormal() const
return whether this edge is an internal edge
Definition: MSEdge.h:257
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const SumoXMLEdgeFunc myFunction
the purpose of the edge
Definition: MSEdge.h:864
std::set< MSTransportable * > myContainers
Containers on the edge.
Definition: MSEdge.h:896
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:990
const MSJunction * getFromJunction() const
Definition: MSEdge.h:397
MSEdgeVector myPredecessors
The preceeding edges.
Definition: MSEdge.h:886
void rebuildAllowedLanes()
Definition: MSEdge.cpp:271
double getLength() const
return the length of the edge
Definition: MSEdge.h:641
virtual void closeBuilding()
Definition: MSEdge.cpp:152
double getMeanSpeed() const
get the mean speed
Definition: MSEdge.cpp:814
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSEdge.h:961
bool isTazConnector() const
Definition: MSEdge.h:285
MSEdgeVector mySuccessors
The succeeding edges.
Definition: MSEdge.h:881
std::set< MSTransportable * > myPersons
Persons on the edge for drawing and pushbutton.
Definition: MSEdge.h:893
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:262
int getVehicleNumber() const
return total number of vehicles on this edges lanes or segments
Definition: MSEdge.cpp:1294
const std::string & getEdgeType() const
Returns the type of the edge.
Definition: MSEdge.h:313
const MSJunction * getToJunction() const
Definition: MSEdge.h:401
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
Definition: MSEdge.h:252
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:879
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition: MSEdge.h:276
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1084
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:858
static bool gUseMesoSim
Definition: MSGlobals.h:94
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:100
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:82
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:92
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:499
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:429
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:354
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.