Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUITriggeredRerouter.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 GUITriggeredRerouter.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Mon, 25.07.2005
19
///
20
// Reroutes vehicles passing an edge (gui-version)
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <vector>
26
#include <string>
27
#include <foreign/rtree/SUMORTree.h>
28
#include <microsim/trigger/MSTriggeredRerouter.h>
29
#include <utils/gui/globjects/GUIGlObject_AbstractAdd.h>
30
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
31
#include <gui/GUIManipulator.h>
32
33
// ===========================================================================
34
// class declarations
35
// ===========================================================================
36
class GUIEdge;
37
38
// ===========================================================================
39
// class definitions
40
// ===========================================================================
41
/**
42
* @class GUITriggeredRerouter
43
* @brief Reroutes vehicles passing an edge
44
* One rerouter can be active on multiple edges. To reduce drawing load we
45
* instantiate GUIGlObjects for every edge
46
* XXX multiple rerouters active on the same edge are problematic
47
*/
48
class GUITriggeredRerouter
49
: public MSTriggeredRerouter,
50
public GUIGlObject_AbstractAdd {
51
public:
52
/** @brief Constructor
53
* @param[in] id The id of the rerouter
54
* @param[in] edges The edges the rerouter is placed at
55
* @param[in] prob The probability to reroute vehicles
56
* @param[in] off Whether the rerouter is off (not working) initially
57
*/
58
GUITriggeredRerouter(const std::string& id, const MSEdgeVector& edges, double prob,
59
bool off, bool optional, SUMOTime timeThreshold,
60
const std::string& vTypes, const Position& pos, const double radius,
61
SUMORTree& rtree);
62
63
64
/// @brief Destructor
65
~GUITriggeredRerouter();
66
67
68
/** @brief Called when a closing tag occurs
69
*
70
* @param[in] element ID of the currently opened element
71
* @exception ProcessError If something fails
72
* @see GenericSAXHandler::myEndElement
73
*/
74
void myEndElement(int element);
75
76
/// @name inherited from GUIGlObject
77
//@{
78
79
/** @brief Returns an own popup-menu
80
*
81
* @param[in] app The application needed to build the popup-menu
82
* @param[in] parent The parent window needed to build the popup-menu
83
* @return The built popup-menu
84
* @see GUIGlObject::getPopUpMenu
85
*/
86
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,
87
GUISUMOAbstractView& parent);
88
89
/** @brief Returns an own parameter window
90
*
91
* @param[in] app The application needed to build the parameter window
92
* @param[in] parent The parent window needed to build the parameter window
93
* @return The built parameter window
94
* @see GUIGlObject::getParameterWindow
95
*/
96
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,
97
GUISUMOAbstractView& parent);
98
99
/// @brief return exaggeration associated with this GLObject
100
double getExaggeration(const GUIVisualizationSettings& s) const;
101
102
/** @brief Returns the boundary to which the view shall be centered in order to show the object
103
*
104
* @return The boundary the object is within
105
* @see GUIGlObject::getCenteringBoundary
106
*/
107
Boundary getCenteringBoundary() const;
108
109
/** @brief Draws the object
110
* @param[in] s The settings for the current view (may influence drawing)
111
* @see GUIGlObject::drawGL
112
*/
113
void drawGL(const GUIVisualizationSettings& s) const;
114
//@}
115
116
GUIManipulator* openManipulator(GUIMainWindow& app,
117
GUISUMOAbstractView& parent);
118
119
/// @brief shift route probabilities
120
void shiftProbs();
121
122
public:
123
124
enum RerouterEdgeType {
125
REROUTER_TRIGGER_EDGE,
126
REROUTER_CLOSED_EDGE,
127
REROUTER_SWITCH_EDGE
128
};
129
130
class GUITriggeredRerouterEdge : public GUIGlObject {
131
132
public:
133
GUITriggeredRerouterEdge(GUIEdge* edge, GUITriggeredRerouter* parent, RerouterEdgeType edgeType, int distIndex = -1,
134
const Position& pos = Position::INVALID, const double radius = std::numeric_limits<double>::max());
135
136
virtual ~GUITriggeredRerouterEdge();
137
138
/// @name inherited from GUIGlObject
139
//@{
140
141
/** @brief Returns an own popup-menu
142
*
143
* @param[in] app The application needed to build the popup-menu
144
* @param[in] parent The parent window needed to build the popup-menu
145
* @return The built popup-menu
146
* @see GUIGlObject::getPopUpMenu
147
*/
148
GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,
149
GUISUMOAbstractView& parent);
150
151
/** @brief Returns an own parameter window
152
*
153
* @param[in] app The application needed to build the parameter window
154
* @param[in] parent The parent window needed to build the parameter window
155
* @return The built parameter window
156
* @see GUIGlObject::getParameterWindow
157
*/
158
GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,
159
GUISUMOAbstractView& parent);
160
161
/// @brief return exaggeration associated with this GLObject
162
double getExaggeration(const GUIVisualizationSettings& s) const;
163
164
/** @brief Returns the boundary to which the view shall be centered in order to show the object
165
*
166
* @return The boundary the object is within
167
* @see GUIGlObject::getCenteringBoundary
168
*/
169
Boundary getCenteringBoundary() const;
170
171
/** @brief Draws the object
172
* @param[in] s The settings for the current view (may influence drawing)
173
* @see GUIGlObject::drawGL
174
*/
175
void drawGL(const GUIVisualizationSettings& s) const;
176
177
void onLeftBtnPress(void* data);
178
179
RerouterEdgeType getRerouterEdgeType() const {
180
return myEdgeType;
181
}
182
183
const MSEdge* getEdge() const {
184
return myEdge;
185
}
186
//@}
187
188
private:
189
/// Definition of a positions container
190
typedef std::vector<Position> PosCont;
191
192
/// Definition of a rotation container
193
typedef std::vector<double> RotCont;
194
195
private:
196
/// The parent rerouter to which this edge instance belongs
197
GUITriggeredRerouter* myParent;
198
199
/// The edge for which this visualization applies
200
MSEdge* myEdge;
201
202
/// whether this edge instance visualizes a closed edge
203
const RerouterEdgeType myEdgeType;
204
205
/// The positions in full-geometry mode
206
PosCont myFGPositions;
207
208
/// The rotations in full-geometry mode
209
RotCont myFGRotations;
210
211
/// The boundary of this rerouter
212
Boundary myBoundary;
213
214
/// The sign half-widths
215
std::vector<double> myHalfWidths;
216
217
/// @brief the index for this in edge in routeProbs
218
int myDistIndex;
219
};
220
221
public:
222
class GUITriggeredRerouterPopupMenu : public GUIGLObjectPopupMenu {
223
FXDECLARE(GUITriggeredRerouterPopupMenu)
224
public:
225
226
GUITriggeredRerouterPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);
227
228
~GUITriggeredRerouterPopupMenu();
229
230
/** @brief Called if the object's manipulator shall be shown */
231
long onCmdOpenManip(FXObject*, FXSelector, void*);
232
233
protected:
234
GUITriggeredRerouterPopupMenu() { }
235
236
};
237
238
239
class GUIManip_TriggeredRerouter : public GUIManipulator {
240
FXDECLARE(GUIManip_TriggeredRerouter)
241
public:
242
enum {
243
MID_USER_DEF = FXDialogBox::ID_LAST,
244
MID_PRE_DEF,
245
MID_OPTION,
246
MID_CLOSE,
247
MID_SHIFT_PROBS,
248
ID_LAST
249
};
250
/// Constructor
251
GUIManip_TriggeredRerouter(GUIMainWindow& app, const std::string& name, GUITriggeredRerouter& o);
252
253
/// Destructor
254
virtual ~GUIManip_TriggeredRerouter();
255
256
long onCmdClose(FXObject*, FXSelector, void*);
257
long onCmdUserDef(FXObject*, FXSelector, void*);
258
long onUpdUserDef(FXObject*, FXSelector, void*);
259
long onCmdChangeOption(FXObject*, FXSelector, void*);
260
long onCmdShiftProbs(FXObject*, FXSelector, void*);
261
262
private:
263
GUIMainWindow* myParent;
264
265
FXint myChosenValue;
266
267
FXDataTarget myChosenTarget;
268
269
double myUsageProbability;
270
271
FXRealSpinner* myUsageProbabilityDial;
272
273
FXDataTarget myUsageProbabilityTarget;
274
275
GUITriggeredRerouter* myObject;
276
277
protected:
278
GUIManip_TriggeredRerouter() { }
279
280
};
281
282
283
private:
284
/// The boundary of this rerouter
285
Boundary myBoundary;
286
287
std::vector<GUITriggeredRerouterEdge*> myEdgeVisualizations;
288
289
int myShiftProbDistIndex;
290
};
291
292