Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEClosingReroute.cpp
Go to the documentation of this file.
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/****************************************************************************/
18//
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23
24#include "GNEClosingReroute.h"
25
26// ===========================================================================
27// member method definitions
28// ===========================================================================
29
34
35
36GNEClosingReroute::GNEClosingReroute(GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) :
37 GNEAdditional(rerouterIntervalParent, SUMO_TAG_CLOSING_REROUTE, ""),
39 myClosedEdge(closedEdge),
40 myPermissions(permissions) {
41 // set parents
42 setParent<GNEAdditional*>(rerouterIntervalParent);
43 setParent<GNEEdge*>(closedEdge);
44 // update boundary of rerouter parent
45 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
46}
47
48
50
51
54 return nullptr;
55}
56
57
60 return nullptr;
61}
62
63
64const Parameterised*
66 return nullptr;
67}
68
69
70void
73 // write common additional attributes
75 // write specific attributes
77 if (getAttribute(SUMO_ATTR_ALLOW) != "authority") {
78 if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {
80 } else {
82 }
83 }
84 device.closeTag();
85}
86
87
88bool
90 return true;
91}
92
93
94std::string
96 return "";
97}
98
99
100void
102 // nothing to fix
103}
104
105
106bool
108 return false;
109}
110
111
112void
116
117
122
123
124void
126 // nothing to update
127}
128
129
130void
131GNEClosingReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
132 // geometry of this element cannot be splitted
133}
134
135
136std::string
138 return getParentAdditionals().at(0)->getID();
139}
140
141
142void
148
149
150std::string
152 switch (key) {
153 case SUMO_ATTR_ID:
154 return getMicrosimID();
155 case SUMO_ATTR_EDGE:
156 return myClosedEdge->getID();
157 case SUMO_ATTR_ALLOW:
161 case GNE_ATTR_PARENT:
162 return getParentAdditionals().at(0)->getID();
163 default:
164 return getCommonAttribute(key);
165 }
166}
167
168
169double
173
174
179
180
185
186
187void
188GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
189 if (value == getAttribute(key)) {
190 return; //avoid needless changes, later logic relies on the fact that attributes have changed
191 }
192 switch (key) {
193 case SUMO_ATTR_ID:
194 case SUMO_ATTR_EDGE:
195 case SUMO_ATTR_ALLOW:
197 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
198 break;
199 default:
200 setCommonAttribute(key, value, undoList);
201 break;
202 }
203}
204
205
206bool
207GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
208 switch (key) {
209 case SUMO_ATTR_ID:
210 return isValidAdditionalID(value);
211 case SUMO_ATTR_EDGE:
212 return (myNet->getAttributeCarriers()->retrieveEdge(value, false) != nullptr);
213 case SUMO_ATTR_ALLOW:
214 return canParseVehicleClasses(value);
216 return canParseVehicleClasses(value);
217 default:
218 return isCommonAttributeValid(key, value);
219 }
220}
221
222
223std::string
225 return getTagStr();
226}
227
228
229std::string
231 return getTagStr() + ": " + myClosedEdge->getID();
232}
233
234// ===========================================================================
235// private
236// ===========================================================================
237
238void
239GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
240 switch (key) {
241 case SUMO_ATTR_ID:
242 // update microsimID
243 setAdditionalID(value);
244 break;
245 case SUMO_ATTR_EDGE:
247 break;
248 case SUMO_ATTR_ALLOW:
250 break;
253 break;
254 default:
255 setCommonAttribute(key, value);
256 break;
257 }
258}
259
260/****************************************************************************/
@ REROUTER_CLOSINGREROUTE
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_EDGE
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_ID
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void setAdditionalID(const std::string &newID)
set additional ID
void writeAdditionalAttributes(OutputDevice &device) const
write common additional attributes
void drawListedAdditional(const GUIVisualizationSettings &s, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
Position getListedPositionInView() const
get listed position in view
void updateGeometryListedAdditional()
update geometry of listed additional
const std::string getID() const
get ID (all Attribute Carriers have one)
double getCommonAttributeDouble(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * myNet
pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) const
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
SVCPermissions myPermissions
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
double getAttributeDouble(SumoXMLAttr key) const override
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
GNEEdge * myClosedEdge
closed edge
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this closingReroute
std::string getParentName() const
Returns the name of the parent object.
void updateGeometry() override
update pre-computed geometry information
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Position getAttributePosition(SumoXMLAttr key) const override
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
GNEClosingReroute(GNENet *net)
default constructor
std::string getAttribute(SumoXMLAttr key) const override
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Parameterised * getParameters() override
get parameters associated with this closingReroute
Position getPositionInView() const
Returns position of additional in view.
~GNEClosingReroute()
destructor
bool isValid(SumoXMLAttr key, const std::string &value) override
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:144
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
static const RGBColor YELLOW
Definition RGBColor.h:191
static const RGBColor RED
named colors
Definition RGBColor.h:188