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-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/****************************************************************************/
18//
19/****************************************************************************/
20#include <config.h>
21
23#include <netedit/GNENet.h>
24
25#include "GNEClosingReroute.h"
26
27// ===========================================================================
28// member method definitions
29// ===========================================================================
30
31#ifdef _MSC_VER
32#pragma warning(push)
33#pragma warning(disable: 4355) // mask warning about "this" in initializers
34#endif
39
40
41GNEClosingReroute::GNEClosingReroute(GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) :
42 GNEAdditional(rerouterIntervalParent, SUMO_TAG_CLOSING_REROUTE, ""),
44 myClosedEdge(closedEdge),
45 myPermissions(permissions) {
46 // set parents
47 setParent<GNEAdditional*>(rerouterIntervalParent);
48 setParent<GNEEdge*>(closedEdge);
49 // update boundary of rerouter parent
50 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
51}
52#ifdef _MSC_VER
53#pragma warning(pop)
54#endif
55
56
58
59
62 return nullptr;
63}
64
65
68 return nullptr;
69}
70
71
72const Parameterised*
74 return nullptr;
75}
76
77
78void
81 // write common additional attributes
83 // write specific attributes
86 if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {
88 } else {
90 }
91 }
92 device.closeTag();
93}
94
95
96bool
98 return true;
99}
100
101
102std::string
104 return "";
105}
106
107
108void
110 // nothing to fix
111}
112
113
114bool
116 return false;
117}
118
119
120void
124
125
130
131
132void
134 // nothing to update
135}
136
137
138void
139GNEClosingReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
140 // geometry of this element cannot be splitted
141}
142
143
144std::string
146 return getParentAdditionals().at(0)->getID();
147}
148
149
150void
156
157
158std::string
160 switch (key) {
161 case SUMO_ATTR_ID:
162 return getMicrosimID();
163 case SUMO_ATTR_EDGE:
164 return myClosedEdge->getID();
165 case SUMO_ATTR_ALLOW:
169 case GNE_ATTR_PARENT:
170 return getParentAdditionals().at(0)->getID();
171 default:
172 return getCommonAttribute(key);
173 }
174}
175
176
177double
181
182
187
188
193
194
195void
196GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
197 if (value == getAttribute(key)) {
198 return; //avoid needless changes, later logic relies on the fact that attributes have changed
199 }
200 switch (key) {
201 case SUMO_ATTR_ID:
202 case SUMO_ATTR_EDGE:
203 case SUMO_ATTR_ALLOW:
205 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
206 break;
207 default:
208 setCommonAttribute(key, value, undoList);
209 break;
210 }
211}
212
213
214bool
215GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
216 switch (key) {
217 case SUMO_ATTR_ID:
218 return isValidAdditionalID(value);
219 case SUMO_ATTR_EDGE:
220 return (myNet->getAttributeCarriers()->retrieveEdge(value, false) != nullptr);
221 case SUMO_ATTR_ALLOW:
222 return canParseVehicleClasses(value);
224 return canParseVehicleClasses(value);
225 default:
226 return isCommonAttributeValid(key, value);
227 }
228}
229
230
231std::string
233 return getTagStr();
234}
235
236
237std::string
239 return getTagStr() + ": " + myClosedEdge->getID();
240}
241
242// ===========================================================================
243// private
244// ===========================================================================
245
246void
247GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
248 switch (key) {
249 case SUMO_ATTR_ID:
250 // update microsimID
251 setAdditionalID(value);
252 break;
253 case SUMO_ATTR_EDGE:
255 break;
256 case SUMO_ATTR_ALLOW:
258 break;
261 break;
262 default:
263 setCommonAttribute(key, value);
264 break;
265 }
266}
267
268/****************************************************************************/
@ REROUTER_CLOSINGREROUTE
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_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
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
SVCPermissions myPermissions
double getAttributeDouble(SumoXMLAttr key) const override
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
GNEEdge * myClosedEdge
closed edge
Position getPositionInView() const override
Returns position of additional in view.
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this closingReroute
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
void updateGeometry() override
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const override
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
std::string getParentName() const override
Returns the name of the parent object.
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
GNEClosingReroute(GNENet *net)
default constructor
std::string getAttribute(SumoXMLAttr key) const override
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Parameterised * getParameters() override
get parameters associated with this closingReroute
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
~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
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
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 & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
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:195
static const RGBColor RED
named colors
Definition RGBColor.h:192