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-2020 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  // build coloring tools
106  {
107  const std::vector<std::string>& names = gSchemeStorage.getNames();
108  for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
109  v->getColoringSchemesCombo()->appendItem(i->c_str());
110  if ((*i) == myVisualizationSettings->name) {
111  v->getColoringSchemesCombo()->setCurrentItem(v->getColoringSchemesCombo()->getNumItems() - 1);
112  }
113  }
114  v->getColoringSchemesCombo()->setNumVisible(MAX2(5, (int)names.size() + 1));
115  }
116  // for junctions
117  new FXButton(v->getLocatorPopup(),
118  "\tLocate Junctions\tLocate a junction within the network.",
120  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
121  // for edges
122  new FXButton(v->getLocatorPopup(),
123  "\tLocate Edges\tLocate an edge within the network.",
125  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
126  // for vehicles
127  new FXButton(v->getLocatorPopup(),
128  "\tLocate Vehicles\tLocate a vehicle within the network.",
130  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
131  // for persons
132  new FXButton(v->getLocatorPopup(),
133  "\tLocate Persons\tLocate a person within the network.",
135  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
136  // for containers
137  new FXButton(v->getLocatorPopup(),
138  "\tLocate Container\tLocate a container within the network.",
140  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
141  // for tls
142  new FXButton(v->getLocatorPopup(),
143  "\tLocate TLS\tLocate a tls within the network.",
145  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
146  // for additional stuff
147  new FXButton(v->getLocatorPopup(),
148  "\tLocate Additional\tLocate an additional structure within the network.",
150  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
151  // for pois
152  new FXButton(v->getLocatorPopup(),
153  "\tLocate PoI\tLocate a PoI within the network.",
155  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
156  // for polygons
157  new FXButton(v->getLocatorPopup(),
158  "\tLocate Polygon\tLocate a Polygon within the network.",
160  ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
161 }
162 
163 
164 bool
165 GUIViewTraffic::setColorScheme(const std::string& name) {
166  if (!gSchemeStorage.contains(name)) {
167  return false;
168  }
169  if (myVisualizationChanger != nullptr) {
170  if (myVisualizationChanger->getCurrentScheme() != name) {
172  }
173  }
174  myVisualizationSettings = &gSchemeStorage.get(name.c_str());
176  update();
177  return true;
178 }
179 
180 
181 void
183  bool hide, double hideThreshold) {
184  assert(!scheme.isFixed());
185  double minValue = std::numeric_limits<double>::infinity();
186  double maxValue = -std::numeric_limits<double>::infinity();
187  // retrieve range
188  if (objectType == GLO_LANE) {
189  // XXX (see #3409) multi-colors are not currently handled. this is a quick hack
190  if (active == 22) {
191  active = 21; // segment height, fall back to start height
192  } else if (active == 24) {
193  active = 23; // segment incline, fall back to total incline
194  }
195  const MSEdgeVector& edges = MSEdge::getAllEdges();
196  for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
198  const double val = static_cast<GUIEdge*>(*it)->getColorValue(s, active);
199  if (val == s.MISSING_DATA) {
200  continue;
201  }
202  minValue = MIN2(minValue, val);
203  maxValue = MAX2(maxValue, val);
204  } else {
205  const std::vector<MSLane*>& lanes = (*it)->getLanes();
206  for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
207  const double val = static_cast<GUILane*>(*it_l)->getColorValue(s, active);
208  if (val == s.MISSING_DATA) {
209  continue;
210  }
211  minValue = MIN2(minValue, val);
212  maxValue = MAX2(maxValue, val);
213  }
214  }
215  }
216  } else if (objectType == GLO_JUNCTION) {
217  if (active == 3) {
218  std::set<const MSJunction*> junctions;
219  for (MSEdge* edge : MSEdge::getAllEdges()) {
220  junctions.insert(edge->getFromJunction());
221  junctions.insert(edge->getToJunction());
222  }
223  for (const MSJunction* junction : junctions) {
224  minValue = MIN2(minValue, junction->getPosition().z());
225  maxValue = MAX2(maxValue, junction->getPosition().z());
226  }
227  }
228  }
230  scheme.clear();
231  // add threshold for every distinct value
232  std::set<SVCPermissions> codes;
233  for (MSEdge* edge : MSEdge::getAllEdges()) {
234  for (MSLane* lane : edge->getLanes()) {
235  codes.insert(lane->getPermissions());
236  }
237  }
238  int step = MAX2(1, 360 / (int)codes.size());
239  int hue = 0;
240  for (SVCPermissions p : codes) {
241  scheme.addColor(RGBColor::fromHSV(hue, 1, 1), p);
242  hue = (hue + step) % 360;
243  }
244  return;
245  }
246 
247  if (minValue != std::numeric_limits<double>::infinity()) {
248  scheme.clear();
249  // add new thresholds
251  scheme.addColor(RGBColor(204, 204, 204), std::numeric_limits<double>::max(), "missing data");
252  }
253  if (hide) {
254  const double rawRange = maxValue - minValue;
255  minValue = MAX2(hideThreshold + MIN2(1.0, rawRange / 100.0), minValue);
256  scheme.addColor(RGBColor(204, 204, 204), hideThreshold);
257  }
258  double range = maxValue - minValue;
259  scheme.addColor(RGBColor::RED, (minValue));
260  scheme.addColor(RGBColor::ORANGE, (minValue + range * 1 / 6.0));
261  scheme.addColor(RGBColor::YELLOW, (minValue + range * 2 / 6.0));
262  scheme.addColor(RGBColor::GREEN, (minValue + range * 3 / 6.0));
263  scheme.addColor(RGBColor::CYAN, (minValue + range * 4 / 6.0));
264  scheme.addColor(RGBColor::BLUE, (minValue + range * 5 / 6.0));
265  scheme.addColor(RGBColor::MAGENTA, (maxValue));
266  }
267 }
268 
269 
270 std::vector<std::string>
272  if (GUINet::getGUIInstance() != nullptr) {
274  }
275  return std::vector<std::string>();
276 }
277 
278 
279 std::vector<std::string>
281  std::set<std::string> keys;
282  for (const MSEdge* e : MSEdge::getAllEdges()) {
283  if (edgeKeys) {
284  for (const auto& item : e->getParametersMap()) {
285  keys.insert(item.first);
286  }
287  } else {
288  for (const auto lane : e->getLanes()) {
289  for (const auto& item : lane->getParametersMap()) {
290  keys.insert(item.first);
291  }
292  }
293  }
294  }
295  return std::vector<std::string>(keys.begin(), keys.end());
296 }
297 
298 
299 std::vector<std::string>
300 GUIViewTraffic::getVehicleParamKeys(bool /*vTypeKeys*/) const {
301  std::set<std::string> keys;
303  vc->secureVehicles();
304  for (auto vehIt = vc->loadedVehBegin(); vehIt != vc->loadedVehEnd(); ++vehIt) {
305  for (auto kv : vehIt->second->getParameter().getParametersMap()) {
306  keys.insert(kv.first);
307  }
308  }
309  vc->releaseVehicles();
310  return std::vector<std::string>(keys.begin(), keys.end());
311 }
312 
313 std::vector<std::string>
315  std::set<std::string> keys;
316  const ShapeContainer::POIs& pois = static_cast<ShapeContainer&>(GUINet::getInstance()->getShapeContainer()).getPOIs();
317  for (auto item : pois) {
318  for (auto kv : item.second->getParametersMap()) {
319  keys.insert(kv.first);
320  }
321  }
322  return std::vector<std::string>(keys.begin(), keys.end());
323 }
324 
325 int
326 GUIViewTraffic::doPaintGL(int mode, const Boundary& bound) {
327  // (uncomment the next line to check select mode)
328  //myVisualizationSettings->drawForRectangleSelection = true;
329  // init view settings
330  glRenderMode(mode);
331  glMatrixMode(GL_MODELVIEW);
332  glPushMatrix();
333  glDisable(GL_TEXTURE_2D);
334  glDisable(GL_ALPHA_TEST);
335  glEnable(GL_BLEND);
336  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
337  glEnable(GL_DEPTH_TEST);
338 
339  // draw decals (if not in grabbing mode)
340  drawDecals();
342  paintGLGrid();
343  }
344 
345 
346  glLineWidth(1);
347  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
348  const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
349  const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
351  glEnable(GL_POLYGON_OFFSET_FILL);
352  glEnable(GL_POLYGON_OFFSET_LINE);
353  int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
354  // Draw additional objects
355  if (myAdditionallyDrawn.size() > 0) {
356  glTranslated(0, 0, -.01);
358  for (auto i : myAdditionallyDrawn) {
359  i.first->drawGLAdditional(this, *myVisualizationSettings);
360  }
362  glTranslated(0, 0, .01);
363  }
364  glPopMatrix();
365  /*
366  // draw legends
367  glMatrixMode(GL_MODELVIEW);
368  glLoadIdentity();
369  glTranslated(1.-.2, 1.-.5, 0.);
370  glScaled(.2, .5, 1.);
371  GUIColoringSchemesMap<GUILane> &sm = GUIViewTraffic::getLaneSchemesMap(); //!!!
372  sm.getColorer(myVisualizationSettings->laneEdgeMode)->drawLegend();
373  */
374  return hits2;
375 }
376 
377 
378 void
380  myTrackedID = id;
381 }
382 
383 
384 void
387 }
388 
389 
390 GUIGlID
392  return myTrackedID;
393 }
394 
395 
396 void
398  if (myTLSGame) {
400  const MSTrafficLightLogic* minTll = nullptr;
401  double minDist = std::numeric_limits<double>::infinity();
402  for (const MSTrafficLightLogic* const tll : tlsControl.getAllLogics()) {
403  if (tlsControl.isActive(tll) && tll->getProgramID() != "off") {
404  // get the links
405  const MSTrafficLightLogic::LaneVector& lanes = tll->getLanesAt(0);
406  if (lanes.size() > 0) {
407  const Position& endPos = lanes[0]->getShape().back();
408  if (endPos.distanceTo(pos) < minDist) {
409  minDist = endPos.distanceTo(pos);
410  minTll = tll;
411  }
412  }
413  }
414  }
415  if (minTll != nullptr) {
416  const MSTLLogicControl::TLSLogicVariants& vars = tlsControl.get(minTll->getID());
417  const std::vector<MSTrafficLightLogic*> logics = vars.getAllLogics();
418  if (logics.size() > 1) {
420  for (int i = 0; i < (int)logics.size() - 1; ++i) {
421  if (minTll->getProgramID() == logics[i]->getProgramID()) {
422  l = (MSSimpleTrafficLightLogic*) logics[i + 1];
423  tlsControl.switchTo(minTll->getID(), l->getProgramID());
424  }
425  }
426  if (l == logics[0]) {
427  tlsControl.switchTo(minTll->getID(), l->getProgramID());
428  }
430  update();
431  }
432  }
433  } else {
434  // DRT game
436  return;
437  }
438  const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
439  if (sel.size() == 0) {
440  // find closest pt vehicle
441  double minDist = std::numeric_limits<double>::infinity();
442  GUIVehicle* closest = nullptr;
446  for (it = vc.loadedVehBegin(); it != end; ++it) {
447  GUIVehicle* veh = dynamic_cast<GUIVehicle*>(it->second);
448  assert(veh != 0);
449  if (veh->getParameter().line != "") {
450  const double dist = veh->getPosition().distanceTo2D(pos);
451  if (dist < minDist) {
452  minDist = dist;
453  closest = veh;
454  }
455  }
456  }
457  if (closest != nullptr) {
458  gSelected.select(closest->getGlID());
460  }
461  } else {
462  // find closest pt stop
463  double minDist = std::numeric_limits<double>::infinity();
464  MSStoppingPlace* closestStop = nullptr;
466  for (auto it = stops.begin(); it != stops.end(); ++it) {
467  MSStoppingPlace* stop = it->second;
468  const double dist = pos.distanceTo2D(stop->getLane().geometryPositionAtOffset(stop->getEndLanePosition()));
469  if (dist < minDist) {
470  minDist = dist;
471  closestStop = stop;
472  }
473  }
474  if (closestStop != 0) {
475  GUIGlID id = *sel.begin();
477  assert(veh != 0);
478  MSLane* lane = veh->getMutableLane();
479  lane->getVehiclesSecure();
480  veh->rerouteDRTStop(closestStop);
482  lane->releaseVehicles();
483  }
484  }
485  }
486 }
487 
488 
489 void
491  const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
492  if (sel.size() > 0) {
493  GUIGlID id = *sel.begin();
495  if (veh != 0) {
497  }
499  }
500  gSelected.clear();
501 }
502 
503 
504 SUMOTime
507 }
508 
509 
510 GUILane*
512  if (makeCurrent()) {
513  int id = getObjectUnderCursor();
514  if (id != 0) {
516  if (o != nullptr) {
517  return dynamic_cast<GUILane*>(o);
518  }
519  }
520  makeNonCurrent();
521  }
522  return nullptr;
523 }
524 
525 long
526 GUIViewTraffic::onCmdCloseLane(FXObject*, FXSelector, void*) {
527  GUILane* lane = getLaneUnderCursor();
528  if (lane != nullptr) {
529  lane->closeTraffic();
531  update();
532  }
533  return 1;
534 }
535 
536 
537 long
538 GUIViewTraffic::onCmdCloseEdge(FXObject*, FXSelector, void*) {
539  GUILane* lane = getLaneUnderCursor();
540  if (lane != nullptr) {
541  dynamic_cast<GUIEdge*>(&lane->getEdge())->closeTraffic(lane);
543  update();
544  }
545  return 1;
546 }
547 
548 
549 long
550 GUIViewTraffic::onCmdAddRerouter(FXObject*, FXSelector, void*) {
551  GUILane* lane = getLaneUnderCursor();
552  if (lane != nullptr) {
553  dynamic_cast<GUIEdge*>(&lane->getEdge())->addRerouter();
555  update();
556  }
557  return 1;
558 }
559 
560 
561 long
562 GUIViewTraffic::onCmdShowReachability(FXObject* menu, FXSelector, void*) {
563  GUILane* lane = getLaneUnderCursor();
564  if (lane != nullptr) {
565  // reset
566  const double UNREACHABLE = -1;
567  gSelected.clear();
568  for (const MSEdge* const e : MSEdge::getAllEdges()) {
569  for (MSLane* const l : e->getLanes()) {
570  GUILane* gLane = dynamic_cast<GUILane*>(l);
572  }
573  }
574  // prepare
575  FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
576  const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
577  const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(svc).maxSpeed;
578  // find reachable
579  std::map<MSEdge*, double> reachableEdges;
580  reachableEdges[&lane->getEdge()] = 0;
581  MSEdgeVector check;
582  check.push_back(&lane->getEdge());
583  while (check.size() > 0) {
584  MSEdge* e = check.front();
585  check.erase(check.begin());
586  double traveltime = reachableEdges[e];
587  for (MSLane* const l : e->getLanes()) {
588  if (l->allowsVehicleClass(svc)) {
589  GUILane* gLane = dynamic_cast<GUILane*>(l);
590  gSelected.select(gLane->getGlID());
591  gLane->setReachability(traveltime);
592  }
593  }
594  traveltime += e->getLength() / MIN2(e->getSpeedLimit(), defaultMaxSpeed);
595  for (MSEdge* const nextEdge : e->getSuccessors(svc)) {
596  if (reachableEdges.count(nextEdge) == 0 ||
597  // revisit edge via faster path
598  reachableEdges[nextEdge] > traveltime) {
599  reachableEdges[nextEdge] = traveltime;
600  check.push_back(nextEdge);
601  }
602  }
603  }
604  // switch to 'color by selection' unless coloring 'by reachability'
607  }
608  update();
609  }
610  return 1;
611 }
612 
613 
614 long
615 GUIViewTraffic::onDoubleClicked(FXObject*, FXSelector, void*) {
616  // leave fullscreen mode
617  if (myApp->isFullScreen()) {
618  myApp->onCmdFullScreen(nullptr, 0, nullptr);
619  } else {
620  stopTrack();
621  }
622  return 1;
623 }
624 
625 
626 
627 void
628 GUIViewTraffic::saveFrame(const std::string& destFile, FXColor* buf) {
629 #ifdef HAVE_FFMPEG
630  if (myCurrentVideo == nullptr) {
631  myCurrentVideo = new GUIVideoEncoder(destFile.c_str(), getWidth(), getHeight(), myApp->getDelay());
632  }
633  myCurrentVideo->writeFrame((uint8_t*)buf);
634 #else
635  UNUSED_PARAMETER(destFile);
636  UNUSED_PARAMETER(buf);
637 #endif
638 }
639 
640 
641 void
643 #ifdef HAVE_FFMPEG
644  if (myCurrentVideo != nullptr) {
645  delete myCurrentVideo;
646  myCurrentVideo = nullptr;
647  }
648 #endif
649 }
650 
651 
652 void
654 #ifdef HAVE_FFMPEG
655  if (myCurrentVideo != nullptr) {
657  }
658 #endif
660 }
661 
662 
663 const std::vector<SUMOTime>
665  return myApp->retrieveBreakpoints();
666 }
667 
668 
669 /****************************************************************************/
#define UNREACHABLE
@ MID_LOCATEPERSON
Locate person - button.
Definition: GUIAppEnum.h:349
@ MID_LOCATEJUNCTION
Locate junction - button.
Definition: GUIAppEnum.h:339
@ MID_LOCATEPOLY
Locate polygons - button.
Definition: GUIAppEnum.h:359
@ MID_LOCATEADD
Locate addtional structure - button.
Definition: GUIAppEnum.h:355
@ MID_LOCATEPOI
Locate poi - button.
Definition: GUIAppEnum.h:357
@ MID_REACHABILITY
show reachability from a given lane
Definition: GUIAppEnum.h:471
@ MID_CLOSE_LANE
close lane
Definition: GUIAppEnum.h:584
@ MID_LOCATEEDGE
Locate edge - button.
Definition: GUIAppEnum.h:341
@ MID_LOCATEVEHICLE
Locate vehicle - button.
Definition: GUIAppEnum.h:343
@ MID_LOCATETLS
Locate TLS - button.
Definition: GUIAppEnum.h:353
@ MID_CLOSE_EDGE
close edge
Definition: GUIAppEnum.h:586
@ MID_ADD_REROUTER
add rerouter
Definition: GUIAppEnum.h:588
@ MID_LOCATECONTAINER
Locate container - button.
Definition: GUIAppEnum.h:351
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:31
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:47
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
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
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:486
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:236
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1318
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
gets the color value according to the current scheme index
Definition: GUILane.cpp:1069
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:536
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:548
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:657
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:542
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:526
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
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
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
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
std::string name
The name of this setting.
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:847
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:166
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:919
double getLength() const
return the length of the edge
Definition: MSEdge.h:630
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1013
static bool gUseMesoSim
Definition: MSGlobals.h:88
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:426
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:456
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:503
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:444
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:371
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:494
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:1121
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.
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:558
const std::string & getID() const
Returns the id.
Definition: Named.h:73
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:36
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:241
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:231
static const RGBColor BLUE
Definition: RGBColor.h:182
static const RGBColor YELLOW
Definition: RGBColor.h:183
static const RGBColor ORANGE
Definition: RGBColor.h:186
static const RGBColor CYAN
Definition: RGBColor.h:184
static const RGBColor GREEN
Definition: RGBColor.h:181
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:300
static const RGBColor MAGENTA
Definition: RGBColor.h:185
static const RGBColor RED
named colors
Definition: RGBColor.h:180
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].