Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNERerouter.h
193871 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 GNERerouter.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2015
17
///
18
//
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEAdditional.h"
24
#include "GNEAdditionalSquared.h"
25
26
// ===========================================================================
27
// class declarations
28
// ===========================================================================
29
30
class GNEEdge;
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
36
class GNERerouter : public GNEAdditional, public GNEAdditionalSquared, public Parameterised {
37
38
public:
39
/// @brief default Constructor
40
GNERerouter(GNENet* net);
41
42
/**@brief Constructor
43
* @param[in] id The storage of gl-ids to get the one for this lane representation from
44
* @param[in] net pointer to GNENet of this additional element belongs
45
* @param[in] fileBucket file in which this element is stored
46
* @param[in] pos position (center) of the rerouter in the map
47
* @param[in] name Rerouter name
48
* @param[in] probability The probability for vehicle rerouting
49
* @param[in] off Whether the router should be inactive initially
50
* @param[in] parameters generic parameters
51
*/
52
GNERerouter(const std::string& id, GNENet* net, FileBucket* fileBucket, const Position& pos, const std::string& name,
53
double probability, bool off, bool optional, SUMOTime timeThreshold, const std::vector<std::string>& vTypes,
54
const Parameterised::Map& parameters);
55
56
/// @brief Destructor
57
~GNERerouter();
58
59
/// @brief methods to retrieve the elements linked to this rerouter
60
/// @{
61
62
/// @brief get GNEMoveElement associated with this rerouter
63
GNEMoveElement* getMoveElement() const override;
64
65
/// @brief get parameters associated with this rerouter
66
Parameterised* getParameters() override;
67
68
/// @brief get parameters associated with this rerouter (constant)
69
const Parameterised* getParameters() const override;
70
71
/// @}
72
73
/// @brief open GNERerouterDialog
74
void openAdditionalDialog(FXWindow* restoringFocusWindow) override;
75
76
/// @name members and functions relative to write additionals into XML
77
/// @{
78
79
/**@brief write additional element into a xml file
80
* @param[in] device device in which write parameters of additional element
81
*/
82
void writeAdditional(OutputDevice& device) const override;
83
84
/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)
85
bool isAdditionalValid() const override;
86
87
/// @brief return a string with the current additional problem (must be reimplemented in all detector children)
88
std::string getAdditionalProblem() const override;
89
90
/// @brief fix additional problem (must be reimplemented in all detector children)
91
void fixAdditionalProblem() override;
92
93
/// @}
94
95
/// @name Function related with contour drawing
96
/// @{
97
98
/// @brief check if draw move contour (red)
99
bool checkDrawMoveContour() const override;
100
101
/// @}
102
103
/// @name Functions related with geometry of element
104
/// @{
105
106
/// @brief update pre-computed geometry information
107
void updateGeometry() override;
108
109
/// @brief Returns position of additional in view
110
Position getPositionInView() const override;
111
112
/// @brief update centering boundary (implies change in RTREE)
113
void updateCenteringBoundary(const bool updateGrid) override;
114
115
/// @brief split geometry
116
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;
117
118
/// @}
119
120
/// @name inherited from GUIGlObject
121
/// @{
122
123
/// @brief Returns the name of the parent object
124
/// @return This object's parent id
125
std::string getParentName() const override;
126
127
/**@brief Draws the object
128
* @param[in] s The settings for the current view (may influence drawing)
129
* @see GUIGlObject::drawGL
130
*/
131
void drawGL(const GUIVisualizationSettings& s) const override;
132
133
/// @}
134
135
/// @name inherited from GNEAttributeCarrier
136
/// @{
137
138
/* @brief method for getting the Attribute of an XML key
139
* @param[in] key The attribute key
140
* @return string with the value associated to key
141
*/
142
std::string getAttribute(SumoXMLAttr key) const override;
143
144
/* @brief method for getting the Attribute of an XML key in double format
145
* @param[in] key The attribute key
146
* @return double with the value associated to key
147
*/
148
double getAttributeDouble(SumoXMLAttr key) const override;
149
150
/* @brief method for getting the Attribute of an XML key in position format
151
* @param[in] key The attribute key
152
* @return position with the value associated to key
153
*/
154
Position getAttributePosition(SumoXMLAttr key) const override;
155
156
/* @brief method for getting the Attribute of an XML key in positionVector format
157
* @param[in] key The attribute key
158
* @return positionVector with the value associated to key
159
*/
160
PositionVector getAttributePositionVector(SumoXMLAttr key) const override;
161
162
/* @brief method for setting the attribute and letting the object perform additional changes
163
* @param[in] key The attribute key
164
* @param[in] value The new value
165
* @param[in] undoList The undoList on which to register changes
166
*/
167
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
168
169
/* @brief method for checking if the key and their correspond attribute are valids
170
* @param[in] key The attribute key
171
* @param[in] value The value associated to key key
172
* @return true if the value is valid, false in other case
173
*/
174
bool isValid(SumoXMLAttr key, const std::string& value) override;
175
176
/// @brief get PopPup ID (Used in AC Hierarchy)
177
std::string getPopUpID() const override;
178
179
/// @brief get Hierarchy Name (Used in AC Hierarchy)
180
std::string getHierarchyName() const override;
181
182
/// @}
183
184
protected:
185
/// @brief probability of rerouter
186
double myProbability = 0;
187
188
/// @brief attribute to enable or disable inactive initially
189
bool myOff = false;
190
191
/// @brief attribute to enable or disable request trigger
192
bool myOptional = false;
193
194
/// @brief attribute to configure activation time threshold
195
SUMOTime myTimeThreshold = 0;
196
197
/// @brief optional vehicle types for restricting the rerouter
198
std::vector<std::string> myVTypes;
199
200
private:
201
/// @brief set attribute after validation
202
void setAttribute(SumoXMLAttr key, const std::string& value) override;
203
204
/// @brief rebuild Rerouter Symbols
205
void rebuildRerouterSymbols(const std::string& value, GNEUndoList* undoList);
206
207
/// @brief Invalidated copy constructor.
208
GNERerouter(const GNERerouter&) = delete;
209
210
/// @brief Invalidated assignment operator.
211
GNERerouter& operator=(const GNERerouter&) = delete;
212
};
213
214