Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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#include <netedit/GNEUndoList.h>
25
27
28// ===========================================================================
29// member method definitions
30// ===========================================================================
31
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, ""),
41 myClosedLane(closedLane),
42 myPermissions(permissions) {
43 // set parents
44 setParent<GNEAdditional*>(rerouterIntervalParent);
45 // update boundary of rerouter parent
46 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
47}
48
49
51
52
53void
66
67
68bool
70 return true;
71}
72
73
74std::string
78
79
80void
84
85
86bool
88 return false;
89}
90
91
94 // GNEClosingLaneReroute cannot be moved
95 return nullptr;
96}
97
98
99void
101 // update centering boundary (needed for centering)
103}
104
105
108 // get rerouter parent position
109 Position signPosition = getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView();
110 // set position depending of indexes
111 signPosition.add(4.5 + 6.25, (getDrawPositionIndex() * -1) - getParentAdditionals().front()->getDrawPositionIndex() + 1, 0);
112 // return signPosition
113 return signPosition;
114}
115
116
117void
119 // nothing to update
120}
121
122
123void
124GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
125 // geometry of this element cannot be splitted
126}
127
128
129std::string
131 return getParentAdditionals().at(0)->getID();
132}
133
134
135void
143
144
145std::string
147 switch (key) {
148 case SUMO_ATTR_ID:
149 return getMicrosimID();
150 case SUMO_ATTR_LANE:
151 return myClosedLane->getID();
152 case SUMO_ATTR_ALLOW:
156 case GNE_ATTR_PARENT:
157 return getParentAdditionals().at(0)->getID();
159 return "";
160 default:
161 return getCommonAttribute(this, key);
162 }
163}
164
165
166double
168 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
169}
170
171
176
177
178void
179GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
180 switch (key) {
181 case SUMO_ATTR_ID:
182 case SUMO_ATTR_LANE:
183 case SUMO_ATTR_ALLOW:
186 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
187 break;
188 default:
189 setCommonAttribute(key, value, undoList);
190 break;
191 }
192}
193
194
195bool
196GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
197 switch (key) {
198 case SUMO_ATTR_ID:
199 return isValidAdditionalID(value);
200 case SUMO_ATTR_LANE:
201 return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);
202 case SUMO_ATTR_ALLOW:
204 return canParseVehicleClasses(value);
205 default:
206 return isCommonValid(key, value);
207 }
208}
209
210
211std::string
213 return getTagStr();
214}
215
216
217std::string
221
222// ===========================================================================
223// private
224// ===========================================================================
225
226void
227GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
228 switch (key) {
229 case SUMO_ATTR_ID:
230 // update microsimID
231 setAdditionalID(value);
232 break;
233 case SUMO_ATTR_LANE:
235 break;
236 case SUMO_ATTR_ALLOW:
238 break;
241 break;
244 break;
245 default:
246 setCommonAttribute(this, key, value);
247 break;
248 }
249}
250
251
252void
254 // nothing to do
255}
256
257
258void
260 // nothing to do
261}
262
263/****************************************************************************/
@ 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)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void drawListedAdditional(const GUIVisualizationSettings &s, const Position &parentPosition, const double offsetX, const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
void setAdditionalID(const std::string &newID)
set additional ID
void shiftLaneIndex()
shift lane index
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const std::string getID() const
get ID (all Attribute Carriers have one)
std::string getCommonAttribute(const Parameterised *parameterised, 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
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) const
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
bool checkDrawMoveContour() const
check if draw move contour (red)
const Parameterised::Map & getACParametersMap() const
get parameters map
Position getPositionInView() const
Returns position of additional in view.
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
double getAttributeDouble(SumoXMLAttr key) const
std::string getParentName() const
Returns the name of the parent object.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
void updateGeometry()
update pre-computed geometry information
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
GNELane * myClosedLane
closed lane
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
GNEClosingLaneReroute(GNENet *net)
parameter constructor
std::string getAttribute(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
GNEMoveOperation * getMoveOperation()
get move operation
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
move operation
move result
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:146
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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:129
static const RGBColor YELLOW
Definition RGBColor.h:191
static const RGBColor RED
named colors
Definition RGBColor.h:188