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>
49#include "GUISUMOViewParent.h"
50#include "GUIViewTraffic.h"
66
67// ===========================================================================
68// member method definitions
69// ===========================================================================
71 FXComposite* p,
72 GUIMainWindow& app,
73 GUISUMOViewParent* parent,
74 GUINet& net, FXGLVisual* glVis,
75 FXGLCanvas* share) :
76 GUISUMOAbstractView(p, app, parent, net.getVisualisationSpeedUp(), glVis, share),
77 myTrackedID(GUIGlObject::INVALID_ID),
78 myTLSGame(OptionsCont::getOptions().getString("game.mode") == "tls")
79#ifdef HAVE_FFMPEG
80 , myCurrentVideo(nullptr)
81#endif
82{}
83
84
87}
88
89
90void
92 //
93}
94
95
96void
98 // build coloring tools
99 {
100 const std::vector<std::string>& names = gSchemeStorage.getNames();
101 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
102 v->getColoringSchemesCombo()->appendItem(i->c_str());
103 if ((*i) == myVisualizationSettings->name) {
104 v->getColoringSchemesCombo()->setCurrentItem(v->getColoringSchemesCombo()->getNumItems() - 1);
105 }
106 }
107 v->getColoringSchemesCombo()->setNumVisible(MAX2(5, (int)names.size() + 1));
108 }
109 // for junctions
111 "\tLocate Junctions\tLocate a junction within the network.",
113 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
114 // for edges
116 "\tLocate Edges\tLocate an edge within the network.",
118 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
119 // for vehicles
121 "\tLocate Vehicles\tLocate a vehicle within the network.",
123 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
124 // for persons
126 "\tLocate Persons\tLocate a person within the network.",
128 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
129 // for containers
131 "\tLocate Container\tLocate a container within the network.",
133 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
134 // for tls
136 "\tLocate TLS\tLocate a tls within the network.",
138 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
139 // for additional stuff
141 "\tLocate Additional\tLocate an additional structure within the network.",
143 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
144 // for pois
146 "\tLocate PoI\tLocate a PoI within the network.",
148 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
149 // for polygons
151 "\tLocate Polygon\tLocate a Polygon within the network.",
153 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
154}
155
156
157bool
158GUIViewTraffic::setColorScheme(const std::string& name) {
159 if (!gSchemeStorage.contains(name)) {
160 return false;
161 }
162 if (myVisualizationChanger != nullptr) {
165 }
166 }
169 update();
170 return true;
171}
172
173
174void
176 bool hide, double hideThreshold, bool hide2, double hideThreshold2) {
177 assert(!scheme.isFixed());
178 double minValue = std::numeric_limits<double>::infinity();
179 double maxValue = -std::numeric_limits<double>::infinity();
180 // retrieve range
181 bool hasMissingData = false;
182 if (objectType == GLO_LANE) {
183 // XXX (see #3409) multi-colors are not currently handled. this is a quick hack
184 if (active == 22) {
185 active = 21; // segment height, fall back to start height
186 } else if (active == 24) {
187 active = 23; // segment incline, fall back to total incline
188 }
189 const MSEdgeVector& edges = MSEdge::getAllEdges();
190 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
192 const double val = static_cast<GUIEdge*>(*it)->getColorValue(s, active);
193 if (val == s.MISSING_DATA) {
194 hasMissingData = true;
195 continue;
196 }
197 minValue = MIN2(minValue, val);
198 maxValue = MAX2(maxValue, val);
199 } else {
200 const std::vector<MSLane*>& lanes = (*it)->getLanes();
201 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
202 const double val = static_cast<GUILane*>(*it_l)->getColorValue(s, active);
203 if (val == s.MISSING_DATA) {
204 hasMissingData = true;
205 continue;
206 }
207 minValue = MIN2(minValue, val);
208 maxValue = MAX2(maxValue, val);
209 }
210 }
211 }
212 } else if (objectType == GLO_JUNCTION) {
213 if (active == 3) {
214 std::set<const MSJunction*> junctions;
215 for (MSEdge* edge : MSEdge::getAllEdges()) {
216 junctions.insert(edge->getFromJunction());
217 junctions.insert(edge->getToJunction());
218 }
219 for (const MSJunction* junction : junctions) {
220 minValue = MIN2(minValue, junction->getPosition().z());
221 maxValue = MAX2(maxValue, junction->getPosition().z());
222 }
223 }
224 }
226 scheme.clear();
227 // add threshold for every distinct value
228 std::set<SVCPermissions> codes;
229 for (MSEdge* edge : MSEdge::getAllEdges()) {
230 for (MSLane* lane : edge->getLanes()) {
231 codes.insert(lane->getPermissions());
232 }
233 }
234 int step = MAX2(1, 360 / (int)codes.size());
235 int hue = 0;
236 for (SVCPermissions p : codes) {
237 scheme.addColor(RGBColor::fromHSV(hue, 1, 1), p);
238 hue = (hue + step) % 360;
239 }
240 return;
241 }
242
243 if (minValue != std::numeric_limits<double>::infinity()) {
244 scheme.clear();
245 // 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 if (hide2) {
259 const double rawRange = maxValue - minValue;
260 maxValue = MIN2(hideThreshold2 - MIN2(1.0, rawRange / 100.0), maxValue);
261 scheme.addColor(RGBColor(204, 204, 204), hideThreshold2);
262 }
263 double range = maxValue - minValue;
264 scheme.addColor(RGBColor::RED, (minValue));
265 scheme.addColor(RGBColor::ORANGE, (minValue + range * 1 / 6.0));
266 scheme.addColor(RGBColor::YELLOW, (minValue + range * 2 / 6.0));
267 scheme.addColor(RGBColor::GREEN, (minValue + range * 3 / 6.0));
268 scheme.addColor(RGBColor::CYAN, (minValue + range * 4 / 6.0));
269 scheme.addColor(RGBColor::BLUE, (minValue + range * 5 / 6.0));
270 scheme.addColor(RGBColor::MAGENTA, (maxValue));
271 if (hasMissingData) {
273 }
274 }
275}
276
277
278std::vector<std::string>
280 if (GUINet::getGUIInstance() != nullptr) {
282 }
283 return std::vector<std::string>();
284}
285
286
287std::vector<std::string>
289 if (GUINet::getGUIInstance() != nullptr) {
291 }
292 return std::vector<std::string>();
293}
294
295std::vector<std::string>
296GUIViewTraffic::getMeanDataAttrs(const std::string& meanDataID) const {
297 if (GUINet::getGUIInstance() != nullptr) {
298 return GUINet::getGUIInstance()->getMeanDataAttrs(meanDataID);
299 }
300 return std::vector<std::string>();
301}
302
303
304std::vector<std::string>
306 std::set<std::string> keys;
307 for (const MSEdge* e : MSEdge::getAllEdges()) {
308 if (edgeKeys) {
309 for (const auto& item : e->getParametersMap()) {
310 keys.insert(item.first);
311 }
312 } else {
313 for (const auto lane : e->getLanes()) {
314 for (const auto& item : lane->getParametersMap()) {
315 keys.insert(item.first);
316 }
317 }
318 }
319 }
320 return std::vector<std::string>(keys.begin(), keys.end());
321}
322
323
324std::vector<std::string>
325GUIViewTraffic::getVehicleParamKeys(bool /*vTypeKeys*/) const {
326 std::set<std::string> keys;
328 vc->secureVehicles();
329 for (auto vehIt = vc->loadedVehBegin(); vehIt != vc->loadedVehEnd(); ++vehIt) {
330 for (auto kv : vehIt->second->getParameter().getParametersMap()) {
331 keys.insert(kv.first);
332 }
333 }
334 vc->releaseVehicles();
335 return std::vector<std::string>(keys.begin(), keys.end());
336}
337
338std::vector<std::string>
340 std::set<std::string> keys;
341 const ShapeContainer::POIs& pois = static_cast<ShapeContainer&>(GUINet::getInstance()->getShapeContainer()).getPOIs();
342 for (auto item : pois) {
343 for (auto kv : item.second->getParametersMap()) {
344 keys.insert(kv.first);
345 }
346 }
347 return std::vector<std::string>(keys.begin(), keys.end());
348}
349
350int
351GUIViewTraffic::doPaintGL(int mode, const Boundary& bound) {
352 // (uncomment the next line to check select mode)
353 //myVisualizationSettings->drawForPositionSelection = true;
354 // init view settings
355 glRenderMode(mode);
356 glMatrixMode(GL_MODELVIEW);
358 glDisable(GL_TEXTURE_2D);
359 glDisable(GL_ALPHA_TEST);
360 glEnable(GL_BLEND);
361 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
362 glEnable(GL_DEPTH_TEST);
363
364 // draw decals (if not in grabbing mode)
365 drawDecals();
368 paintGLGrid();
369 }
370
371
372 glLineWidth(1);
373 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
374 const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
375 const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
376 glEnable(GL_POLYGON_OFFSET_FILL);
377 glEnable(GL_POLYGON_OFFSET_LINE);
378 int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
379 // Draw additional objects
380 if (myAdditionallyDrawn.size() > 0) {
381 glTranslated(0, 0, -.01);
383 for (auto i : myAdditionallyDrawn) {
384 i.first->drawGLAdditional(this, *myVisualizationSettings);
385 }
387 glTranslated(0, 0, .01);
388 }
390 /*
391 // draw legends
392 glMatrixMode(GL_MODELVIEW);
393 glLoadIdentity();
394 glTranslated(1.-.2, 1.-.5, 0.);
395 glScaled(.2, .5, 1.);
396 GUIColoringSchemesMap<GUILane> &sm = GUIViewTraffic::getLaneSchemesMap(); //!!!
397 sm.getColorer(myVisualizationSettings->laneEdgeMode)->drawLegend();
398 */
399 return hits2;
400}
401
402
403void
405 myTrackedID = id;
406}
407
408
409void
412}
413
414
417 return myTrackedID;
418}
419
420
421void
423 if (myTLSGame) {
425 MSTrafficLightLogic* minTll = nullptr;
426 double minDist = std::numeric_limits<double>::infinity();
427 for (MSTrafficLightLogic* const tll : tlsControl.getAllLogics()) {
428 if (tlsControl.isActive(tll) && tll->getProgramID() != "off") {
429 // get the links
430 const MSTrafficLightLogic::LaneVector& lanes = tll->getLanesAt(0);
431 if (lanes.size() > 0) {
432 const Position& endPos = lanes[0]->getShape().back();
433 if (endPos.distanceTo(pos) < minDist) {
434 minDist = endPos.distanceTo(pos);
435 minTll = tll;
436 }
437 }
438 }
439 }
440 if (minTll != nullptr) {
441 const int nextPhase = (minTll->getCurrentPhaseIndex() + 1) % minTll->getPhaseNumber();
442 minTll->changeStepAndDuration(tlsControl, MSNet::getInstance()->getCurrentTimeStep(), nextPhase, -1);
443 update();
444 }
445 } else {
446 // DRT game
448 return;
449 }
450 const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
451 if (sel.size() == 0) {
452 // find closest pt vehicle
453 double minDist = std::numeric_limits<double>::infinity();
454 GUIVehicle* closest = nullptr;
458 for (it = vc.loadedVehBegin(); it != end; ++it) {
459 GUIVehicle* veh = dynamic_cast<GUIVehicle*>(it->second);
460 assert(veh != 0);
461 if (veh->getParameter().line != "") {
462 const double dist = veh->getPosition().distanceTo2D(pos);
463 if (dist < minDist) {
464 minDist = dist;
465 closest = veh;
466 }
467 }
468 }
469 if (closest != nullptr) {
470 gSelected.select(closest->getGlID());
472 }
473 } else {
474 // find closest pt stop
475 double minDist = std::numeric_limits<double>::infinity();
476 MSStoppingPlace* closestStop = nullptr;
478 for (auto it = stops.begin(); it != stops.end(); ++it) {
479 MSStoppingPlace* stop = it->second;
480 const double dist = pos.distanceTo2D(stop->getLane().geometryPositionAtOffset(stop->getEndLanePosition()));
481 if (dist < minDist) {
482 minDist = dist;
483 closestStop = stop;
484 }
485 }
486 if (closestStop != 0) {
487 GUIGlID id = *sel.begin();
489 assert(veh != 0);
490 MSLane* lane = veh->getMutableLane();
491 lane->getVehiclesSecure();
492 veh->rerouteDRTStop(closestStop);
494 lane->releaseVehicles();
495 }
496 }
497 }
498}
499
500
501void
503 const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
504 if (sel.size() > 0) {
505 GUIGlID id = *sel.begin();
507 if (veh != 0) {
509 }
511 }
513}
514
515
519}
520
521
522long
523GUIViewTraffic::onCmdCloseLane(FXObject*, FXSelector, void*) {
524 GUILane* lane = getLaneUnderCursor();
525 if (lane != nullptr) {
526 lane->closeTraffic();
528 update();
529 }
530 return 1;
531}
532
533
534long
535GUIViewTraffic::onCmdCloseEdge(FXObject*, FXSelector, void*) {
536 GUILane* lane = getLaneUnderCursor();
537 if (lane != nullptr) {
538 dynamic_cast<GUIEdge*>(&lane->getEdge())->closeTraffic(lane);
540 update();
541 }
542 return 1;
543}
544
545
546long
547GUIViewTraffic::onCmdAddRerouter(FXObject*, FXSelector, void*) {
548 GUILane* lane = getLaneUnderCursor();
549 if (lane != nullptr) {
550 dynamic_cast<GUIEdge*>(&lane->getEdge())->addRerouter();
552 update();
553 }
554 return 1;
555}
556
557
558long
559GUIViewTraffic::showLaneReachability(GUILane* lane, FXObject* menu, FXSelector) {
560 if (lane != nullptr) {
561 // reset
562 const double UNREACHED = -1;
564 for (const MSEdge* const e : MSEdge::getAllEdges()) {
565 for (MSLane* const l : e->getLanes()) {
566 GUILane* gLane = dynamic_cast<GUILane*>(l);
567 gLane->setReachability(UNREACHED);
568 }
569 }
570 // prepare
571 FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
572 const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
573 const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(svc).maxSpeed;
574 // find reachable
575 std::map<MSEdge*, double> reachableEdges;
576 reachableEdges[&lane->getEdge()] = 0;
577 MSEdgeVector check;
578 check.push_back(&lane->getEdge());
579 while (check.size() > 0) {
580 MSEdge* e = check.front();
581 check.erase(check.begin());
582 double traveltime = reachableEdges[e];
583 for (MSLane* const l : e->getLanes()) {
584 if (l->allowsVehicleClass(svc)) {
585 GUILane* gLane = dynamic_cast<GUILane*>(l);
586 gSelected.select(gLane->getGlID());
587 gLane->setReachability(traveltime);
588 }
589 }
590 traveltime += e->getLength() / MIN2(e->getSpeedLimit(), defaultMaxSpeed);
591 for (MSEdge* const nextEdge : e->getSuccessors(svc)) {
592 if (reachableEdges.count(nextEdge) == 0 ||
593 // revisit edge via faster path
594 reachableEdges[nextEdge] > traveltime) {
595 reachableEdges[nextEdge] = traveltime;
596 check.push_back(nextEdge);
597 }
598 }
599 }
600 }
601 return 1;
602}
603
604
605long
606GUIViewTraffic::onCmdShowReachability(FXObject* menu, FXSelector selector, void*) {
607 GUILane* lane = getLaneUnderCursor();
608 if (lane != nullptr) {
609 // reset
610 showLaneReachability(lane, menu, selector);
611 // switch to 'color by selection' unless coloring 'by reachability'
614 }
615 update();
616 }
617 return 1;
618}
619
620
621GUILane*
623 if (makeCurrent()) {
624 int id = getObjectUnderCursor();
625 if (id != 0) {
627 if (o != nullptr) {
628 return dynamic_cast<GUILane*>(o);
629 }
630 }
631 makeNonCurrent();
632 }
633 return nullptr;
634}
635
636
637long
638GUIViewTraffic::onDoubleClicked(FXObject*, FXSelector, void*) {
639 // leave fullscreen mode
640 if (myApp->isFullScreen()) {
641 myApp->onCmdFullScreen(nullptr, 0, nullptr);
642 } else {
643 stopTrack();
644 }
645 return 1;
646}
647
648
649
650void
651GUIViewTraffic::saveFrame(const std::string& destFile, FXColor* buf) {
652#ifdef HAVE_FFMPEG
653 if (myCurrentVideo == nullptr) {
654 myCurrentVideo = new GUIVideoEncoder(destFile.c_str(), getWidth(), getHeight(), myApp->getDelay());
655 }
656 myCurrentVideo->writeFrame((uint8_t*)buf);
657#else
658 UNUSED_PARAMETER(destFile);
659 UNUSED_PARAMETER(buf);
660#endif
661}
662
663
664void
666#ifdef HAVE_FFMPEG
667 if (myCurrentVideo != nullptr) {
668 delete myCurrentVideo;
669 myCurrentVideo = nullptr;
670 }
671#endif
672}
673
674
675void
677#ifdef HAVE_FFMPEG
678 if (myCurrentVideo != nullptr) {
680 }
681#endif
683}
684
685
686const std::vector<SUMOTime>
688 return myApp->retrieveBreakpoints();
689}
690
691
692/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
@ MID_LOCATEPERSON
Locate person - button.
Definition: GUIAppEnum.h:369
@ MID_LOCATEJUNCTION
Locate junction - button.
Definition: GUIAppEnum.h:357
@ MID_LOCATEPOLY
Locate polygons - button.
Definition: GUIAppEnum.h:379
@ MID_LOCATEADD
Locate additional structure - button.
Definition: GUIAppEnum.h:375
@ MID_LOCATEPOI
Locate poi - button.
Definition: GUIAppEnum.h:377
@ MID_LOCATEEDGE
Locate edge - button.
Definition: GUIAppEnum.h:359
@ MID_LOCATEVEHICLE
Locate vehicle - button.
Definition: GUIAppEnum.h:363
@ MID_LOCATETLS
Locate TLS - button.
Definition: GUIAppEnum.h:373
@ MID_LOCATECONTAINER
Locate container - button.
Definition: GUIAppEnum.h:371
GUICompleteSchemeStorage gSchemeStorage
unsigned int GUIGlID
Definition: GUIGlObject.h:43
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
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define INVALID_ID
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
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:71
T MAX2(T a, T b)
Definition: StdDefs.h:77
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:118
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:124
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
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 override
gets the color value according to the current scheme index
Definition: GUIEdge.cpp:520
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:71
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
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:60
void setReachability(double value)
Definition: GUILane.h:240
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUILane.cpp:1183
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1464
bool isFullScreen()
virtual const std::vector< SUMOTime > retrieveBreakpoints() const
retrieve breakpoints if provided by the application
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
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:548
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:560
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:694
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
Definition: GUINet.cpp:704
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:554
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:538
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
Definition: GUINet.cpp:715
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 *)
void buildColorRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, int active, GUIGlObjectType objectType, bool hide=false, double hideThreshold=0, bool hide2=false, double hideThreshold2=0)
recalibrate color scheme according to the current value range
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()
returns the GUILane at cursor position (implementation depends on view)
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.
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
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 *)
static long showLaneReachability(GUILane *lane, FXObject *, FXSelector)
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 > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
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_DATA_ATTRIBUTE_NUMERICAL
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
static const std::string SCHEME_NAME_LANE_PARAM_NUMERICAL
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_EDGE_PARAM_NUMERICAL
scheme names
static const std::string SCHEME_NAME_PERMISSION_CODE
static const std::string SCHEME_NAME_PARAM_NUMERICAL
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:984
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:1056
double getLength() const
return the length of the edge
Definition: MSEdge.h:658
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1155
static bool gUseMesoSim
Definition: MSGlobals.h:103
The base class for an intersection.
Definition: MSJunction.h:58
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:456
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:486
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:713
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:533
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:452
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:502
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:379
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:1310
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.
A class that stores and controls tls and switching of their programs.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
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.
virtual int getPhaseNumber() const =0
Returns the number of phases.
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
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:585
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:371
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] (technical limit, not subject to speed deviation)