Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/gui/GUIViewTraffic.h
169666 views
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
/****************************************************************************/
14
/// @file GUIViewTraffic.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @author Andreas Gaubatz
19
/// @date Sept 2002
20
///
21
// A view on the simulation; this view is a microscopic one
22
/****************************************************************************/
23
#pragma once
24
#include <config.h>
25
26
#include <string>
27
#include <utils/geom/Boundary.h>
28
#include <utils/geom/Position.h>
29
#include <utils/common/RGBColor.h>
30
#include <utils/geom/PositionVector.h>
31
#include "GUISUMOViewParent.h"
32
#include <utils/gui/windows/GUISUMOAbstractView.h>
33
34
35
// ===========================================================================
36
// class declarations
37
// ===========================================================================
38
class GUINet;
39
class GUISUMOViewParent;
40
class GUIVehicle;
41
class GUIVideoEncoder;
42
class MSRoute;
43
44
45
// ===========================================================================
46
// class definitions
47
// ===========================================================================
48
/**
49
* @class GUIViewTraffic
50
* Microsocopic view at the simulation
51
*/
52
class GUIViewTraffic : public GUISUMOAbstractView {
53
public:
54
/// @brief constructor
55
GUIViewTraffic(FXComposite* p, GUIMainWindow& app,
56
GUISUMOViewParent* parent, GUINet& net, FXGLVisual* glVis,
57
FXGLCanvas* share);
58
/// @brief destructor
59
virtual ~GUIViewTraffic();
60
61
/// @brief builds the view toolbars
62
virtual void buildViewToolBars(GUIGlChildWindow*) override;
63
64
/** @brief Starts vehicle tracking
65
* @param[in] id The glID of the vehicle to track
66
*/
67
void startTrack(int id) override;
68
69
/** @brief Stops vehicle tracking
70
*/
71
void stopTrack() override;
72
73
/** @brief Returns the id of the tracked vehicle (-1 if none)
74
* @return The glID of the vehicle to track
75
*/
76
GUIGlID getTrackedID() const override;
77
78
bool setColorScheme(const std::string& name) override;
79
80
/// @brief recalibrate color scheme according to the current value range
81
void buildColorRainbow(const GUIVisualizationSettings& s, GUIColorScheme& scheme, int active, GUIGlObjectType objectType,
82
const GUIVisualizationRainbowSettings& rs) override;
83
84
/// @brief return list of loaded edgeData attributes
85
std::vector<std::string> getEdgeDataAttrs() const override;
86
87
/// @brief return list of loaded edgeData ids (being computed in the current simulation)
88
std::vector<std::string> getMeanDataIDs() const override;
89
90
/// @brief return list of available attributes for the given meanData id
91
std::vector<std::string> getMeanDataAttrs(const std::string& meanDataID) const override;
92
93
/// @brief return list of available edge parameters
94
std::vector<std::string> getEdgeLaneParamKeys(bool edgeKeys) const override;
95
96
/// @brief return list of available vehicle parameters
97
std::vector<std::string> getVehicleParamKeys(bool vTypeKeys) const override;
98
99
/// @brief return list of available POI parameters
100
std::vector<std::string> getPOIParamKeys() const override;
101
102
/// @brief handle mouse click in gaming mode
103
void onGamingClick(Position pos) override;
104
void onGamingRightClick(Position pos) override;
105
106
/// @brief get the current simulation time
107
SUMOTime getCurrentTimeStep() const override;
108
109
/// @brief interaction with the simulation
110
long onCmdCloseLane(FXObject*, FXSelector, void*) override;
111
long onCmdCloseEdge(FXObject*, FXSelector, void*) override;
112
long onCmdAddRerouter(FXObject*, FXSelector, void*) override;
113
114
/// @brief highlight edges according to reachability
115
long onCmdShowReachability(FXObject*, FXSelector, void*) override;
116
static long showLaneReachability(GUILane* lane, FXObject*, FXSelector);
117
118
long onDoubleClicked(FXObject*, FXSelector, void*) override;
119
120
/** @brief Adds a frame to a video snapshot which will be initialized if necessary
121
*/
122
void saveFrame(const std::string& destFile, FXColor* buf) override;
123
124
/** @brief Ends a video snapshot
125
*/
126
void endSnapshot() override;
127
128
/** @brief Checks whether it is time for a snapshot
129
*/
130
void checkSnapshots() override;
131
132
/// @brief retrieve breakpoints from the current runThread
133
const std::vector<SUMOTime> retrieveBreakpoints() const override;
134
135
/// @brief Draw (or not) the JuPedSim pedestrian network
136
/// @param s The visualization settings
137
void drawPedestrianNetwork(const GUIVisualizationSettings& s) const override;
138
139
/// @brief Change the color of the JuPedSim pedestrian network
140
/// @param s The visualization settings
141
void changePedestrianNetworkColor(const GUIVisualizationSettings& s) const override;
142
143
/** @brief centers to the chosen artifact
144
* @param[in] id The id of the artifact to center to
145
* @param[in] applyZoom Whether to zoom in
146
* @param[in] zoomDist The distance in m to use for the zoom, values < 0 means: use the centeringBoundary
147
* @note caller is responsible for calling update
148
*/
149
void centerTo(GUIGlID id, bool applyZoom, double zoomDist = 20) override;
150
151
protected:
152
int doPaintGL(int mode, const Boundary& bound) override;
153
154
GUILane* getLaneUnderCursor() override;
155
156
private:
157
GUIGlID myTrackedID;
158
159
/// @brief whether game mode was set to 'tls'
160
bool myTLSGame;
161
162
#ifdef HAVE_FFMPEG
163
GUIVideoEncoder* myCurrentVideo;
164
#endif
165
166
protected:
167
GUIViewTraffic() { }
168
169
};
170
171