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.dev/sumo
3// Copyright (C) 2001-2023 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>
42#include <microsim/MSEdge.h>
43#include <microsim/MSGlobals.h>
45#include <microsim/MSLane.h>
66
67#include "GUISUMOViewParent.h"
68#include "GUIViewTraffic.h"
69
70// ===========================================================================
71// member method definitions
72// ===========================================================================
74 FXComposite* p,
75 GUIMainWindow& app,
76 GUISUMOViewParent* parent,
77 GUINet& net, FXGLVisual* glVis,
78 FXGLCanvas* share) :
79 GUISUMOAbstractView(p, app, parent, net.getVisualisationSpeedUp(), glVis, share),
80 myTrackedID(GUIGlObject::INVALID_ID),
81 myTLSGame(OptionsCont::getOptions().getString("game.mode") == "tls")
82#ifdef HAVE_FFMPEG
83 , myCurrentVideo(nullptr)
84#endif
85{}
86
87
90}
91
92
93void
95 //
96}
97
98
99void
101 // build coloring tools
102 {
103 const std::vector<std::string>& names = gSchemeStorage.getNames();
104 for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) {
105 v->getColoringSchemesCombo()->appendItem(i->c_str());
106 if ((*i) == myVisualizationSettings->name) {
107 v->getColoringSchemesCombo()->setCurrentItem(v->getColoringSchemesCombo()->getNumItems() - 1);
108 }
109 }
110 v->getColoringSchemesCombo()->setNumVisible(MAX2(5, (int)names.size() + 1));
111 }
112 // for junctions
114 (std::string("\t") + TL("Locate Junctions") + std::string("\t") + TL("Locate a junction within the network.")).c_str(),
117 // for edges
119 (std::string("\t") + TL("Locate Edges") + std::string("\t") + TL("Locate an edge within the network.")).c_str(),
122 // for vehicles
124 (std::string("\t") + TL("Locate Vehicles") + std::string("\t") + TL("Locate a vehicle within the network.")).c_str(),
127 // for persons
129 (std::string("\t") + TL("Locate Persons") + std::string("\t") + TL("Locate a person within the network.")).c_str(),
132 // for containers
134 (std::string("\t") + TL("Locate Container") + std::string("\t") + TL("Locate a container within the network.")).c_str(),
137 // for tls
139 (std::string("\t") + TL("Locate TLS") + std::string("\t") + TL("Locate a tls within the network.")).c_str(),
142 // for additional stuff
144 (std::string("\t") + TL("Locate Additional") + std::string("\t") + TL("Locate an additional structure within the network.")).c_str(),
147 // for pois
149 (std::string("\t") + TL("Locate PoI") + std::string("\t") + TL("Locate a PoI within the network.")).c_str(),
152 // for polygons
154 (std::string("\t") + TL("Locate Polygon") + std::string("\t") + TL("Locate a Polygon within the network.")).c_str(),
157}
158
159
160bool
161GUIViewTraffic::setColorScheme(const std::string& name) {
162 if (!gSchemeStorage.contains(name)) {
163 return false;
164 }
165 if (myGUIDialogViewSettings != nullptr) {
168 }
169 }
172 update();
173 return true;
174}
175
176
177void
179 bool hide, double hideThreshold, bool hide2, double hideThreshold2) {
180 assert(!scheme.isFixed());
181 double minValue = std::numeric_limits<double>::infinity();
182 double maxValue = -std::numeric_limits<double>::infinity();
183 // retrieve range
184 bool hasMissingData = false;
185 if (objectType == GLO_LANE) {
186 // XXX (see #3409) multi-colors are not currently handled. this is a quick hack
187 if (active == 22) {
188 active = 21; // segment height, fall back to start height
189 } else if (active == 24) {
190 active = 23; // segment incline, fall back to total incline
191 }
192 const MSEdgeVector& edges = MSEdge::getAllEdges();
193 for (MSEdgeVector::const_iterator it = edges.begin(); it != edges.end(); ++it) {
195 const double val = static_cast<GUIEdge*>(*it)->getColorValue(s, active);
196 if (val == s.MISSING_DATA) {
197 hasMissingData = true;
198 continue;
199 }
200 minValue = MIN2(minValue, val);
201 maxValue = MAX2(maxValue, val);
202 } else {
203 const std::vector<MSLane*>& lanes = (*it)->getLanes();
204 for (std::vector<MSLane*>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); it_l++) {
205 const double val = static_cast<GUILane*>(*it_l)->getColorValue(s, active);
206 if (val == s.MISSING_DATA) {
207 hasMissingData = true;
208 continue;
209 }
210 minValue = MIN2(minValue, val);
211 maxValue = MAX2(maxValue, val);
212 }
213 }
214 }
215 } else if (objectType == GLO_JUNCTION) {
216 if (active == 3) {
217 std::set<const MSJunction*> junctions;
218 for (MSEdge* edge : MSEdge::getAllEdges()) {
219 junctions.insert(edge->getFromJunction());
220 junctions.insert(edge->getToJunction());
221 }
222 for (const MSJunction* junction : junctions) {
223 minValue = MIN2(minValue, junction->getPosition().z());
224 maxValue = MAX2(maxValue, junction->getPosition().z());
225 }
226 }
227 }
229 scheme.clear();
230 // add threshold for every distinct value
231 std::set<SVCPermissions> codes;
232 for (MSEdge* edge : MSEdge::getAllEdges()) {
233 for (MSLane* lane : edge->getLanes()) {
234 codes.insert(lane->getPermissions());
235 }
236 }
237 int step = MAX2(1, 360 / (int)codes.size());
238 int hue = 0;
239 for (SVCPermissions p : codes) {
240 scheme.addColor(RGBColor::fromHSV(hue, 1, 1), p);
241 hue = (hue + step) % 360;
242 }
243 return;
244 }
245
246 if (hide && hide2 && minValue == std::numeric_limits<double>::infinity()) {
247 minValue = hideThreshold;
248 maxValue = hideThreshold2;
249 }
250 if (minValue != std::numeric_limits<double>::infinity()) {
251 scheme.clear();
252 // add new thresholds
258 || hasMissingData) {
259 scheme.addColor(s.COL_MISSING_DATA, s.MISSING_DATA, "missing data");
260 }
261 if (hide) {
262 const double rawRange = maxValue - minValue;
263 minValue = MAX2(hideThreshold + MIN2(1.0, rawRange / 100.0), minValue);
264 scheme.addColor(RGBColor(204, 204, 204), hideThreshold);
265 }
266 if (hide2) {
267 const double rawRange = maxValue - minValue;
268 maxValue = MIN2(hideThreshold2 - MIN2(1.0, rawRange / 100.0), maxValue);
269 scheme.addColor(RGBColor(204, 204, 204), hideThreshold2);
270 }
271 double range = maxValue - minValue;
272 scheme.addColor(RGBColor::RED, (minValue));
273 scheme.addColor(RGBColor::ORANGE, (minValue + range * 1 / 6.0));
274 scheme.addColor(RGBColor::YELLOW, (minValue + range * 2 / 6.0));
275 scheme.addColor(RGBColor::GREEN, (minValue + range * 3 / 6.0));
276 scheme.addColor(RGBColor::CYAN, (minValue + range * 4 / 6.0));
277 scheme.addColor(RGBColor::BLUE, (minValue + range * 5 / 6.0));
278 scheme.addColor(RGBColor::MAGENTA, (maxValue));
279 }
280}
281
282
283std::vector<std::string>
285 if (GUINet::getGUIInstance() != nullptr) {
287 }
288 return std::vector<std::string>();
289}
290
291
292std::vector<std::string>
294 if (GUINet::getGUIInstance() != nullptr) {
296 }
297 return std::vector<std::string>();
298}
299
300std::vector<std::string>
301GUIViewTraffic::getMeanDataAttrs(const std::string& meanDataID) const {
302 if (GUINet::getGUIInstance() != nullptr) {
303 return GUINet::getGUIInstance()->getMeanDataAttrs(meanDataID);
304 }
305 return std::vector<std::string>();
306}
307
308
309std::vector<std::string>
311 std::set<std::string> keys;
312 for (const MSEdge* e : MSEdge::getAllEdges()) {
313 if (edgeKeys) {
314 for (const auto& item : e->getParametersMap()) {
315 keys.insert(item.first);
316 }
317 } else {
318 for (const auto lane : e->getLanes()) {
319 for (const auto& item : lane->getParametersMap()) {
320 keys.insert(item.first);
321 }
322 }
323 }
324 }
325 return std::vector<std::string>(keys.begin(), keys.end());
326}
327
328
329std::vector<std::string>
330GUIViewTraffic::getVehicleParamKeys(bool /*vTypeKeys*/) const {
331 std::set<std::string> keys;
333 vc->secureVehicles();
334 for (auto vehIt = vc->loadedVehBegin(); vehIt != vc->loadedVehEnd(); ++vehIt) {
335 for (auto kv : vehIt->second->getParameter().getParametersMap()) {
336 keys.insert(kv.first);
337 }
338 }
339 vc->releaseVehicles();
340 return std::vector<std::string>(keys.begin(), keys.end());
341}
342
343std::vector<std::string>
345 std::set<std::string> keys;
346 const ShapeContainer::POIs& pois = static_cast<ShapeContainer&>(GUINet::getInstance()->getShapeContainer()).getPOIs();
347 for (auto item : pois) {
348 for (auto kv : item.second->getParametersMap()) {
349 keys.insert(kv.first);
350 }
351 }
352 return std::vector<std::string>(keys.begin(), keys.end());
353}
354
355int
356GUIViewTraffic::doPaintGL(int mode, const Boundary& bound) {
359 }
360 // init view settings
361 glRenderMode(mode);
362 glMatrixMode(GL_MODELVIEW);
364 glDisable(GL_TEXTURE_2D);
365 glDisable(GL_ALPHA_TEST);
366 glEnable(GL_BLEND);
367 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
368 glEnable(GL_DEPTH_TEST);
369
370 // draw decals (if not in grabbing mode)
371 drawDecals();
374 paintGLGrid();
375 }
376
377
378 glLineWidth(1);
379 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
380 const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
381 const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
382 glEnable(GL_POLYGON_OFFSET_FILL);
383 glEnable(GL_POLYGON_OFFSET_LINE);
385 int hits2 = grid.Search(minB, maxB, *myVisualizationSettings);
387 // Draw additional objects
388 if (myAdditionallyDrawn.size() > 0) {
389 glTranslated(0, 0, -.01);
391 for (auto i : myAdditionallyDrawn) {
392 i.first->drawGLAdditional(this, *myVisualizationSettings);
393 }
395 glTranslated(0, 0, .01);
396 }
398 /*
399 // draw legends
400 glMatrixMode(GL_MODELVIEW);
401 glLoadIdentity();
402 glTranslated(1.-.2, 1.-.5, 0.);
403 glScaled(.2, .5, 1.);
404 GUIColoringSchemesMap<GUILane> &sm = GUIViewTraffic::getLaneSchemesMap(); //!!!
405 sm.getColorer(myVisualizationSettings->laneEdgeMode)->drawLegend();
406 */
407 return hits2;
408}
409
410
411void
413 myTrackedID = id;
415 if (o != nullptr) {
416 GUIBaseVehicle* v = dynamic_cast<GUIBaseVehicle*>(o);
417 if (v != nullptr) {
419 }
420 }
421}
422
423
424void
427}
428
429
432 return myTrackedID;
433}
434
435
436void
438 if (myTLSGame) {
440 MSTrafficLightLogic* minTll = nullptr;
441 double minDist = std::numeric_limits<double>::infinity();
442 for (MSTrafficLightLogic* const tll : tlsControl.getAllLogics()) {
443 if (tlsControl.isActive(tll) && tll->getProgramID() != "off") {
444 // get the links
445 const MSTrafficLightLogic::LaneVector& lanes = tll->getLanesAt(0);
446 if (lanes.size() > 0) {
447 const Position& endPos = lanes[0]->getShape().back();
448 if (endPos.distanceTo(pos) < minDist) {
449 minDist = endPos.distanceTo(pos);
450 minTll = tll;
451 }
452 }
453 }
454 }
455 if (minTll != nullptr) {
456 if (minTll->getPhaseNumber() == 0) {
457 // MSRailSignal
458 return;
459 }
460 const int ci = minTll->getCurrentPhaseIndex();
461 const int n = minTll->getPhaseNumber();
462 int greenCount = 0;
463 for (auto& phase : minTll->getPhases()) {
464 if (phase->isGreenPhase()) {
465 greenCount++;
466 }
467 }
468 int nextPhase = (ci + 1) % n;
469 SUMOTime nextDuration = 0;
470 if (minTll->getCurrentPhaseDef().isGreenPhase() || (greenCount == 1 && minTll->getCurrentPhaseDef().isAllRedPhase())) {
471 nextDuration = minTll->getPhase(nextPhase).duration;
472 } else {
473 // we are in transition to a green phase
474 // -> skip forward to the transtion into the next green phase
475 // but ensure that the total transition time is maintained
476 // taking into account how much time was already spent
477 SUMOTime spentTransition = minTll->getSpentDuration();
478 // the transition may consist of more than one phase so we
479 // search backwards until the prior green phase
480 for (int i = ci - 1; i != ci; i--) {
481 if (i < 0) {
482 i = n - 1;
483 }
484 if (minTll->getPhase(i).isGreenPhase()) {
485 break;
486 }
487 spentTransition += minTll->getPhase(i).duration;
488 }
489 // now we skip past the next greenphase
490 int numGreen = 0;
491 int i = nextPhase;
492 for (; numGreen < 2; i = (i + 1) % n) {
493 if (minTll->getPhase(i).isGreenPhase()) {
494 numGreen++;
495 continue;
496 }
497 // transition after the next green
498 if (numGreen == 1) {
499 SUMOTime dur = minTll->getPhase(i).duration;
500 if (dur <= spentTransition) {
501 spentTransition -= dur;
502 } else {
503 nextPhase = i;
504 nextDuration = dur - spentTransition;
505 break;
506 }
507 }
508 }
509 }
510 minTll->changeStepAndDuration(tlsControl, MSNet::getInstance()->getCurrentTimeStep(), nextPhase, nextDuration);
511 update();
512 }
513 } else {
514 // DRT game
516 return;
517 }
518 const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
519 if (sel.size() == 0) {
520 // find closest pt vehicle
521 double minDist = std::numeric_limits<double>::infinity();
522 GUIVehicle* closest = nullptr;
526 for (it = vc.loadedVehBegin(); it != end; ++it) {
527 GUIVehicle* veh = dynamic_cast<GUIVehicle*>(it->second);
528 assert(veh != 0);
529 if (veh->getParameter().line != "") {
530 const double dist = veh->getPosition().distanceTo2D(pos);
531 if (dist < minDist) {
532 minDist = dist;
533 closest = veh;
534 }
535 }
536 }
537 if (closest != nullptr) {
538 gSelected.select(closest->getGlID());
540 }
541 } else {
542 // find closest pt stop
543 double minDist = std::numeric_limits<double>::infinity();
544 MSStoppingPlace* closestStop = nullptr;
546 for (auto it = stops.begin(); it != stops.end(); ++it) {
547 MSStoppingPlace* stop = it->second;
548 const double dist = pos.distanceTo2D(stop->getLane().geometryPositionAtOffset(stop->getEndLanePosition()));
549 if (dist < minDist) {
550 minDist = dist;
551 closestStop = stop;
552 }
553 }
554 if (closestStop != 0) {
555 GUIGlID id = *sel.begin();
557 assert(veh != 0);
558 MSLane* lane = veh->getMutableLane();
559 lane->getVehiclesSecure();
560 veh->rerouteDRTStop(closestStop);
562 lane->releaseVehicles();
563 }
564 }
565 }
566}
567
568
569void
571 const std::set<GUIGlID>& sel = gSelected.getSelected(GLO_VEHICLE);
572 if (sel.size() > 0) {
573 GUIGlID id = *sel.begin();
575 if (veh != 0) {
577 }
579 }
581}
582
583
587}
588
589
590long
591GUIViewTraffic::onCmdCloseLane(FXObject*, FXSelector, void*) {
592 GUILane* lane = getLaneUnderCursor();
593 if (lane != nullptr) {
594 lane->closeTraffic();
596 update();
597 }
598 return 1;
599}
600
601
602long
603GUIViewTraffic::onCmdCloseEdge(FXObject*, FXSelector, void*) {
604 GUILane* lane = getLaneUnderCursor();
605 if (lane != nullptr) {
606 dynamic_cast<GUIEdge*>(&lane->getEdge())->closeTraffic(lane);
608 update();
609 }
610 return 1;
611}
612
613
614long
615GUIViewTraffic::onCmdAddRerouter(FXObject*, FXSelector, void*) {
616 GUILane* lane = getLaneUnderCursor();
617 if (lane != nullptr) {
618 dynamic_cast<GUIEdge*>(&lane->getEdge())->addRerouter();
620 update();
621 }
622 return 1;
623}
624
625
626long
627GUIViewTraffic::showLaneReachability(GUILane* lane, FXObject* menu, FXSelector) {
628 if (lane != nullptr) {
629 // reset
630 const double UNREACHED = INVALID_DOUBLE;
632 for (const MSEdge* const e : MSEdge::getAllEdges()) {
633 for (MSLane* const l : e->getLanes()) {
634 GUILane* gLane = dynamic_cast<GUILane*>(l);
635 gLane->setReachability(UNREACHED);
636 }
637 }
638 // prepare
639 FXMenuCommand* mc = dynamic_cast<FXMenuCommand*>(menu);
640 const SUMOVehicleClass svc = SumoVehicleClassStrings.get(mc->getText().text());
641 const double defaultMaxSpeed = SUMOVTypeParameter::VClassDefaultValues(svc).maxSpeed;
642 // find reachable
643 std::map<MSEdge*, double> reachableEdges;
644 reachableEdges[&lane->getEdge()] = 0;
645 MSEdgeVector check;
646 check.push_back(&lane->getEdge());
647 while (check.size() > 0) {
648 MSEdge* e = check.front();
649 check.erase(check.begin());
650 double traveltime = reachableEdges[e];
651 for (MSLane* const l : e->getLanes()) {
652 if (l->allowsVehicleClass(svc)) {
653 GUILane* gLane = dynamic_cast<GUILane*>(l);
654 gSelected.select(gLane->getGlID(), false);
655 gLane->setReachability(traveltime);
656 }
657 }
658 const double dt = e->getLength() / MIN2(e->getSpeedLimit(), defaultMaxSpeed);
659 // ensure algorithm termination
660 traveltime += MAX2(dt, NUMERICAL_EPS);
661 for (MSEdge* const nextEdge : e->getSuccessors(svc)) {
662 if (reachableEdges.count(nextEdge) == 0 ||
663 // revisit edge via faster path
664 reachableEdges[nextEdge] > traveltime) {
665 reachableEdges[nextEdge] = traveltime;
666 check.push_back(nextEdge);
667 }
668 }
669 if (svc == SVC_PEDESTRIAN) {
670 // can also walk backwards
671 for (MSEdge* const prevEdge : e->getPredecessors()) {
672 if (prevEdge->allowedLanes(*e, svc) != nullptr &&
673 (reachableEdges.count(prevEdge) == 0 ||
674 // revisit edge via faster path
675 reachableEdges[prevEdge] > traveltime)) {
676 reachableEdges[prevEdge] = traveltime;
677 check.push_back(prevEdge);
678 }
679 }
680 }
681 }
683 }
684 return 1;
685}
686
687
688long
689GUIViewTraffic::onCmdShowReachability(FXObject* menu, FXSelector selector, void*) {
690 GUILane* lane = getLaneUnderCursor();
691 if (lane != nullptr) {
692 // reset
693 showLaneReachability(lane, menu, selector);
694 // switch to 'color by selection' unless coloring 'by reachability'
697 }
698 update();
699 }
700 return 1;
701}
702
703
704GUILane*
706 if (makeCurrent()) {
707 int id = getObjectUnderCursor();
708 if (id != 0) {
710 if (o != nullptr) {
711 return dynamic_cast<GUILane*>(o);
712 }
713 }
714 makeNonCurrent();
715 }
716 return nullptr;
717}
718
719
720long
721GUIViewTraffic::onDoubleClicked(FXObject*, FXSelector, void*) {
722 // leave fullscreen mode
723 if (myApp->isFullScreen()) {
724 myApp->onCmdFullScreen(nullptr, 0, nullptr);
725 } else {
726 stopTrack();
727 }
728 return 1;
729}
730
731
732
733void
734GUIViewTraffic::saveFrame(const std::string& destFile, FXColor* buf) {
735#ifdef HAVE_FFMPEG
736 if (myCurrentVideo == nullptr) {
737 myCurrentVideo = new GUIVideoEncoder(destFile.c_str(), getWidth(), getHeight(), myApp->getDelay());
738 }
739 myCurrentVideo->writeFrame((uint8_t*)buf);
740#else
741 UNUSED_PARAMETER(destFile);
742 UNUSED_PARAMETER(buf);
743#endif
744}
745
746
747void
749#ifdef HAVE_FFMPEG
750 if (myCurrentVideo != nullptr) {
751 delete myCurrentVideo;
752 myCurrentVideo = nullptr;
753 }
754#endif
755}
756
757
758void
760#ifdef HAVE_FFMPEG
761 if (myCurrentVideo != nullptr) {
763 }
764#endif
766}
767
768
769const std::vector<SUMOTime>
771 return myApp->retrieveBreakpoints();
772}
773
774
775/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
@ MID_HOTKEY_SHIFT_O_LOCATEPOI
Locate poi - button.
Definition: GUIAppEnum.h:179
@ MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL
Locate additional structure - button.
Definition: GUIAppEnum.h:169
@ MID_HOTKEY_SHIFT_C_LOCATECONTAINER
Locate container - button.
Definition: GUIAppEnum.h:171
@ MID_HOTKEY_SHIFT_V_LOCATEVEHICLE
Locate vehicle - button.
Definition: GUIAppEnum.h:189
@ MID_HOTKEY_SHIFT_L_LOCATEPOLY
Locate polygons - button.
Definition: GUIAppEnum.h:177
@ MID_HOTKEY_SHIFT_E_LOCATEEDGE
Locate edge - button.
Definition: GUIAppEnum.h:173
@ MID_HOTKEY_SHIFT_P_LOCATEPERSON
Locate person - button.
Definition: GUIAppEnum.h:181
@ MID_HOTKEY_SHIFT_J_LOCATEJUNCTION
Locate junction - button.
Definition: GUIAppEnum.h:175
@ MID_HOTKEY_SHIFT_T_LOCATETLS
Locate TLS - button.
Definition: GUIAppEnum.h:187
GUICompleteSchemeStorage gSchemeStorage
#define GUIDesignButtonPopup
checkable button placed in popup (for example, locate buttons)
Definition: GUIDesigns.h:107
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 TL(string)
Definition: MsgHandler.h:287
#define INVALID_ID
SUMOTime DELTA_T
Definition: SUMOTime.cpp:38
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
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 INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
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:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
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
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:539
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 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:245
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
gets the color value according to the current scheme index
Definition: GUILane.cpp:1242
void closeTraffic(bool rebuildAllowed=true)
close this lane for traffic
Definition: GUILane.cpp:1526
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:581
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:593
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:727
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:285
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
Definition: GUINet.cpp:737
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:587
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:571
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
Definition: GUINet.cpp:748
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.
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
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::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)
bool secondaryShape
whether secondary lane shape shall be drawn
GUIColorer laneColorer
The lane colorer.
bool forceDrawForPositionSelection
flag to force draw for position selection (see drawForPositionSelection)
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 & getPredecessors() const
Definition: MSEdge.h:406
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1156
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:474
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:504
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:745
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:551
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:453
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:322
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:503
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:380
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:1386
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.
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:592
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:254
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:244
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
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: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)