Eclipse SUMO - Simulation of Urban MObility
GUIViewTraffic.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 /****************************************************************************/
22 // A view on the simulation; this view is a microscopic one
23 /****************************************************************************/
24 #include <config.h>
25 
26 #ifdef HAVE_FFMPEG
28 #endif
29 
30 #include <iostream>
31 #include <utility>
32 #include <cmath>
33 #include <limits>
34 #include <guisim/GUINet.h>
35 #include <guisim/GUIEdge.h>
36 #include <guisim/GUILane.h>
37 #include <guisim/GUIVehicle.h>
39 #include <microsim/MSGlobals.h>
40 #include <microsim/MSEdge.h>
41 #include <microsim/MSLane.h>
46 #include <utils/common/RGBColor.h>
49 #include "GUISUMOViewParent.h"
50 #include "GUIViewTraffic.h"
62 #include <utils/gui/div/GLHelper.h>
65 
66 /* -------------------------------------------------------------------------
67  * GUIViewTraffic - FOX callback mapping
68  * ----------------------------------------------------------------------- */
69 FXDEFMAP(GUIViewTraffic) GUIViewTrafficMap[] = {
70  FXMAPFUNC(SEL_COMMAND, MID_CLOSE_LANE, GUIViewTraffic::onCmdCloseLane),
71  FXMAPFUNC(SEL_COMMAND, MID_CLOSE_EDGE, GUIViewTraffic::onCmdCloseEdge),
72  FXMAPFUNC(SEL_COMMAND, MID_ADD_REROUTER, GUIViewTraffic::onCmdAddRerouter),
74 };
75 
76 
77 FXIMPLEMENT_ABSTRACT(GUIViewTraffic, GUISUMOAbstractView, GUIViewTrafficMap, ARRAYNUMBER(GUIViewTrafficMap))
78 
79 
80 // ===========================================================================
81 // member method definitions
82 // ===========================================================================
84  FXComposite* p,
85  GUIMainWindow& app,
86  GUISUMOViewParent* parent,
87  GUINet& net, FXGLVisual* glVis,
88  FXGLCanvas* share) :
89  GUISUMOAbstractView(p, app, parent, net.getVisualisationSpeedUp(), glVis, share),
90  myTrackedID(GUIGlObject::INVALID_ID),
91  myTLSGame(OptionsCont::getOptions().getString("game.mode") == "tls")
92 #ifdef HAVE_FFMPEG
93  , myCurrentVideo(nullptr)
94 #endif
95 {}
96 
97 
99  endSnapshot();
100 }
101 
102 
103 void
105  //
106 }
107 
108 
109 void
111  // build coloring tools
112  {
113  const std::vector<std::string>& names = gSchemeStorage.getNames();
114  for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
115  v->getColoringSchemesCombo()->appendItem(i->c_str());
116  if ((*i) == myVisualizationSettings->name) {
117  v->getColoringSchemesCombo()->setCurrentItem(v->getColoringSchemesCombo()->getNumItems() - 1);
118  }
119  }
120  v->getColoringSchemesCombo()->setNumVisible(MAX2(5, (int)names.size() + 1));
121  }
122  // for junctions
123  new FXButton(v->getLocatorPopup(),
124  "\tLocate Junctions\tLocate a junction within the network.",
126  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
127  // for edges
128  new FXButton(v->getLocatorPopup(),
129  "\tLocate Edges\tLocate an edge within the network.",
131  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
132  // for vehicles
133  new FXButton(v->getLocatorPopup(),
134  "\tLocate Vehicles\tLocate a vehicle within the network.",
136  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
137  // for persons
138  new FXButton(v->getLocatorPopup(),
139  "\tLocate Persons\tLocate a person within the network.",
141  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
142  // for containers
143  new FXButton(v->getLocatorPopup(),
144  "\tLocate Container\tLocate a container within the network.",
146  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
147  // for tls
148  new FXButton(v->getLocatorPopup(),
149  "\tLocate TLS\tLocate a tls within the network.",
151  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
152  // for additional stuff
153  new FXButton(v->getLocatorPopup(),
154  "\tLocate Additional\tLocate an additional structure within the network.",
156  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
157  // for pois
158  new FXButton(v->getLocatorPopup(),
159  "\tLocate PoI\tLocate a PoI within the network.",
161  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
162  // for polygons
163  new FXButton(v->getLocatorPopup(),
164  "\tLocate Polygon\tLocate a Polygon within the network.",
166  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
167 }
168 
169 
170 bool
171 GUIViewTraffic::setColorScheme(const std::string& name) {
172  if (!gSchemeStorage.contains(name)) {
173  return false;
174  }
175  if (myVisualizationChanger != nullptr) {
176  if (myVisualizationChanger->getCurrentScheme() != name) {
178  }
179  }
180  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
182  update();
183  return true;
184 }
185 
186 
187 void
189  bool hide, double hideThreshold) {
190  assert(!scheme.isFixed());
191  double minValue = std::numeric_limits<double>::infinity();
192  double maxValue = -std::numeric_limits<double>::infinity();
193  // retrieve range
194  if (objectType == GLO_LANE) {
195  // XXX (see #3409) multi-colors are not currently handled. this is a quick hack
196  if (active == 22) {
197  active = 21; // segment height, fall back to start height
198  } else if (active == 24) {
199  active = 23; // segment incline, fall back to total incline
200  }
201  const MSEdgeVector& edges = MSEdge::getAllEdges();
202  for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
204  const double val = static_cast<GUIEdge*>(*it)->getColorValue(s, active);
205  if (val == s.MISSING_DATA) {
206  continue;
207  }
208  minValue = MIN2(minValue, val);
209  maxValue = MAX2(maxValue, val);
210  } else {
211  const std::vector<MSLane*>& lanes = (*it)->getLanes();
212  for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
213  const double val = static_cast<GUILane*>(*it_l)->getColorValue(s, active);
214  if (val == s.MISSING_DATA) {
215  continue;
216  }
217  minValue = MIN2(minValue, val);
218  maxValue = MAX2(maxValue, val);
219  }
220  }
221  }
222  } else if (objectType == GLO_JUNCTION) {
223  if (active == 3) {
224  std::set<const MSJunction*> junctions;
225  for (MSEdge* edge : MSEdge::getAllEdges()) {
226  junctions.insert(edge->getFromJunction());
227  junctions.insert(edge->getToJunction());
228  }
229  for (const MSJunction* junction : junctions) {
230  minValue = MIN2(minValue, junction->getPosition().z());
231  maxValue = MAX2(maxValue, junction->getPosition().z());
232  }
233  }
234  }
236  scheme.clear();
237  // add threshold for every distinct value
238  std::set<SVCPermissions> codes;
239  for (MSEdge* edge : MSEdge::getAllEdges()) {
240  for (MSLane* lane : edge->getLanes()) {
241  codes.insert(lane->getPermissions());
242  }
243  }
244  int step = MAX2(1, 360 / (int)codes.size());
245  int hue = 0;
246  for (SVCPermissions p : codes) {
247  scheme.addColor(RGBColor::fromHSV(hue, 1, 1), p);
248  hue = (hue + step) % 360;
249  }
250  return;
251  }
252 
253  if (minValue != std::numeric_limits<double>::infinity()) {
254  scheme.clear();
255  // add new thresholds
257  scheme.addColor(RGBColor(204, 204, 204), std::numeric_limits<double>::max(), "missing data");
258  }
259  if (hide) {
260  const double rawRange = maxValue - minValue;
261  minValue = MAX2(hideThreshold + MIN2(1.0, rawRange / 100.0), minValue);
262  scheme.addColor(RGBColor(204, 204, 204), hideThreshold);
263  }
264  double range = maxValue - minValue;
265  scheme.addColor(RGBColor::RED, (minValue));
266  scheme.addColor(RGBColor::ORANGE, (minValue + range * 1 / 6.0));
267  scheme.addColor(RGBColor::YELLOW, (minValue + range * 2 / 6.0));
268  scheme.addColor(RGBColor::GREEN, (minValue + range * 3 / 6.0));
269  scheme.addColor(RGBColor::CYAN, (minValue + range * 4 / 6.0));
270  scheme.addColor(RGBColor::BLUE, (minValue + range * 5 / 6.0));
271  scheme.addColor(RGBColor::MAGENTA, (maxValue));
272  }
273 }
274 
275 
276 std::vector<std::string>
278  if (GUINet::getGUIInstance() != nullptr) {
280  }
281  return std::vector<std::string>();
282 }
283 
284 
285 std::vector<std::string>
287  std::set<std::string> keys;
288  for (const MSEdge* e : MSEdge::getAllEdges()) {
289  if (edgeKeys) {
290  for (const auto& item : e->getParametersMap()) {
291  keys.insert(item.first);
292  }
293  } else {
294  for (const auto lane : e->getLanes()) {
295  for (const auto& item : lane->getParametersMap()) {
296  keys.insert(item.first);
297  }
298  }
299  }
300  }
301  return std::vector<std::string>(keys.begin(), keys.end());
302 }
303 
304 
305 std::vector<std::string>
306 GUIViewTraffic::getVehicleParamKeys(bool /*vTypeKeys*/) const {
307  std::set<std::string> keys;
309  vc->secureVehicles();
310  for (auto vehIt = vc->loadedVehBegin(); vehIt != vc->loadedVehEnd(); ++vehIt) {
311  for (auto kv : vehIt->second->getParameter().getParametersMap()) {
312  keys.insert(kv.first);
313  }
314  }
315  vc->releaseVehicles();
316  return std::vector<std::string>(keys.begin(), keys.end());
317 }
318 
319 std::vector<std::string>
321  std::set<std::string> keys;
322  const ShapeContainer::POIs& pois = static_cast<ShapeContainer&>(GUINet::getInstance()->getShapeContainer()).getPOIs();
323  for (auto item : pois) {
324  for (auto kv : item.second->getParametersMap()) {
325  keys.insert(kv.first);
326  }
327  }
328  return std::vector<std::string>(keys.begin(), keys.end());
329 }
330 
331 int
332 GUIViewTraffic::doPaintGL(int mode, const Boundary& bound) {
333  // (uncomment the next line to check select mode)
334  //myVisualizationSettings->drawForPositionSelection = true;
335  // init view settings
336  glRenderMode(mode);
337  glMatrixMode(GL_MODELVIEW);
339  glDisable(GL_TEXTURE_2D);
340  glDisable(GL_ALPHA_TEST);
341  glEnable(GL_BLEND);
342  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
343  glEnable(GL_DEPTH_TEST);
344 
345  // draw decals (if not in grabbing mode)
346  drawDecals();
348  paintGLGrid();
349  }
350 
351 
352  glLineWidth(1);
353  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
354  const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
355  const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
357  glEnable(GL_POLYGON_OFFSET_FILL);
358  glEnable(GL_POLYGON_OFFSET_LINE);
359  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
360  // Draw additional objects
361  if (myAdditionallyDrawn.size() > 0) {
362  glTranslated(0, 0, -.01);
364  for (auto i : myAdditionallyDrawn) {
365  i.first->drawGLAdditional(this, *myVisualizationSettings);
366  }
368  glTranslated(0, 0, .01);
369  }
371  /*
372  // draw legends
373  glMatrixMode(GL_MODELVIEW);
374  glLoadIdentity();
375  glTranslated(1.-.2, 1.-.5, 0.);
376  glScaled(.2, .5, 1.);
377  GUIColoringSchemesMap<GUILane> &sm = GUIViewTraffic::getLaneSchemesMap(); //!!!
378  sm.getColorer(myVisualizationSettings->laneEdgeMode)->drawLegend();
379  */
380  return hits2;
381 }
382 
383 
384 void
386  myTrackedID = id;
387 }
388 
389 
390 void
393 }
394 
395 
396 GUIGlID
398  return myTrackedID;
399 }
400 
401 
402 void
404  if (myTLSGame) {
406  const MSTrafficLightLogic* minTll = nullptr;
407  double minDist = std::numeric_limits<double>::infinity();
408  for (const MSTrafficLightLogic* const tll : tlsControl.getAllLogics()) {
409  if (tlsControl.isActive(tll) && tll->getProgramID() != "off") {
410  // get the links
411  const MSTrafficLightLogic::LaneVector& lanes = tll->getLanesAt(0);
412  if (lanes.size() > 0) {
413  const Position& endPos = lanes[0]->getShape().back();
414  if (endPos.distanceTo(pos) < minDist) {
415  minDist = endPos.distanceTo(pos);
416  minTll = tll;
417  }
418  }
419  }
420  }
421  if (minTll != nullptr) {
422  const MSTLLogicControl::TLSLogicVariants& vars = tlsControl.get(minTll->getID());
423  const std::vector<MSTrafficLightLogic*> logics = vars.getAllLogics();
424  if (logics.size() > 1) {
426  for (int i = 0; i < (int)logics.size() - 1; ++i) {
427  if (minTll->getProgramID() == logics[i]->getProgramID()) {
428  l = (MSSimpleTrafficLightLogic*) logics[i + 1];
429  tlsControl.switchTo(minTll->getID(), l->getProgramID());
430  }
431  }
432  if (l == logics[0]) {
433  tlsControl.switchTo(minTll->getID(), l->getProgramID());
434  }
436  update();
437  }
438  }
439  } else {
440  // DRT game
442  return;
443  }
444  const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
445  if (sel.size() == 0) {
446  // find closest pt vehicle
447  double minDist = std::numeric_limits<double>::infinity();
448  GUIVehicle* closest = nullptr;
452  for (it = vc.loadedVehBegin(); it != end; ++it) {
453  GUIVehicle* veh = dynamic_cast<GUIVehicle*>(it->second);
454  assert(veh != 0);
455  if (veh->getParameter().line != "") {
456  const double dist = veh->getPosition().distanceTo2D(pos);
457  if (dist < minDist) {
458  minDist = dist;
459  closest = veh;
460  }
461  }
462  }
463  if (closest != nullptr) {
464  gSelected.select(closest->getGlID());
466  }
467  } else {
468  // find closest pt stop
469  double minDist = std::numeric_limits<double>::infinity();
470  MSStoppingPlace* closestStop = nullptr;
472  for (auto it = stops.begin(); it != stops.end(); ++it) {
473  MSStoppingPlace* stop = it->second;
474  const double dist = pos.distanceTo2D(stop->getLane().geometryPositionAtOffset(stop->getEndLanePosition()));
475  if (dist < minDist) {
476  minDist = dist;
477  closestStop = stop;
478  }
479  }
480  if (closestStop != 0) {
481  GUIGlID id = *sel.begin();
483  assert(veh != 0);
484  MSLane* lane = veh->getMutableLane();
485  lane->getVehiclesSecure();
486  veh->rerouteDRTStop(closestStop);
488  lane->releaseVehicles();
489  }
490  }
491  }
492 }
493 
494 
495 void
497  const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
498  if (sel.size() > 0) {
499  GUIGlID id = *sel.begin();
501  if (veh != 0) {
503  }
505  }
506  gSelected.clear();
507 }
508 
509 
510 SUMOTime
513 }
514 
515 
516 GUILane*
518  if (makeCurrent()) {
519  int id = getObjectUnderCursor();
520  if (id != 0) {
522  if (o != nullptr) {
523  return dynamic_cast<GUILane*>(o);
524  }
525  }
526  makeNonCurrent();
527  }
528  return nullptr;
529 }
530 
531 long
532 GUIViewTraffic::onCmdCloseLane(FXObject*, FXSelector, void*) {
533  GUILane* lane = getLaneUnderCursor();
534  if (lane != nullptr) {
535  lane->closeTraffic();
537  update();
538  }
539  return 1;
540 }
541 
542 
543 long
544 GUIViewTraffic::onCmdCloseEdge(FXObject*, FXSelector, void*) {
545  GUILane* lane = getLaneUnderCursor();
546  if (lane != nullptr) {
547  dynamic_cast<GUIEdge*>(&lane->getEdge())->closeTraffic(lane);
549  update();
550  }
551  return 1;
552 }
553 
554 
555 long
556 GUIViewTraffic::onCmdAddRerouter(FXObject*, FXSelector, void*) {
557  GUILane* lane = getLaneUnderCursor();
558  if (lane != nullptr) {
559  dynamic_cast<GUIEdge*>(&lane->getEdge())->addRerouter();
561  update();
562  }
563  return 1;
564 }
565 
566 
567 long
568 GUIViewTraffic::onCmdShowReachability(FXObject* menu, FXSelector, void*) {
569  GUILane* lane = getLaneUnderCursor();
570  if (lane != nullptr) {
571  // reset
572  const double UNREACHABLE = -1;
573  gSelected.clear();
574  for (const MSEdge* const e : MSEdge::getAllEdges()) {
575  for (MSLane* const l : e->getLanes()) {
576  GUILane* gLane = dynamic_cast<GUILane*>(l);
578  }
579  }
580  // prepare
581  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
582  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
583  const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(svc).maxSpeed;
584  // find reachable
585  std::map<MSEdge*, double> reachableEdges;
586  reachableEdges[&lane->getEdge()] = 0;
587  MSEdgeVector check;
588  check.push_back(&lane->getEdge());
589  while (check.size() > 0) {
590  MSEdge* e = check.front();
591  check.erase(check.begin());
592  double traveltime = reachableEdges[e];
593  for (MSLane* const l : e->getLanes()) {
594  if (l->allowsVehicleClass(svc)) {
595  GUILane* gLane = dynamic_cast<GUILane*>(l);
596  gSelected.select(gLane->getGlID());
597  gLane->setReachability(traveltime);
598  }
599  }
600  traveltime += e->getLength() / MIN2(e->getSpeedLimit(), defaultMaxSpeed);
601  for (MSEdge* const nextEdge : e->getSuccessors(svc)) {
602  if (reachableEdges.count(nextEdge) == 0 ||
603  // revisit edge via faster path
604  reachableEdges[nextEdge] > traveltime) {
605  reachableEdges[nextEdge] = traveltime;
606  check.push_back(nextEdge);
607  }
608  }
609  }
610  // switch to 'color by selection' unless coloring 'by reachability'
613  }
614  update();
615  }
616  return 1;
617 }
618 
619 
620 long
621 GUIViewTraffic::onDoubleClicked(FXObject*, FXSelector, void*) {
622  // leave fullscreen mode
623  if (myApp->isFullScreen()) {
624  myApp->onCmdFullScreen(nullptr, 0, nullptr);
625  } else {
626  stopTrack();
627  }
628  return 1;
629 }
630 
631 
632 
633 void
634 GUIViewTraffic::saveFrame(const std::string& destFile, FXColor* buf) {
635 #ifdef HAVE_FFMPEG
636  if (myCurrentVideo == nullptr) {
637  myCurrentVideo = new GUIVideoEncoder(destFile.c_str(), getWidth(), getHeight(), myApp->getDelay());
638  }
639  myCurrentVideo->writeFrame((uint8_t*)buf);
640 #else
641  UNUSED_PARAMETER(destFile);
642  UNUSED_PARAMETER(buf);
643 #endif
644 }
645 
646 
647 void
649 #ifdef HAVE_FFMPEG
650  if (myCurrentVideo != nullptr) {
651  delete myCurrentVideo;
652  myCurrentVideo = nullptr;
653  }
654 #endif
655 }
656 
657 
658 void
660 #ifdef HAVE_FFMPEG
661  if (myCurrentVideo != nullptr) {
663  }
664 #endif
666 }
667 
668 
669 const std::vector<SUMOTime>
671  return myApp->retrieveBreakpoints();
672 }
673 
674 
675 /****************************************************************************/
#define UNREACHABLE
@ MID_LOCATEPERSON
Locate person - button.
Definition: GUIAppEnum.h:359
@ MID_LOCATEJUNCTION
Locate junction - button.
Definition: GUIAppEnum.h:349
@ MID_LOCATEPOLY
Locate polygons - button.
Definition: GUIAppEnum.h:369
@ MID_LOCATEADD
Locate addtional structure - button.
Definition: GUIAppEnum.h:365
@ MID_LOCATEPOI
Locate poi - button.
Definition: GUIAppEnum.h:367
@ MID_REACHABILITY
show reachability from a given lane
Definition: GUIAppEnum.h:485
@ MID_CLOSE_LANE
close lane
Definition: GUIAppEnum.h:606
@ MID_LOCATEEDGE
Locate edge - button.
Definition: GUIAppEnum.h:351
@ MID_LOCATEVEHICLE
Locate vehicle - button.
Definition: GUIAppEnum.h:353
@ MID_LOCATETLS
Locate TLS - button.
Definition: GUIAppEnum.h:363
@ MID_CLOSE_EDGE
close edge
Definition: GUIAppEnum.h:608
@ MID_ADD_REROUTER
add rerouter
Definition: GUIAppEnum.h:610
@ MID_LOCATECONTAINER
Locate container - button.
Definition: GUIAppEnum.h:361
GUICompleteSchemeStorage gSchemeStorage
unsigned int GUIGlID
Definition: GUIGlObject.h:40
GUIGlObjectType
@ GLO_JUNCTION
a junction
@ GLO_LANE
a lane
@ GLO_VEHICLE
a vehicle
GUISelectedStorage gSelected
A global holder of selected objects.
@ LOCATEVEHICLE
@ LOCATEPERSON
@ LOCATECONTAINER
@ LOCATEJUNCTION
FXDEFMAP(GUIViewTraffic) GUIViewTrafficMap[]
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define INVALID_ID
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
long long int SUMOTime
Definition: SUMOTime.h:32
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_BUS_STOP
A bus stop.
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MIN2(T a, T b)
Definition: StdDefs.h:74
T MAX2(T a, T b)
Definition: StdDefs.h:80
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:129
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:117
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:135
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:123
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
void addActiveAddVisualisation(GUISUMOAbstractView *const parent, int which)
Adds the named visualisation feature to the given view.
@ VO_SHOW_FUTURE_ROUTE
show vehicle's current continued from the current position
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
const std::vector< std::string > & getNames() const
Returns a list of stored settings names.
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
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
FXComboBox * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world....
FXPopup * getLocatorPopup()
@ brief return a pointer to locator popup
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:67
GUIGlID getGlID() const
Returns the numerical id of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:59
void setReachability(double value)
Definition: GUILane.h:245
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1430
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1161
bool isFullScreen()
virtual double getDelay() const
Returns the delay (should be overwritten by subclasses if applicable)
virtual long onCmdFullScreen(FXObject *, FXSelector, void *)
Toggle full screen mode.
bool isGaming() const
return whether the gui is in gaming mode
virtual const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:81
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:543
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:555
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:672
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:549
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:533
const std::string & getName() const
int addColor(const T &color, const double threshold, const std::string &name="")
void paintGLGrid()
paints a grid
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
const SUMORTree * myGrid
The visualization speed-up.
GUIDialog_ViewSettings * myVisualizationChanger
Visualization changer.
FXbool makeCurrent()
A reimplementation due to some internal reasons.
void addSnapshot(SUMOTime time, const std::string &file, const int w=-1, const int h=-1)
Sets the snapshot time to file map.
GUIGlID getObjectUnderCursor()
returns the id of the front object under the cursor using GL_SELECT
GUIMainWindow * myApp
The application.
double m2p(double meter) const
meter-to-pixels conversion method
GUIVisualizationSettings * myVisualizationSettings
visualization settings
std::map< GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
void drawDecals()
Draws the stored decals.
A single child window which contains a view of the simulation area.
void clear()
Clears the list of selected objects.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
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: GUIVehicle.h:51
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: GUIVehicle.h:71
void rerouteDRTStop(MSStoppingPlace *busStop)
handle route to accomodate to given stop
Definition: GUIVehicle.cpp:985
A simple video encoder from RGBA pics to anything ffmpeg can handle.
long onCmdCloseEdge(FXObject *, FXSelector, void *)
long onCmdCloseLane(FXObject *, FXSelector, void *)
interaction with the simulation
void recalculateBoundaries()
recalculate boundaries
virtual ~GUIViewTraffic()
destructor
std::vector< std::string > getEdgeLaneParamKeys(bool edgeKeys) const
return list of available edge parameters
void onGamingRightClick(Position pos)
int doPaintGL(int mode, const Boundary &bound)
paint GL
SUMOTime getCurrentTimeStep() const
get the current simulation time
GUILane * getLaneUnderCursor()
void buildColorRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, int active, GUIGlObjectType objectType, bool hide=false, double hideThreshold=0)
recalibrate color scheme according to the current value range
void stopTrack()
Stops vehicle tracking.
void startTrack(int id)
Starts vehicle tracking.
void saveFrame(const std::string &destFile, FXColor *buf)
Adds a frame to a video snapshot which will be initialized if neccessary.
void endSnapshot()
Ends a video snapshot.
const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints from the current runThread
std::vector< std::string > getVehicleParamKeys(bool vTypeKeys) const
return list of available vehicle parameters
std::vector< std::string > getPOIParamKeys() const
return list of available POI parameters
long onCmdAddRerouter(FXObject *, FXSelector, void *)
void onGamingClick(Position pos)
handle mouse click in gaming mode
long onCmdShowReachability(FXObject *, FXSelector, void *)
highlight edges according to reachability
bool setColorScheme(const std::string &name)
set color scheme
long onDoubleClicked(FXObject *, FXSelector, void *)
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
virtual void buildViewToolBars(GUIGlChildWindow *)
builds the view toolbars
bool myTLSGame
whether game mode was set to 'tls'
void checkSnapshots()
Checks whether it is time for a snapshot.
GUIGlID getTrackedID() const
Returns the id of the tracked vehicle (-1 if none)
Stores the information about how to visualize structures.
static const std::string SCHEME_NAME_EDGEDATA_NUMERICAL
std::string name
The name of this setting.
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
bool gaming
whether the application is in gaming mode or not
bool showGrid
Information whether a grid shall be shown.
double scale
information about a lane's width (temporary, used for a single view)
GUIColorer laneColorer
The lane colorer.
static const std::string SCHEME_NAME_PERMISSION_CODE
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
A road/street connecting two junctions.
Definition: MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:918
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
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
double getLength() const
return the length of the edge
Definition: MSEdge.h:641
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1084
static bool gUseMesoSim
Definition: MSGlobals.h:94
The base class for an intersection.
Definition: MSJunction.h:58
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:428
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:458
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:449
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:499
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:1273
SUMOTime duration
The duration of the phase.
A fixed traffic light logic.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
A lane area vehicles can halt at.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
Storage for all programs of a single tls.
std::vector< MSTrafficLightLogic * > getAllLogics() const
A class that stores and controls tls and switching of their programs.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
void switchTo(const std::string &id, const std::string &programID)
Switches the named (id) tls to the named (programID) program.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
bool isActive(const MSTrafficLightLogic *tl) const
Returns whether the given tls program is the currently active for his tls.
The parent class for traffic light logics.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
const std::string & getProgramID() const
Returns this tl-logic's id.
The class responsible for building and deletion of vehicles.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Definition: MSVehicle.h:560
const std::string & getID() const
Returns the id.
Definition: Named.h:74
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
A storage for options typed value containers)
Definition: OptionsCont.h:89
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:242
static const RGBColor BLUE
Definition: RGBColor.h:187
static const RGBColor YELLOW
Definition: RGBColor.h:188
static const RGBColor ORANGE
Definition: RGBColor.h:191
static const RGBColor CYAN
Definition: RGBColor.h:189
static const RGBColor GREEN
Definition: RGBColor.h:186
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition: RGBColor.cpp:368
static const RGBColor MAGENTA
Definition: RGBColor.h:190
static const RGBColor RED
named colors
Definition: RGBColor.h:185
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
Definition: SUMORTree.h:116
std::string line
The vehicle's line (mainly for public transport)
Storage for geometrical objects.
struct for default values that depend of VClass
double maxSpeed
The vehicle type's maximum speed [m/s].