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-2026 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>
41#include <guisim/GUIVehicle.h>
45#include <microsim/MSEdge.h>
46#include <microsim/MSGlobals.h>
48#include <microsim/MSLane.h>
70
71#include "GUISUMOViewParent.h"
72#include "GUIViewTraffic.h"
73
74// ===========================================================================
75// member method definitions
76// ===========================================================================
78 FXComposite* p,
79 GUIMainWindow& app,
80 GUISUMOViewParent* parent,
81 GUINet& net, FXGLVisual* glVis,
82 FXGLCanvas* share) :
83 GUISUMOAbstractView(p, app, parent, net.getVisualisationSpeedUp(), glVis, share),
84 myTrackedID(GUIGlObject::INVALID_ID),
85 myTLSGame(OptionsCont::getOptions().getString("game.mode") == "tls")
86#ifdef HAVE_FFMPEG
87 , myCurrentVideo(nullptr)
88#endif
89{}
90
91
95
96
97void
99 // build coloring tools
100 {
101 const std::vector<std::string>& names = gSchemeStorage.getNames();
102 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
103 v->getColoringSchemesCombo()->appendIconItem(i->c_str());
104 if ((*i) == myVisualizationSettings->name) {
106 }
107 }
108 }
109 // for junctions
111 (std::string("\t") + TL("Locate Junctions") + std::string("\t") + TL("Locate a junction within the network.")).c_str(),
114 // for edges
116 (std::string("\t") + TL("Locate Edges") + std::string("\t") + TL("Locate an edge within the network.")).c_str(),
119 // for vehicles
121 (std::string("\t") + TL("Locate Vehicles") + std::string("\t") + TL("Locate a vehicle within the network.")).c_str(),
124 // for persons
126 (std::string("\t") + TL("Locate Persons") + std::string("\t") + TL("Locate a person within the network.")).c_str(),
129 // for containers
131 (std::string("\t") + TL("Locate Container") + std::string("\t") + TL("Locate a container within the network.")).c_str(),
134 // for tls
136 (std::string("\t") + TL("Locate TLS") + std::string("\t") + TL("Locate a tls within the network.")).c_str(),
139 // for additional stuff
141 (std::string("\t") + TL("Locate Additional") + std::string("\t") + TL("Locate an additional structure within the network.")).c_str(),
144 // for pois
146 (std::string("\t") + TL("Locate PoI") + std::string("\t") + TL("Locate a PoI within the network.")).c_str(),
149 // for polygons
151 (std::string("\t") + TL("Locate Polygon") + std::string("\t") + TL("Locate a Polygon within the network.")).c_str(),
154}
155
156
157bool
158GUIViewTraffic::setColorScheme(const std::string& name) {
159 if (!gSchemeStorage.contains(name)) {
160 return false;
161 }
162 if (myGUIDialogViewSettings != nullptr) {
165 }
166 }
169 update();
170 return true;
171}
172
173
174void
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_VEHICLE) {
214 for (MSVehicleControl::constVehIt it_v = c.loadedVehBegin(); it_v != c.loadedVehEnd(); ++it_v) {
215 const GUIGlObject* veh;
217 veh = static_cast<const GUIMEVehicle*>(it_v->second);
218 } else {
219 veh = static_cast<const GUIVehicle*>(it_v->second);
220 }
221 const double val = veh->getColorValue(s, active);
222 if (val == s.MISSING_DATA) {
223 hasMissingData = true;
224 continue;
225 }
226 minValue = MIN2(minValue, val);
227 maxValue = MAX2(maxValue, val);
228 }
229 } else if (objectType == GLO_JUNCTION) {
230 if (active == 3) {
231 std::set<const MSJunction*> junctions;
232 for (MSEdge* edge : MSEdge::getAllEdges()) {
233 junctions.insert(edge->getFromJunction());
234 junctions.insert(edge->getToJunction());
235 }
236 for (const MSJunction* junction : junctions) {
237 minValue = MIN2(minValue, junction->getPosition().z());
238 maxValue = MAX2(maxValue, junction->getPosition().z());
239 }
240 }
241 }
243 scheme.clear();
244 // add threshold for every distinct value
245 std::set<SVCPermissions> codes;
246 for (MSEdge* edge : MSEdge::getAllEdges()) {
247 for (MSLane* lane : edge->getLanes()) {
248 codes.insert(lane->getPermissions());
249 }
250 }
251 int step = MAX2(1, 360 / (int)codes.size());
252 int hue = 0;
253 for (SVCPermissions p : codes) {
254 scheme.addColor(RGBColor::fromHSV(hue, 1, 1), (double)p);
255 hue = (hue + step) % 360;
256 }
257 return;
258 }
259 buildMinMaxRainbow(s, scheme, rs, minValue, maxValue, hasMissingData);
260}
261
262
263std::vector<std::string>
265 if (GUINet::getGUIInstance() != nullptr) {
267 }
268 return std::vector<std::string>();
269}
270
271
272std::vector<std::string>
274 if (GUINet::getGUIInstance() != nullptr) {
276 }
277 return std::vector<std::string>();
278}
279
280std::vector<std::string>
281GUIViewTraffic::getMeanDataAttrs(const std::string& meanDataID) const {
282 if (GUINet::getGUIInstance() != nullptr) {
283 return GUINet::getGUIInstance()->getMeanDataAttrs(meanDataID);
284 }
285 return std::vector<std::string>();
286}
287
288
289std::vector<std::string>
291 std::set<std::string> keys;
292 for (const MSEdge* e : MSEdge::getAllEdges()) {
293 if (edgeKeys) {
294 for (const auto& item : e->getParametersMap()) {
295 keys.insert(item.first);
296 }
297 } else {
298 for (const auto lane : e->getLanes()) {
299 for (const auto& item : lane->getParametersMap()) {
300 keys.insert(item.first);
301 }
302 }
303 }
304 }
305 return std::vector<std::string>(keys.begin(), keys.end());
306}
307
308
309std::vector<std::string>
310GUIViewTraffic::getVehicleParamKeys(bool /*vTypeKeys*/) const {
311 std::set<std::string> keys;
312 MSVehicleControl* vc = nullptr;
315 } else {
317 }
318 vc->secureVehicles();
319 for (auto vehIt = vc->loadedVehBegin(); vehIt != vc->loadedVehEnd(); ++vehIt) {
320 for (auto kv : vehIt->second->getParameter().getParametersMap()) {
321 keys.insert(kv.first);
322 }
323 }
324 vc->releaseVehicles();
325 return std::vector<std::string>(keys.begin(), keys.end());
326}
327
328std::vector<std::string>
330 std::set<std::string> keys;
331 const ShapeContainer::POIs& pois = static_cast<ShapeContainer&>(GUINet::getInstance()->getShapeContainer()).getPOIs();
332 for (auto item : pois) {
333 for (auto kv : item.second->getParametersMap()) {
334 keys.insert(kv.first);
335 }
336 }
337 return std::vector<std::string>(keys.begin(), keys.end());
338}
339
340
341void
347
348int
349GUIViewTraffic::doPaintGL(int mode, const Boundary& bound) {
350 // init view settings
351 glRenderMode(mode);
352 glMatrixMode(GL_MODELVIEW);
354 glDisable(GL_TEXTURE_2D);
355 glDisable(GL_ALPHA_TEST);
356 glEnable(GL_BLEND);
357 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
358 glEnable(GL_DEPTH_TEST);
359
360 // draw decals (if not in grabbing mode)
361 drawDecals();
364 paintGLGrid();
365 }
366 glLineWidth(1);
367 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
368 const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
369 const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
370 glEnable(GL_POLYGON_OFFSET_FILL);
371 glEnable(GL_POLYGON_OFFSET_LINE);
373 int hits2 = grid.Search(minB, maxB, *myVisualizationSettings);
375 // Draw additional objects
376 if (myAdditionallyDrawn.size() > 0) {
377 glTranslated(0, 0, -.01);
379 for (auto i : myAdditionallyDrawn) {
380 i.first->drawGLAdditional(this, *myVisualizationSettings);
381 }
383 glTranslated(0, 0, .01);
384 }
386 /*
387 // draw legends
388 glMatrixMode(GL_MODELVIEW);
389 glLoadIdentity();
390 glTranslated(1.-.2, 1.-.5, 0.);
391 glScaled(.2, .5, 1.);
392 GUIColoringSchemesMap<GUILane> &sm = GUIViewTraffic::getLaneSchemesMap(); //!!!
393 sm.getColorer(myVisualizationSettings->laneEdgeMode)->drawLegend();
394 */
395 return hits2;
396}
397
398
399void
401 myTrackedID = id;
403 if (o != nullptr) {
404 GUIBaseVehicle* v = dynamic_cast<GUIBaseVehicle*>(o);
405 if (v != nullptr) {
407 }
408 }
409}
410
411
412void
416
417
420 return myTrackedID;
421}
422
423
424void
426 if (myTLSGame) {
428 MSTrafficLightLogic* minTll = nullptr;
429 GUIGlObject* minRR = nullptr;
430 double minDist = std::numeric_limits<double>::infinity();
431 double minDistRR = std::numeric_limits<double>::infinity();
432 for (MSTrafficLightLogic* const tll : tlsControl.getAllLogics()) {
433 if (tlsControl.isActive(tll) && tll->getProgramID() != "off") {
434 // get the links
435 const MSTrafficLightLogic::LaneVector& lanes = tll->getLanesAt(0);
436 if (lanes.size() > 0) {
437 const Position& endPos = lanes[0]->getShape().back();
438 if (endPos.distanceTo(pos) < minDist) {
439 minDist = endPos.distanceTo(pos);
440 minTll = tll;
441 }
442 }
443 }
444 }
445 if (makeCurrent()) {
447 if (o->getType() == GLO_REROUTER_EDGE) {
448 const MSEdge* const edge = dynamic_cast<GUITriggeredRerouter::GUITriggeredRerouterEdge*>(o)->getEdge();
449 const double dist = edge->getFromJunction()->getPosition().distanceTo2D(pos);
450 if (dist < minDistRR) {
451 minDistRR = dist;
452 minRR = o;
453 }
454 }
455 }
456 makeNonCurrent();
457 }
458 if (minDistRR < minDist && minRR != nullptr) {
459 minRR->onLeftBtnPress(nullptr);
460 update();
461 return;
462 }
463
464 if (minTll != nullptr) {
465 if (minTll->getPhaseNumber() == 0) {
466 // MSRailSignal
467 return;
468 }
469 const int ci = minTll->getCurrentPhaseIndex();
470 const int n = minTll->getPhaseNumber();
471 int greenCount = 0;
472 for (auto& phase : minTll->getPhases()) {
473 if (phase->isGreenPhase()) {
474 greenCount++;
475 }
476 }
477 int nextPhase = (ci + 1) % n;
478 SUMOTime nextDuration = 0;
479 if (minTll->getCurrentPhaseDef().isGreenPhase() || (greenCount == 1 && minTll->getCurrentPhaseDef().isAllRedPhase())) {
480 nextDuration = minTll->getPhase(nextPhase).duration;
481 } else {
482 // we are in transition to a green phase
483 // -> skip forward to the transition into the next green phase
484 // but ensure that the total transition time is maintained
485 // taking into account how much time was already spent
486 SUMOTime spentTransition = minTll->getSpentDuration();
487 // the transition may consist of more than one phase so we
488 // search backwards until the prior green phase
489 for (int i = ci - 1; i != ci; i--) {
490 if (i < 0) {
491 i = n - 1;
492 }
493 if (minTll->getPhase(i).isGreenPhase()) {
494 break;
495 }
496 spentTransition += minTll->getPhase(i).duration;
497 }
498 // now we skip past the next greenphase
499 int numGreen = 0;
500 int i = nextPhase;
501 for (; numGreen < 2; i = (i + 1) % n) {
502 if (minTll->getPhase(i).isGreenPhase()) {
503 numGreen++;
504 continue;
505 }
506 // transition after the next green
507 if (numGreen == 1) {
508 SUMOTime dur = minTll->getPhase(i).duration;
509 if (dur <= spentTransition) {
510 spentTransition -= dur;
511 } else {
512 nextPhase = i;
513 nextDuration = dur - spentTransition;
514 break;
515 }
516 }
517 }
518 }
519 minTll->changeStepAndDuration(tlsControl, MSNet::getInstance()->getCurrentTimeStep(), nextPhase, nextDuration);
520 update();
521 }
522 } else {
523 // DRT game
525 return;
526 }
527 const auto& sel = gSelected.getSelected(GLO_VEHICLE);
528 if (sel.size() == 0) {
529 // find closest pt vehicle
530 double minDist = std::numeric_limits<double>::infinity();
531 GUIVehicle* closest = nullptr;
535 for (it = vc.loadedVehBegin(); it != end; ++it) {
536 GUIVehicle* veh = dynamic_cast<GUIVehicle*>(it->second);
537 assert(veh != 0);
538 if (veh->getParameter().line != "") {
539 const double dist = veh->getPosition().distanceTo2D(pos);
540 if (dist < minDist) {
541 minDist = dist;
542 closest = veh;
543 }
544 }
545 }
546 if (closest != nullptr) {
547 gSelected.select(closest->getGlID());
549 }
550 } else {
551 // find closest pt stop
552 double minDist = std::numeric_limits<double>::infinity();
553 MSStoppingPlace* closestStop = nullptr;
555 for (auto it = stops.begin(); it != stops.end(); ++it) {
556 MSStoppingPlace* stop = it->second;
557 const double dist = pos.distanceTo2D(stop->getLane().geometryPositionAtOffset(stop->getEndLanePosition()));
558 if (dist < minDist) {
559 minDist = dist;
560 closestStop = stop;
561 }
562 }
563 if (closestStop != 0) {
564 GUIGlID id = *sel.begin();
566 assert(veh != 0);
567 MSLane* lane = veh->getMutableLane();
568 lane->getVehiclesSecure();
569 veh->rerouteDRTStop(closestStop);
571 lane->releaseVehicles();
572 }
573 }
574 }
575}
576
577
578void
580 const auto& sel = gSelected.getSelected(GLO_VEHICLE);
581 if (sel.size() > 0) {
582 GUIGlID id = *sel.begin();
584 if (veh != 0) {
586 }
588 }
590}
591
592
597
598
599long
600GUIViewTraffic::onCmdCloseLane(FXObject*, FXSelector, void*) {
601 GUILane* lane = getLaneUnderCursor();
602 if (lane != nullptr) {
603 lane->closeTraffic();
605 update();
606 }
607 return 1;
608}
609
610
611long
612GUIViewTraffic::onCmdCloseEdge(FXObject*, FXSelector, void*) {
613 GUILane* lane = getLaneUnderCursor();
614 if (lane != nullptr) {
615 dynamic_cast<GUIEdge*>(&lane->getEdge())->closeTraffic(lane);
617 update();
618 }
619 return 1;
620}
621
622
623long
624GUIViewTraffic::onCmdAddRerouter(FXObject*, FXSelector, void*) {
625 GUILane* lane = getLaneUnderCursor();
626 if (lane != nullptr) {
627 dynamic_cast<GUIEdge*>(&lane->getEdge())->addRerouter();
629 update();
630 }
631 return 1;
632}
633
634
635long
636GUIViewTraffic::showLaneReachability(GUILane* lane, FXObject* menu, FXSelector) {
637 if (lane != nullptr) {
638 // reset
639 const double UNREACHED = INVALID_DOUBLE;
641 for (const MSEdge* const e : MSEdge::getAllEdges()) {
642 for (MSLane* const l : e->getLanes()) {
643 GUILane* gLane = dynamic_cast<GUILane*>(l);
644 gLane->setReachability(UNREACHED);
645 }
646 }
647 // prepare
648 FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
649 const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
650 const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(svc).desiredMaxSpeed;
651 // find reachable
652 std::map<MSEdge*, double> reachableEdges;
653 reachableEdges[&lane->getEdge()] = 0;
654 MSEdgeVector check;
655 check.push_back(&lane->getEdge());
656 while (check.size() > 0) {
657 MSEdge* e = check.front();
658 check.erase(check.begin());
659 double traveltime = reachableEdges[e];
660 for (MSLane* const l : e->getLanes()) {
661 if (l->allowsVehicleClass(svc)) {
662 GUILane* gLane = dynamic_cast<GUILane*>(l);
663 gSelected.select(gLane->getGlID(), false);
664 gLane->setReachability(traveltime);
665 }
666 }
667 const double dt = e->getLength() / MIN2(e->getSpeedLimit(), defaultMaxSpeed);
668 // ensure algorithm termination
669 traveltime += MAX2(dt, NUMERICAL_EPS);
670 for (MSEdge* const nextEdge : e->getSuccessors(svc)) {
671 if (reachableEdges.count(nextEdge) == 0 ||
672 // revisit edge via faster path
673 reachableEdges[nextEdge] > traveltime) {
674 reachableEdges[nextEdge] = traveltime;
675 check.push_back(nextEdge);
676 }
677 }
678 if (svc == SVC_PEDESTRIAN) {
679 // can also walk backwards
680 for (MSEdge* const prevEdge : e->getPredecessors()) {
681 if (prevEdge->allowedLanes(*e, svc) != nullptr &&
682 (reachableEdges.count(prevEdge) == 0 ||
683 // revisit edge via faster path
684 reachableEdges[prevEdge] > traveltime)) {
685 reachableEdges[prevEdge] = traveltime;
686 check.push_back(prevEdge);
687 }
688 }
689 // and connect to arbitrary incoming if there are no walkingareas
691 for (const MSEdge* const in_const : e->getToJunction()->getIncoming()) {
692 MSEdge* in = const_cast<MSEdge*>(in_const);
693 if ((in->getPermissions() & svc) == svc &&
694 (reachableEdges.count(in) == 0 ||
695 // revisit edge via faster path
696 reachableEdges[in] > traveltime)) {
697 reachableEdges[in] = traveltime;
698 check.push_back(in);
699 }
700 }
701 }
702 }
703 }
705 }
706 return 1;
707}
708
709
710long
711GUIViewTraffic::onCmdShowReachability(FXObject* menu, FXSelector selector, void*) {
712 GUILane* lane = getLaneUnderCursor();
713 if (lane != nullptr) {
714 // reset
715 showLaneReachability(lane, menu, selector);
716 // switch to 'color by selection' unless coloring 'by reachability'
719 }
720 update();
721 }
722 return 1;
723}
724
725
726GUILane*
728 if (makeCurrent()) {
729 int id = getObjectUnderCursor();
730 if (id != 0) {
732 if (o != nullptr) {
733 return dynamic_cast<GUILane*>(o);
734 }
735 }
736 makeNonCurrent();
737 }
738 return nullptr;
739}
740
741
742long
743GUIViewTraffic::onDoubleClicked(FXObject*, FXSelector, void*) {
744 // leave fullscreen mode
745 if (myApp->isFullScreen()) {
746 myApp->onCmdFullScreen(nullptr, 0, nullptr);
747 } else {
748 stopTrack();
749 }
750 return 1;
751}
752
753
754
755void
756GUIViewTraffic::saveFrame(const std::string& destFile, FXColor* buf) {
757#ifdef HAVE_FFMPEG
758 if (myCurrentVideo == nullptr) {
759 myCurrentVideo = new GUIVideoEncoder(destFile.c_str(), getWidth(), getHeight(), myApp->getDelay());
760 }
761 myCurrentVideo->writeFrame((uint8_t*)buf);
762#else
763 UNUSED_PARAMETER(destFile);
764 UNUSED_PARAMETER(buf);
765#endif
766}
767
768
769void
771#ifdef HAVE_FFMPEG
772 if (myCurrentVideo != nullptr) {
773 delete myCurrentVideo;
774 myCurrentVideo = nullptr;
775 }
776#endif
777}
778
779
780void
782#ifdef HAVE_FFMPEG
783 if (myCurrentVideo != nullptr) {
785 }
786#endif
788}
789
790
791const std::vector<SUMOTime>
795
796
797void
799 GUIShapeContainer& shapeContainer = dynamic_cast<GUIShapeContainer&>(GUINet::getInstance()->getShapeContainer());
800 if (s.showPedestrianNetwork) {
801 shapeContainer.removeInactivePolygonTypes(std::set<std::string> {"jupedsim.pedestrian_network"});
802 } else {
803 shapeContainer.addInactivePolygonTypes(std::set<std::string> {"jupedsim.pedestrian_network"});
804 }
805 update();
806}
807
808
809void
811 GUIShapeContainer& shapeContainer = dynamic_cast<GUIShapeContainer&>(GUINet::getInstance()->getShapeContainer());
812 for (auto polygonwithID : shapeContainer.getPolygons()) {
813 if (polygonwithID.second->getShapeType() == "jupedsim.pedestrian_network") {
814 polygonwithID.second->setShapeColor(s.pedestrianNetworkColor);
815 }
816 }
817 update();
818}
819
820/****************************************************************************/
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 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
void removeActiveAddVisualisation(GUISUMOAbstractView *const parent, int which) override
Adds the named visualisation feature to the given view.
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:509
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:248
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition GUILane.cpp:1314
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition GUILane.cpp:1601
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:52
Position getPosition(const double offset=0) const override
Return current position (x/y, cartesian)
Definition GUIVehicle.h:72
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:1120
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:658
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:1192
const MSJunction * getToJunction() const
Definition MSEdge.h:427
double getLength() const
return the length of the edge
Definition MSEdge.h:694
const MSJunction * getFromJunction() const
Definition MSEdge.h:423
const MSEdgeVector & getPredecessors() const
Definition MSEdge.h:418
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1292
static bool gUseMesoSim
Definition MSGlobals.h:106
The base class for an intersection.
Definition MSJunction.h:58
const Position & getPosition(bool secondaryShape=false) const
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:484
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition MSLane.h:514
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:775
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:561
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:199
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition MSNet.h:475
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:826
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition MSNet.h:525
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:402
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1552
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].