Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUILaneSpeedTrigger.h
169667 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 GUILaneSpeedTrigger.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Mon, 26.04.2004
19
///
20
// Changes the speed allowed on a set of lanes (gui version)
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <vector>
26
#include <string>
27
#include <microsim/trigger/MSLaneSpeedTrigger.h>
28
#include <utils/foxtools/MFXComboBoxIcon.h>
29
#include <utils/gui/globjects/GUIGlObject_AbstractAdd.h>
30
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
31
#include <gui/GUIManipulator.h>
32
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
/**
38
* @class GUILaneSpeedTrigger
39
* @brief Changes the speed allowed on a set of lanes (gui version)
40
*
41
* This is the gui-version of the MSLaneSpeedTrigger-object
42
*/
43
class GUILaneSpeedTrigger
44
: public MSLaneSpeedTrigger,
45
public GUIGlObject_AbstractAdd {
46
public:
47
/** @brief Constructor
48
* @param[in] idStorage The gl-id storage for giving this object an gl-id
49
* @param[in] id The id of the lane speed trigger
50
* @param[in] destLanes List of lanes affected by this speed trigger
51
* @param[in] file Name of the file to read the speeds to set from
52
*/
53
GUILaneSpeedTrigger(const std::string& id,
54
const std::vector<MSLane*>& destLanes,
55
const std::string& file);
56
57
/** destructor */
58
~GUILaneSpeedTrigger();
59
60
/// @name inherited from GUIGlObject
61
//@{
62
63
/** @brief Returns an own popup-menu
64
*
65
* @param[in] app The application needed to build the popup-menu
66
* @param[in] parent The parent window needed to build the popup-menu
67
* @return The built popup-menu
68
* @see GUIGlObject::getPopUpMenu
69
*/
70
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent);
71
72
/** @brief Returns an own parameter window
73
*
74
* @param[in] app The application needed to build the parameter window
75
* @param[in] parent The parent window needed to build the parameter window
76
* @return The built parameter window
77
* @see GUIGlObject::getParameterWindow
78
*/
79
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent);
80
81
/// @brief return exaggeration associated with this GLObject
82
double getExaggeration(const GUIVisualizationSettings& s) const;
83
84
/** @brief Returns the boundary to which the view shall be centered in order to show the object
85
*
86
* @return The boundary the object is within
87
* @see GUIGlObject::getCenteringBoundary
88
*/
89
Boundary getCenteringBoundary() const;
90
91
/** @brief Draws the object
92
* @param[in] s The settings for the current view (may influence drawing)
93
* @see GUIGlObject::drawGL
94
*/
95
void drawGL(const GUIVisualizationSettings& s) const;
96
//@}
97
98
GUIManipulator* openManipulator(GUIMainWindow& app, GUISUMOAbstractView& parent);
99
100
public:
101
class GUILaneSpeedTriggerPopupMenu : public GUIGLObjectPopupMenu {
102
FXDECLARE(GUILaneSpeedTriggerPopupMenu)
103
public:
104
105
GUILaneSpeedTriggerPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);
106
107
~GUILaneSpeedTriggerPopupMenu();
108
109
/** @brief Called if the object's manipulator shall be shown */
110
long onCmdOpenManip(FXObject*, FXSelector, void*);
111
112
protected:
113
GUILaneSpeedTriggerPopupMenu() { }
114
115
};
116
117
class GUIManip_LaneSpeedTrigger : public GUIManipulator {
118
FXDECLARE(GUIManip_LaneSpeedTrigger)
119
public:
120
enum {
121
MID_USER_DEF = FXDialogBox::ID_LAST,
122
MID_PRE_DEF,
123
MID_OPTION,
124
MID_CLOSE,
125
ID_LAST
126
};
127
/// Constructor
128
GUIManip_LaneSpeedTrigger(GUIMainWindow& app,
129
const std::string& name, GUILaneSpeedTrigger& o,
130
int xpos, int ypos);
131
132
/// Destructor
133
virtual ~GUIManip_LaneSpeedTrigger();
134
135
long onCmdClose(FXObject*, FXSelector, void*);
136
long onCmdUserDef(FXObject*, FXSelector, void*);
137
long onUpdUserDef(FXObject*, FXSelector, void*);
138
long onCmdPreDef(FXObject*, FXSelector, void*);
139
long onUpdPreDef(FXObject*, FXSelector, void*);
140
long onCmdChangeOption(FXObject*, FXSelector, void*);
141
142
private:
143
GUIMainWindow* myParent;
144
145
FXint myChosenValue;
146
147
FXDataTarget myChosenTarget;
148
149
double mySpeed;
150
151
FXDataTarget mySpeedTarget;
152
153
FXRealSpinner* myUserDefinedSpeed;
154
155
MFXComboBoxIcon* myPredefinedValues;
156
157
GUILaneSpeedTrigger* myObject;
158
159
protected:
160
FOX_CONSTRUCTOR(GUIManip_LaneSpeedTrigger)
161
};
162
163
private:
164
/// Definition of a positions container
165
typedef std::vector<Position> PosCont;
166
167
/// Definition of a rotation container
168
typedef std::vector<double> RotCont;
169
170
private:
171
/// The positions in full-geometry mode
172
PosCont myFGPositions;
173
174
/// The rotations in full-geometry mode
175
RotCont myFGRotations;
176
177
/// The boundary of this rerouter
178
Boundary myBoundary;
179
180
/// The information whether the speed shall be shown in m/s or km/h
181
bool myShowAsKMH;
182
183
/// Storage for last value to avoid string recomputation
184
mutable double myLastValue;
185
186
/// Storage for speed string to avoid recomputation
187
mutable std::string myLastValueString;
188
189
};
190
191