Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIViewTraffic.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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>
36#include <gui/GUIGlobals.h>
37#include <guisim/GUIEdge.h>
38#include <guisim/GUILane.h>
39#include <guisim/GUINet.h>
40#include <guisim/GUIVehicle.h>
44#include <microsim/MSEdge.h>
45#include <microsim/MSGlobals.h>
47#include <microsim/MSLane.h>
69
70#include "GUISUMOViewParent.h"
71#include "GUIViewTraffic.h"
72
73// ===========================================================================
74// member method definitions
75// ===========================================================================
77 FXComposite* p,
78 GUIMainWindow& app,
79 GUISUMOViewParent* parent,
80 GUINet& net, FXGLVisual* glVis,
81 FXGLCanvas* share) :
82 GUISUMOAbstractView(p, app, parent, net.getVisualisationSpeedUp(), glVis, share),
83 myTrackedID(GUIGlObject::INVALID_ID),
84 myTLSGame(OptionsCont::getOptions().getString("game.mode") == "tls")
85#ifdef HAVE_FFMPEG
86 , myCurrentVideo(nullptr)
87#endif
88{}
89
90
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()->appendIconItem(i->c_str());
103 if ((*i) == myVisualizationSettings->name) {
105 }
106 }
107 }
108 // for junctions
110 (std::string("\t") + TL("Locate Junctions") + std::string("\t") + TL("Locate a junction within the network.")).c_str(),
113 // for edges
115 (std::string("\t") + TL("Locate Edges") + std::string("\t") + TL("Locate an edge within the network.")).c_str(),
118 // for vehicles
120 (std::string("\t") + TL("Locate Vehicles") + std::string("\t") + TL("Locate a vehicle within the network.")).c_str(),
123 // for persons
125 (std::string("\t") + TL("Locate Persons") + std::string("\t") + TL("Locate a person within the network.")).c_str(),
128 // for containers
130 (std::string("\t") + TL("Locate Container") + std::string("\t") + TL("Locate a container within the network.")).c_str(),
133 // for tls
135 (std::string("\t") + TL("Locate TLS") + std::string("\t") + TL("Locate a tls within the network.")).c_str(),
138 // for additional stuff
140 (std::string("\t") + TL("Locate Additional") + std::string("\t") + TL("Locate an additional structure within the network.")).c_str(),
143 // for pois
145 (std::string("\t") + TL("Locate PoI") + std::string("\t") + TL("Locate a PoI within the network.")).c_str(),
148 // for polygons
150 (std::string("\t") + TL("Locate Polygon") + std::string("\t") + TL("Locate a Polygon within the network.")).c_str(),
153}
154
155
156bool
157GUIViewTraffic::setColorScheme(const std::string& name) {
158 if (!gSchemeStorage.contains(name)) {
159 return false;
160 }
161 if (myGUIDialogViewSettings != nullptr) {
164 }
165 }
168 update();
169 return true;
170}
171
172
173void
176 assert(!scheme.isFixed());
177 double minValue = std::numeric_limits<double>::infinity();
178 double maxValue = -std::numeric_limits<double>::infinity();
179 // retrieve range
180 bool hasMissingData = false;
181 if (objectType == GLO_LANE) {
182 // XXX (see #3409) multi-colors are not currently handled. this is a quick hack
183 if (active == 22) {
184 active = 21; // segment height, fall back to start height
185 } else if (active == 24) {
186 active = 23; // segment incline, fall back to total incline
187 }
188 const MSEdgeVector& edges = MSEdge::getAllEdges();
189 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
191 const double val = static_cast<GUIEdge*>(*it)->getColorValue(s, active);
192 if (val == s.MISSING_DATA) {
193 hasMissingData = true;
194 continue;
195 }
196 minValue = MIN2(minValue, val);
197 maxValue = MAX2(maxValue, val);
198 } else {
199 const std::vector<MSLane*>& lanes = (*it)->getLanes();
200 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
201 const double val = static_cast<GUILane*>(*it_l)->getColorValue(s, active);
202 if (val == s.MISSING_DATA) {
203 hasMissingData = true;
204 continue;
205 }
206 minValue = MIN2(minValue, val);
207 maxValue = MAX2(maxValue, val);
208 }
209 }
210 }
211 } else if (objectType == GLO_VEHICLE) {
213 for (MSVehicleControl::constVehIt it_v = c.loadedVehBegin(); it_v != c.loadedVehEnd(); ++it_v) {
214 const GUIGlObject* veh;
216 veh = static_cast<const GUIMEVehicle*>(it_v->second);
217 } else {
218 veh = static_cast<const GUIVehicle*>(it_v->second);
219 }
220 const double val = veh->getColorValue(s, active);
221 if (val == s.MISSING_DATA) {
222 hasMissingData = true;
223 continue;
224 }
225 minValue = MIN2(minValue, val);
226 maxValue = MAX2(maxValue, val);
227 }
228 } else if (objectType == GLO_JUNCTION) {
229 if (active == 3) {
230 std::set<const MSJunction*> junctions;
231 for (MSEdge* edge : MSEdge::getAllEdges()) {
232 junctions.insert(edge->getFromJunction());
233 junctions.insert(edge->getToJunction());
234 }
235 for (const MSJunction* junction : junctions) {
236 minValue = MIN2(minValue, junction->getPosition().z());
237 maxValue = MAX2(maxValue, junction->getPosition().z());
238 }
239 }
240 }
242 scheme.clear();
243 // add threshold for every distinct value
244 std::set<SVCPermissions> codes;
245 for (MSEdge* edge : MSEdge::getAllEdges()) {
246 for (MSLane* lane : edge->getLanes()) {
247 codes.insert(lane->getPermissions());
248 }
249 }
250 int step = MAX2(1, 360 / (int)codes.size());
251 int hue = 0;
252 for (SVCPermissions p : codes) {
253 scheme.addColor(RGBColor::fromHSV(hue, 1, 1), (double)p);
254 hue = (hue + step) % 360;
255 }
256 return;
257 }
258 buildMinMaxRainbow(s, scheme, rs, minValue, maxValue, hasMissingData);
259}
260
261
262std::vector<std::string>
264 if (GUINet::getGUIInstance() != nullptr) {
266 }
267 return std::vector<std::string>();
268}
269
270
271std::vector<std::string>
273 if (GUINet::getGUIInstance() != nullptr) {
275 }
276 return std::vector<std::string>();
277}
278
279std::vector<std::string>
280GUIViewTraffic::getMeanDataAttrs(const std::string& meanDataID) const {
281 if (GUINet::getGUIInstance() != nullptr) {
282 return GUINet::getGUIInstance()->getMeanDataAttrs(meanDataID);
283 }
284 return std::vector<std::string>();
285}
286
287
288std::vector<std::string>
290 std::set<std::string> keys;
291 for (const MSEdge* e : MSEdge::getAllEdges()) {
292 if (edgeKeys) {
293 for (const auto& item : e->getParametersMap()) {
294 keys.insert(item.first);
295 }
296 } else {
297 for (const auto lane : e->getLanes()) {
298 for (const auto& item : lane->getParametersMap()) {
299 keys.insert(item.first);
300 }
301 }
302 }
303 }
304 return std::vector<std::string>(keys.begin(), keys.end());
305}
306
307
308std::vector<std::string>
309GUIViewTraffic::getVehicleParamKeys(bool /*vTypeKeys*/) const {
310 std::set<std::string> keys;
311 MSVehicleControl* vc = nullptr;
314 } else {
316 }
317 vc->secureVehicles();
318 for (auto vehIt = vc->loadedVehBegin(); vehIt != vc->loadedVehEnd(); ++vehIt) {
319 for (auto kv : vehIt->second->getParameter().getParametersMap()) {
320 keys.insert(kv.first);
321 }
322 }
323 vc->releaseVehicles();
324 return std::vector<std::string>(keys.begin(), keys.end());
325}
326
327std::vector<std::string>
329 std::set<std::string> keys;
330 const ShapeContainer::POIs& pois = static_cast<ShapeContainer&>(GUINet::getInstance()->getShapeContainer()).getPOIs();
331 for (auto item : pois) {
332 for (auto kv : item.second->getParametersMap()) {
333 keys.insert(kv.first);
334 }
335 }
336 return std::vector<std::string>(keys.begin(), keys.end());
337}
338
339
340void
346
347int
348GUIViewTraffic::doPaintGL(int mode, const Boundary& bound) {
349 // init view settings
350 glRenderMode(mode);
351 glMatrixMode(GL_MODELVIEW);
353 glDisable(GL_TEXTURE_2D);
354 glDisable(GL_ALPHA_TEST);
355 glEnable(GL_BLEND);
356 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
357 glEnable(GL_DEPTH_TEST);
358
359 // draw decals (if not in grabbing mode)
360 drawDecals();
363 paintGLGrid();
364 }
365 glLineWidth(1);
366 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
367 const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
368 const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
369 glEnable(GL_POLYGON_OFFSET_FILL);
370 glEnable(GL_POLYGON_OFFSET_LINE);
372 int hits2 = grid.Search(minB, maxB, *myVisualizationSettings);
374 // Draw additional objects
375 if (myAdditionallyDrawn.size() > 0) {
376 glTranslated(0, 0, -.01);
378 for (auto i : myAdditionallyDrawn) {
379 i.first->drawGLAdditional(this, *myVisualizationSettings);
380 }
382 glTranslated(0, 0, .01);
383 }
385 /*
386 // draw legends
387 glMatrixMode(GL_MODELVIEW);
388 glLoadIdentity();
389 glTranslated(1.-.2, 1.-.5, 0.);
390 glScaled(.2, .5, 1.);
391 GUIColoringSchemesMap<GUILane> &sm = GUIViewTraffic::getLaneSchemesMap(); //!!!
392 sm.getColorer(myVisualizationSettings->laneEdgeMode)->drawLegend();
393 */
394 return hits2;
395}
396
397
398void
400 myTrackedID = id;
402 if (o != nullptr) {
403 GUIBaseVehicle* v = dynamic_cast<GUIBaseVehicle*>(o);
404 if (v != nullptr) {
406 }
407 }
408}
409
410
411void
415
416
419 return myTrackedID;
420}
421
422
423void
425 if (myTLSGame) {
427 MSTrafficLightLogic* minTll = nullptr;
428 GUIGlObject* minRR = nullptr;
429 double minDist = std::numeric_limits<double>::infinity();
430 double minDistRR = std::numeric_limits<double>::infinity();
431 for (MSTrafficLightLogic* const tll : tlsControl.getAllLogics()) {
432 if (tlsControl.isActive(tll) && tll->getProgramID() != "off") {
433 // get the links
434 const MSTrafficLightLogic::LaneVector& lanes = tll->getLanesAt(0);
435 if (lanes.size() > 0) {
436 const Position& endPos = lanes[0]->getShape().back();
437 if (endPos.distanceTo(pos) < minDist) {
438 minDist = endPos.distanceTo(pos);
439 minTll = tll;
440 }
441 }
442 }
443 }
444 if (makeCurrent()) {
446 if (o->getType() == GLO_REROUTER_EDGE) {
447 const double dist = o->getCenter().distanceTo2D(pos);
448 if (dist < minDistRR) {
449 minDistRR = dist;
450 minRR = o;
451 }
452 }
453 }
454 makeNonCurrent();
455 }
456 if (minDistRR < minDist && minRR != nullptr) {
457 minRR->onLeftBtnPress(nullptr);
458 update();
459 return;
460 }
461
462 if (minTll != nullptr) {
463 if (minTll->getPhaseNumber() == 0) {
464 // MSRailSignal
465 return;
466 }
467 const int ci = minTll->getCurrentPhaseIndex();
468 const int n = minTll->getPhaseNumber();
469 int greenCount = 0;
470 for (auto& phase : minTll->getPhases()) {
471 if (phase->isGreenPhase()) {
472 greenCount++;
473 }
474 }
475 int nextPhase = (ci + 1) % n;
476 SUMOTime nextDuration = 0;
477 if (minTll->getCurrentPhaseDef().isGreenPhase() || (greenCount == 1 && minTll->getCurrentPhaseDef().isAllRedPhase())) {
478 nextDuration = minTll->getPhase(nextPhase).duration;
479 } else {
480 // we are in transition to a green phase
481 // -> skip forward to the transition into the next green phase
482 // but ensure that the total transition time is maintained
483 // taking into account how much time was already spent
484 SUMOTime spentTransition = minTll->getSpentDuration();
485 // the transition may consist of more than one phase so we
486 // search backwards until the prior green phase
487 for (int i = ci - 1; i != ci; i--) {
488 if (i < 0) {
489 i = n - 1;
490 }
491 if (minTll->getPhase(i).isGreenPhase()) {
492 break;
493 }
494 spentTransition += minTll->getPhase(i).duration;
495 }
496 // now we skip past the next greenphase
497 int numGreen = 0;
498 int i = nextPhase;
499 for (; numGreen < 2; i = (i + 1) % n) {
500 if (minTll->getPhase(i).isGreenPhase()) {
501 numGreen++;
502 continue;
503 }
504 // transition after the next green
505 if (numGreen == 1) {
506 SUMOTime dur = minTll->getPhase(i).duration;
507 if (dur <= spentTransition) {
508 spentTransition -= dur;
509 } else {
510 nextPhase = i;
511 nextDuration = dur - spentTransition;
512 break;
513 }
514 }
515 }
516 }
517 minTll->changeStepAndDuration(tlsControl, MSNet::getInstance()->getCurrentTimeStep(), nextPhase, nextDuration);
518 update();
519 }
520 } else {
521 // DRT game
523 return;
524 }
525 const auto& sel = gSelected.getSelected(GLO_VEHICLE);
526 if (sel.size() == 0) {
527 // find closest pt vehicle
528 double minDist = std::numeric_limits<double>::infinity();
529 GUIVehicle* closest = nullptr;
533 for (it = vc.loadedVehBegin(); it != end; ++it) {
534 GUIVehicle* veh = dynamic_cast<GUIVehicle*>(it->second);
535 assert(veh != 0);
536 if (veh->getParameter().line != "") {
537 const double dist = veh->getPosition().distanceTo2D(pos);
538 if (dist < minDist) {
539 minDist = dist;
540 closest = veh;
541 }
542 }
543 }
544 if (closest != nullptr) {
545 gSelected.select(closest->getGlID());
547 }
548 } else {
549 // find closest pt stop
550 double minDist = std::numeric_limits<double>::infinity();
551 MSStoppingPlace* closestStop = nullptr;
553 for (auto it = stops.begin(); it != stops.end(); ++it) {
554 MSStoppingPlace* stop = it->second;
555 const double dist = pos.distanceTo2D(stop->getLane().geometryPositionAtOffset(stop->getEndLanePosition()));
556 if (dist < minDist) {
557 minDist = dist;
558 closestStop = stop;
559 }
560 }
561 if (closestStop != 0) {
562 GUIGlID id = *sel.begin();
564 assert(veh != 0);
565 MSLane* lane = veh->getMutableLane();
566 lane->getVehiclesSecure();
567 veh->rerouteDRTStop(closestStop);
569 lane->releaseVehicles();
570 }
571 }
572 }
573}
574
575
576void
578 const auto& sel = gSelected.getSelected(GLO_VEHICLE);
579 if (sel.size() > 0) {
580 GUIGlID id = *sel.begin();
582 if (veh != 0) {
584 }
586 }
588}
589
590
595
596
597long
598GUIViewTraffic::onCmdCloseLane(FXObject*, FXSelector, void*) {
599 GUILane* lane = getLaneUnderCursor();
600 if (lane != nullptr) {
601 lane->closeTraffic();
603 update();
604 }
605 return 1;
606}
607
608
609long
610GUIViewTraffic::onCmdCloseEdge(FXObject*, FXSelector, void*) {
611 GUILane* lane = getLaneUnderCursor();
612 if (lane != nullptr) {
613 dynamic_cast<GUIEdge*>(&lane->getEdge())->closeTraffic(lane);
615 update();
616 }
617 return 1;
618}
619
620
621long
622GUIViewTraffic::onCmdAddRerouter(FXObject*, FXSelector, void*) {
623 GUILane* lane = getLaneUnderCursor();
624 if (lane != nullptr) {
625 dynamic_cast<GUIEdge*>(&lane->getEdge())->addRerouter();
627 update();
628 }
629 return 1;
630}
631
632
633long
634GUIViewTraffic::showLaneReachability(GUILane* lane, FXObject* menu, FXSelector) {
635 if (lane != nullptr) {
636 // reset
637 const double UNREACHED = INVALID_DOUBLE;
639 for (const MSEdge* const e : MSEdge::getAllEdges()) {
640 for (MSLane* const l : e->getLanes()) {
641 GUILane* gLane = dynamic_cast<GUILane*>(l);
642 gLane->setReachability(UNREACHED);
643 }
644 }
645 // prepare
646 FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
647 const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
648 const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(svc).desiredMaxSpeed;
649 // find reachable
650 std::map<MSEdge*, double> reachableEdges;
651 reachableEdges[&lane->getEdge()] = 0;
652 MSEdgeVector check;
653 check.push_back(&lane->getEdge());
654 while (check.size() > 0) {
655 MSEdge* e = check.front();
656 check.erase(check.begin());
657 double traveltime = reachableEdges[e];
658 for (MSLane* const l : e->getLanes()) {
659 if (l->allowsVehicleClass(svc)) {
660 GUILane* gLane = dynamic_cast<GUILane*>(l);
661 gSelected.select(gLane->getGlID(), false);
662 gLane->setReachability(traveltime);
663 }
664 }
665 const double dt = e->getLength() / MIN2(e->getSpeedLimit(), defaultMaxSpeed);
666 // ensure algorithm termination
667 traveltime += MAX2(dt, NUMERICAL_EPS);
668 for (MSEdge* const nextEdge : e->getSuccessors(svc)) {
669 if (reachableEdges.count(nextEdge) == 0 ||
670 // revisit edge via faster path
671 reachableEdges[nextEdge] > traveltime) {
672 reachableEdges[nextEdge] = traveltime;
673 check.push_back(nextEdge);
674 }
675 }
676 if (svc == SVC_PEDESTRIAN) {
677 // can also walk backwards
678 for (MSEdge* const prevEdge : e->getPredecessors()) {
679 if (prevEdge->allowedLanes(*e, svc) != nullptr &&
680 (reachableEdges.count(prevEdge) == 0 ||
681 // revisit edge via faster path
682 reachableEdges[prevEdge] > traveltime)) {
683 reachableEdges[prevEdge] = traveltime;
684 check.push_back(prevEdge);
685 }
686 }
687 // and connect to arbitrary incoming if there are no walkingareas
689 for (const MSEdge* const in_const : e->getToJunction()->getIncoming()) {
690 MSEdge* in = const_cast<MSEdge*>(in_const);
691 if ((in->getPermissions() & svc) == svc &&
692 (reachableEdges.count(in) == 0 ||
693 // revisit edge via faster path
694 reachableEdges[in] > traveltime)) {
695 reachableEdges[in] = traveltime;
696 check.push_back(in);
697 }
698 }
699 }
700 }
701 }
703 }
704 return 1;
705}
706
707
708long
709GUIViewTraffic::onCmdShowReachability(FXObject* menu, FXSelector selector, void*) {
710 GUILane* lane = getLaneUnderCursor();
711 if (lane != nullptr) {
712 // reset
713 showLaneReachability(lane, menu, selector);
714 // switch to 'color by selection' unless coloring 'by reachability'
717 }
718 update();
719 }
720 return 1;
721}
722
723
724GUILane*
726 if (makeCurrent()) {
727 int id = getObjectUnderCursor();
728 if (id != 0) {
730 if (o != nullptr) {
731 return dynamic_cast<GUILane*>(o);
732 }
733 }
734 makeNonCurrent();
735 }
736 return nullptr;
737}
738
739
740long
741GUIViewTraffic::onDoubleClicked(FXObject*, FXSelector, void*) {
742 // leave fullscreen mode
743 if (myApp->isFullScreen()) {
744 myApp->onCmdFullScreen(nullptr, 0, nullptr);
745 } else {
746 stopTrack();
747 }
748 return 1;
749}
750
751
752
753void
754GUIViewTraffic::saveFrame(const std::string& destFile, FXColor* buf) {
755#ifdef HAVE_FFMPEG
756 if (myCurrentVideo == nullptr) {
757 myCurrentVideo = new GUIVideoEncoder(destFile.c_str(), getWidth(), getHeight(), myApp->getDelay());
758 }
759 myCurrentVideo->writeFrame((uint8_t*)buf);
760#else
761 UNUSED_PARAMETER(destFile);
762 UNUSED_PARAMETER(buf);
763#endif
764}
765
766
767void
769#ifdef HAVE_FFMPEG
770 if (myCurrentVideo != nullptr) {
771 delete myCurrentVideo;
772 myCurrentVideo = nullptr;
773 }
774#endif
775}
776
777
778void
780#ifdef HAVE_FFMPEG
781 if (myCurrentVideo != nullptr) {
783 }
784#endif
786}
787
788
789const std::vector<SUMOTime>
793
794
795void
797 GUIShapeContainer& shapeContainer = dynamic_cast<GUIShapeContainer&>(GUINet::getInstance()->getShapeContainer());
798 if (s.showPedestrianNetwork) {
799 shapeContainer.removeInactivePolygonTypes(std::set<std::string> {"jupedsim.pedestrian_network"});
800 } else {
801 shapeContainer.addInactivePolygonTypes(std::set<std::string> {"jupedsim.pedestrian_network"});
802 }
803 update();
804}
805
806
807void
809 GUIShapeContainer& shapeContainer = dynamic_cast<GUIShapeContainer&>(GUINet::getInstance()->getShapeContainer());
810 for (auto polygonwithID : shapeContainer.getPolygons()) {
811 if (polygonwithID.second->getShapeType() == "jupedsim.pedestrian_network") {
812 polygonwithID.second->setShapeColor(s.pedestrianNetworkColor);
813 }
814 }
815 update();
816}
817
818/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ MID_HOTKEY_SHIFT_O_LOCATEPOI
Locate poi - button.
Definition GUIAppEnum.h:182
@ MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL
Locate additional structure - button.
Definition GUIAppEnum.h:172
@ MID_HOTKEY_SHIFT_C_LOCATECONTAINER
Locate container - button.
Definition GUIAppEnum.h:174
@ MID_HOTKEY_SHIFT_V_LOCATEVEHICLE
Locate vehicle - button.
Definition GUIAppEnum.h:192
@ MID_HOTKEY_SHIFT_L_LOCATEPOLY
Locate polygons - button.
Definition GUIAppEnum.h:180
@ MID_HOTKEY_SHIFT_E_LOCATEEDGE
Locate edge - button.
Definition GUIAppEnum.h:176
@ MID_HOTKEY_SHIFT_P_LOCATEPERSON
Locate person - button.
Definition GUIAppEnum.h:184
@ MID_HOTKEY_SHIFT_J_LOCATEJUNCTION
Locate junction - button.
Definition GUIAppEnum.h:178
@ MID_HOTKEY_SHIFT_T_LOCATETLS
Locate TLS - button.
Definition GUIAppEnum.h:190
GUICompleteSchemeStorage gSchemeStorage
#define GUIDesignButtonPopup
checkable button placed in popup (for example, locate buttons)
Definition GUIDesigns.h:130
unsigned int GUIGlID
Definition GUIGlObject.h:44
GUIGlObjectType
@ GLO_REROUTER_EDGE
a Rerouter over edge
@ 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 TL(string)
Definition MsgHandler.h:304
#define INVALID_ID
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
@ SUMO_TAG_BUS_STOP
A bus stop.
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
const double SUMO_const_laneWidth
Definition StdDefs.h:52
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
A MSVehicle extended by some values for usage within the gui.
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_TRACK
track the vehicle (only needed for cleaning up)
@ 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:51
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUIEdge.cpp:544
MFXComboBoxIcon * getColoringSchemesCombo()
return combobox with the current coloring schemes (standard, fastest standard, real world....
FXPopup * getLocatorPopup()
@ brief return a pointer to locator popup
virtual double getColorValue(const GUIVisualizationSettings &, int) const
static const GUIGlID INVALID_ID
Definition GUIGlObject.h:73
virtual void onLeftBtnPress(void *)
notify object about left click
GUIGlID getGlID() const
Returns the numerical id of the object.
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 bool gSecondaryShape
whether secondary shapes are currently being drawn
Definition GUIGlobals.h:49
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:246
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUILane.cpp:1307
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1594
A MSVehicle extended by some values for usage within the gui.
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:591
void unlock()
release exclusive access to the simulation state
Definition GUINet.cpp:603
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition GUINet.cpp:743
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition GUINet.h:287
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
Definition GUINet.cpp:753
void lock()
grant exclusive access to the simulation state
Definition GUINet.cpp:597
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition GUINet.cpp:581
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
Definition GUINet.cpp:764
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition GUINet.cpp:608
const std::string & getName() const
int addColor(const T &color, const double threshold, const std::string &name="")
virtual void checkSnapshots()
Checks whether it is time for a snapshot.
void paintGLGrid() const
paints a grid
FXbool makeCurrent()
A reimplementation due to some internal reasons.
void buildMinMaxRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, const GUIVisualizationRainbowSettings &rs, double minValue, double maxValue, bool hasMissingData)
helper function for buildColorRainbow
GUIGlID getObjectUnderCursor(double sensitivity=SENSITIVITY)
returns the id of the front object under the cursor using GL_SELECT
void addSnapshot(SUMOTime time, const std::string &file, const int w=-1, const int h=-1)
Sets the snapshot time to file map.
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
GUIMainWindow * myApp
The application.
std::vector< GUIGlObject * > getGUIGlObjectsAtPosition(Position pos, double radius)
returns the GUIGlObjects at position within the given (rectangular) radius using GL_SELECT
double m2p(double meter) const
meter-to-pixels conversion method
GUIVisualizationSettings * myVisualizationSettings
visualization settings
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIDialog_ViewSettings * myGUIDialogViewSettings
Visualization changer.
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 notifyChanged()
inform the update target of earlier changes
void clear()
Clears the list of selected objects.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
const std::unordered_set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
Storage for geometrical objects extended by mutexes.
void removeInactivePolygonTypes(std::set< std::string > inactivePolygonTypes)
Remove some polygon types that were deemed as inactive.
void addInactivePolygonTypes(std::set< std::string > inactivePolygonTypes)
Adds new polygon types to the set of inactive ones.
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.
void saveFrame(const std::string &destFile, FXColor *buf) override
Adds a frame to a video snapshot which will be initialized if necessary.
SUMOTime getCurrentTimeStep() const override
get the current simulation time
std::vector< std::string > getVehicleParamKeys(bool vTypeKeys) const override
return list of available vehicle parameters
virtual void buildViewToolBars(GUIGlChildWindow *) override
builds the view toolbars
std::vector< std::string > getMeanDataIDs() const override
return list of loaded edgeData ids (being computed in the current simulation)
void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20) override
centers to the chosen artifact
virtual ~GUIViewTraffic()
destructor
long onCmdCloseLane(FXObject *, FXSelector, void *) override
interaction with the simulation
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const override
return list of available attributes for the given meanData id
void stopTrack() override
Stops vehicle tracking.
int doPaintGL(int mode, const Boundary &bound) override
paint GL
GUIGlID getTrackedID() const override
Returns the id of the tracked vehicle (-1 if none)
std::vector< std::string > getPOIParamKeys() const override
return list of available POI parameters
long onCmdCloseEdge(FXObject *, FXSelector, void *) override
void onGamingClick(Position pos) override
handle mouse click in gaming mode
void endSnapshot() override
Ends a video snapshot.
long onCmdShowReachability(FXObject *, FXSelector, void *) override
highlight edges according to reachability
void drawPedestrianNetwork(const GUIVisualizationSettings &s) const override
Draw (or not) the JuPedSim pedestrian network.
void checkSnapshots() override
Checks whether it is time for a snapshot.
bool setColorScheme(const std::string &name) override
set color scheme
const std::vector< SUMOTime > retrieveBreakpoints() const override
retrieve breakpoints from the current runThread
GUILane * getLaneUnderCursor() override
returns the GUILane at cursor position (implementation depends on view)
void buildColorRainbow(const GUIVisualizationSettings &s, GUIColorScheme &scheme, int active, GUIGlObjectType objectType, const GUIVisualizationRainbowSettings &rs) override
recalibrate color scheme according to the current value range
void startTrack(int id) override
Starts vehicle tracking.
long onDoubleClicked(FXObject *, FXSelector, void *) override
std::vector< std::string > getEdgeDataAttrs() const override
return list of loaded edgeData attributes
static long showLaneReachability(GUILane *lane, FXObject *, FXSelector)
long onCmdAddRerouter(FXObject *, FXSelector, void *) override
std::vector< std::string > getEdgeLaneParamKeys(bool edgeKeys) const override
return list of available edge parameters
void changePedestrianNetworkColor(const GUIVisualizationSettings &s) const override
Change the color of the JuPedSim pedestrian network.
bool myTLSGame
whether game mode was set to 'tls'
void onGamingRightClick(Position pos) override
Stores the information about how to visualize structures.
bool showPedestrianNetwork
Flag for visualizing the pedestrian network generated for JuPedSim.
std::string name
The name of this setting.
RGBColor pedestrianNetworkColor
The color of the pedestrian network generated for JuPedSim.
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)
bool secondaryShape
whether secondary lane shape shall be drawn
GUIColorer laneColorer
The lane colorer.
static const std::string SCHEME_NAME_PERMISSION_CODE
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getNumItems() const
Return the number of items in the list.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
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:1096
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:657
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:1168
const MSJunction * getToJunction() const
Definition MSEdge.h:426
double getLength() const
return the length of the edge
Definition MSEdge.h:693
const MSEdgeVector & getPredecessors() const
Definition MSEdge.h:417
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1268
static bool gUseMesoSim
Definition MSGlobals.h:106
The base class for an intersection.
Definition MSJunction.h:58
const ConstMSEdgeVector & getIncoming() const
Definition MSJunction.h:108
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:483
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition MSLane.h:513
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:769
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition MSNet.h:465
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:334
bool hasPedestrianNetwork() const
return whether the network contains walkingareas and crossings
Definition MSNet.h:809
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition MSNet.h:515
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:392
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1488
SUMOTime duration
The duration of the phase.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
bool isAllRedPhase() const
Returns whether this phase is an "all red" phase.
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 const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
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.
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
virtual const Phases & getPhases() const =0
Returns the phases of this tls program.
SUMOTime getSpentDuration(SUMOTime simStep=-1) const
Returns the duration spent in the current phase.
The class responsible for building and deletion of vehicles.
virtual void releaseVehicles()
unlock access to vehicle removal/additions for thread synchronization
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.
virtual void secureVehicles()
lock access to vehicle removal/additions for thread synchronization
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:589
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:273
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:263
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:403
A RT-tree for efficient storing of SUMO's GL-objects.
Definition SUMORTree.h:66
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:114
std::string line
The vehicle's line (mainly for public transport)
Storage for geometrical objects.
const Polygons & getPolygons() const
Returns all polygons.
#define UNUSED_PARAMETER(x)
struct for default values that depend of VClass
double desiredMaxSpeed
The vehicle type's desired maximum speed [m/s].