Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/settings/GUISettingsHandler.h
193674 views
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
/****************************************************************************/
14
/// @file GUISettingsHandler.h
15
/// @author Michael Behrisch
16
/// @author Daniel Krajzewicz
17
/// @author Jakob Erdmann
18
/// @date Fri, 24. Apr 2009
19
///
20
// The handler for parsing gui settings from xml.
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <utils/xml/SUMOSAXHandler.h>
26
#include <utils/distribution/RandomDistributor.h>
27
28
29
// ===========================================================================
30
// class declarations
31
// ===========================================================================
32
class GUISUMOAbstractView;
33
class Position;
34
35
36
// ===========================================================================
37
// class definitions
38
// ===========================================================================
39
/** @class GUISettingsHandler
40
* @brief An XML-handler for visualisation schemes
41
*/
42
class GUISettingsHandler : public SUMOSAXHandler {
43
public:
44
/** @brief Constructor
45
* @param[in] file the file to parse
46
*/
47
GUISettingsHandler(const std::string& content, bool isFile = true, bool netedit = false);
48
49
50
/// @brief Destructor
51
~GUISettingsHandler();
52
53
54
55
/// @name inherited from GenericSAXHandler
56
//@{
57
58
/** @brief Called on the opening of a tag
59
* @param[in] element ID of the currently opened element
60
* @param[in] attrs Attributes within the currently opened element
61
* @exception ProcessError If something fails
62
* @see GenericSAXHandler::myStartElement
63
*/
64
void myStartElement(int element, const SUMOSAXAttributes& attrs);
65
66
/** @brief Called when a closing tag occurs
67
*
68
* @param[in] element ID of the currently opened element
69
* @exception ProcessError If something fails
70
* @see GenericSAXHandler::myEndElement
71
*/
72
void myEndElement(int element);
73
//@}
74
75
76
77
/** @brief Adds the parsed settings to the global list of settings
78
* @return the names of the parsed settings
79
*/
80
const std::vector<std::string>& addSettings(GUISUMOAbstractView* view = 0) const;
81
82
83
/** @brief Sets the viewport which has been parsed
84
* @param[in] parent the view for which the viewport has to be set
85
*/
86
void applyViewport(GUISUMOAbstractView* view) const;
87
88
89
/** @brief Makes a snapshot if it has been parsed
90
* @param[in] parent the view which needs to be shot
91
* @todo Please describe why the snapshots are only set if no other existed before (see code)
92
*/
93
void setSnapshots(GUISUMOAbstractView* view) const;
94
95
96
/** @brief Returns whether any decals have been parsed
97
* @return whether decals have been parsed
98
*/
99
bool hasDecals() const;
100
101
102
/** @brief Returns the parsed decals
103
* @return the parsed decals
104
*/
105
const std::vector<GUISUMOAbstractView::Decal>& getDecals() const;
106
107
108
/** @brief Returns the parsed delay
109
* @return the parsed delay
110
*/
111
double getDelay() const;
112
113
114
/** @brief Returns the parsed breakpoints
115
* @return the parsed breakpoints
116
*/
117
const std::vector<SUMOTime>& getBreakpoints() const {
118
return myBreakpoints;
119
}
120
121
122
/// @brief loads breakpoints from the specified file
123
static std::vector<SUMOTime> loadBreakpoints(const std::string& file);
124
125
126
/** @brief Returns the parsed view type
127
* @return the parsed view type
128
*/
129
const std::string& getViewType() const {
130
return myViewType;
131
}
132
133
RandomDistributor<std::string> getEventDistribution(const std::string& id);
134
double getJamSoundTime() {
135
return myJamSoundTime;
136
}
137
138
std::vector<std::string> getTrackers() {
139
return myTrackers;
140
}
141
142
const std::string& getSettingName() const {
143
return mySettings.name;
144
}
145
146
private:
147
/// @brief The settings to fill
148
GUIVisualizationSettings mySettings;
149
150
/// @brief names of all loaded settings
151
std::vector<std::string> myLoadedSettingNames;
152
153
/// @brief The view type (osg, opengl, default) loaded
154
std::string myViewType;
155
156
/// @brief The delay loaded
157
double myDelay;
158
159
/// @brief The viewport loaded, zoom is stored in z coordinate
160
Position myLookFrom;
161
162
/// @brief The point to look at, only needed for osg view
163
Position myLookAt;
164
165
/// @brief Whether the Z coordinate is set in 3D view
166
bool myZCoordSet;
167
168
/// @brief View rotation
169
double myRotation;
170
171
/// @brief Zoom level
172
double myZoom;
173
174
/// @brief mappig of time steps to filenames for potential snapshots
175
std::map<SUMOTime, std::vector<std::string> > mySnapshots;
176
177
/// @brief The decals list to fill
178
std::vector<GUISUMOAbstractView::Decal> myDecals;
179
180
/// @brief The last color scheme category (edges or vehicles)
181
int myCurrentColorer;
182
183
/// @brief The current color scheme
184
GUIColorScheme* myCurrentScheme;
185
186
/// @brief The current scaling scheme
187
GUIScaleScheme* myCurrentScaleScheme;
188
189
/// @brief The parsed breakpoints
190
std::vector<SUMOTime> myBreakpoints;
191
192
/// @brief The parsed event distributions
193
std::map<std::string, RandomDistributor<std::string> > myEventDistributions;
194
double myJamSoundTime;
195
196
/// @brief list of tlsIDs to open trackers for
197
std::vector<std::string> myTrackers;
198
199
private:
200
/// @brief parse color attribute
201
RGBColor parseColor(const SUMOSAXAttributes& attrs, const std::string attribute, const RGBColor& defaultValue) const;
202
203
/// @brief parse attributes for textSettings
204
GUIVisualizationTextSettings parseTextSettings(
205
const std::string& prefix, const SUMOSAXAttributes& attrs,
206
GUIVisualizationTextSettings defaults);
207
208
/// @brief parse attributes for sizeSettings
209
GUIVisualizationSizeSettings parseSizeSettings(
210
const std::string& prefix, const SUMOSAXAttributes& attrs,
211
GUIVisualizationSizeSettings defaults);
212
213
/// @brief parse attributes for rainbowSettings
214
GUIVisualizationRainbowSettings parseRainbowSettings(
215
const std::string& prefix, const SUMOSAXAttributes& attrs,
216
GUIVisualizationRainbowSettings defaults);
217
};
218
219