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