Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEClosingLaneReroute.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#include <config.h>
21
23#include <netedit/GNENet.h>
24
26
27// ===========================================================================
28// member method definitions
29// ===========================================================================
30
34 myClosedLane(nullptr),
35 myPermissions(0) {
36}
37
38
39GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
40 GNEAdditional(rerouterIntervalParent, SUMO_TAG_CLOSING_LANE_REROUTE, ""),
42 myClosedLane(closedLane),
43 myPermissions(permissions) {
44 // set parents
45 setParent<GNEAdditional*>(rerouterIntervalParent);
46 setParent<GNELane*>(closedLane);
47 // update boundary of rerouter parent
48 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
49}
50
51
53
54
57 return nullptr;
58}
59
60
63 return nullptr;
64}
65
66
67const Parameterised*
69 return nullptr;
70}
71
72
73void
76 // write common additional attributes
78 // write specific attributes
81 if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {
83 } else {
85 }
86 }
87 device.closeTag();
88}
89
90
91bool
93 return true;
94}
95
96
97std::string
101
102
103void
105 // nothing to fix
106}
107
108
109bool
111 return false;
112}
113
114
115void
119
120
125
126
127void
129 // nothing to update
130}
131
132
133void
134GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
135 // geometry of this element cannot be splitted
136}
137
138
139std::string
141 return getParentAdditionals().at(0)->getID();
142}
143
144
145void
151
152
153std::string
155 switch (key) {
156 case SUMO_ATTR_ID:
157 return getMicrosimID();
158 case SUMO_ATTR_LANE:
159 return myClosedLane->getID();
160 case SUMO_ATTR_ALLOW:
164 case GNE_ATTR_PARENT:
165 return getParentAdditionals().at(0)->getID();
167 return "";
168 default:
169 return getCommonAttribute(key);
170 }
171}
172
173
174double
178
179
183
184
189
190
191void
192GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
193 switch (key) {
194 case SUMO_ATTR_ID:
195 case SUMO_ATTR_LANE:
196 case SUMO_ATTR_ALLOW:
199 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
200 break;
201 default:
202 setCommonAttribute(key, value, undoList);
203 break;
204 }
205}
206
207
208bool
209GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
210 switch (key) {
211 case SUMO_ATTR_ID:
212 return isValidAdditionalID(value);
213 case SUMO_ATTR_LANE:
214 return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);
215 case SUMO_ATTR_ALLOW:
217 return canParseVehicleClasses(value);
218 default:
219 return isCommonAttributeValid(key, value);
220 }
221}
222
223
224std::string
226 return getTagStr();
227}
228
229
230std::string
234
235// ===========================================================================
236// private
237// ===========================================================================
238
239void
240GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
241 switch (key) {
242 case SUMO_ATTR_ID:
243 // update microsimID
244 setAdditionalID(value);
245 break;
246 case SUMO_ATTR_LANE:
248 break;
249 case SUMO_ATTR_ALLOW:
251 break;
254 break;
257 break;
258 default:
259 setCommonAttribute(key, value);
260 break;
261 }
262}
263
264/****************************************************************************/
@ REROUTER_CLOSINGLANEREROUTE
const SVCPermissions SVCAll
all VClasses are allowed
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_LANE_REROUTE
lane of a reroute of type closing
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_ID
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
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 shiftLaneIndex()
shift lane index
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
double getCommonAttributeDouble(SumoXMLAttr key) const
const std::string getID() const override
get ID (all Attribute Carriers have one)
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
Position getPositionInView() const override
Returns position of additional in view.
void updateGeometry() override
update pre-computed geometry information
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Position getAttributePosition(SumoXMLAttr key) const override
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
double getAttributeDouble(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
Parameterised * getParameters() override
get parameters associated with this closingLaneReroute
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
GNELane * myClosedLane
closed lane
std::string getAttribute(SumoXMLAttr key) const override
GNEClosingLaneReroute(GNENet *net)
parameter constructor
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this closingLaneReroute
bool isValid(SumoXMLAttr key, const std::string &value) override
std::string getParentName() const override
Returns the name of the parent object.
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane 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