Eclipse SUMO - Simulation of Urban MObility
GNEClosingLaneReroute.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 
22 #include "GNEClosingLaneReroute.h"
24 
25 #include <netedit/GNEUndoList.h>
26 #include <netedit/GNENet.h>
27 
28 
29 // ===========================================================================
30 // member method definitions
31 // ===========================================================================
32 
35 {}, {}, {}, {}, {}, {}, {}, {},
36 std::map<std::string, std::string>()),
37  myClosedLane(nullptr),
38 myPermissions(0) {
39  // reset default values
40  resetDefaultValues();
41 }
42 
43 
44 GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
46 {}, {}, {}, {rerouterIntervalParent}, {}, {}, {}, {},
47 std::map<std::string, std::string>()),
48 myClosedLane(closedLane),
49 myPermissions(permissions) {
50  // update boundary of rerouter parent
51  rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
52 }
53 
54 
56 
57 
58 void
62  if (getAttribute(SUMO_ATTR_ALLOW) != "authority") {
63  if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {
65  } else {
67  }
68  }
69  device.closeTag();
70 }
71 
72 
75  // GNEClosingLaneReroute cannot be moved
76  return nullptr;
77 }
78 
79 
80 void
82  // update centering boundary (needed for centering)
84 }
85 
86 
89  // get rerouter parent position
90  Position signPosition = getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView();
91  // set position depending of indexes
92  signPosition.add(4.5 + 6.25, (getDrawPositionIndex() * -1) - getParentAdditionals().front()->getDrawPositionIndex() + 1, 0);
93  // return signPosition
94  return signPosition;
95 }
96 
97 
98 void
103 }
104 
105 
106 void
107 GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
108  // geometry of this element cannot be splitted
109 }
110 
111 
112 std::string
114  return getParentAdditionals().at(0)->getID();
115 }
116 
117 
118 void
120  // draw closing lane reroute as listed attribute
125 }
126 
127 
128 std::string
130  switch (key) {
131  case SUMO_ATTR_ID:
132  return getID();
133  case SUMO_ATTR_LANE:
134  return myClosedLane->getID();
135  case SUMO_ATTR_ALLOW:
137  case SUMO_ATTR_DISALLOW:
139  case GNE_ATTR_PARENT:
140  return getParentAdditionals().at(0)->getID();
141  case GNE_ATTR_SELECTED:
144  return "";
145  default:
146  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
147  }
148 }
149 
150 
151 double
153  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
154 }
155 
156 
157 void
158 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
159  switch (key) {
160  case SUMO_ATTR_ID:
161  case SUMO_ATTR_LANE:
162  case SUMO_ATTR_ALLOW:
163  case SUMO_ATTR_DISALLOW:
164  case GNE_ATTR_SELECTED:
166  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
167  break;
168  default:
169  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
170  }
171 }
172 
173 
174 bool
175 GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
176  switch (key) {
177  case SUMO_ATTR_ID:
178  return isValidAdditionalID(value);
179  case SUMO_ATTR_LANE:
180  return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);
181  case SUMO_ATTR_ALLOW:
182  case SUMO_ATTR_DISALLOW:
183  return canParseVehicleClasses(value);
184  case GNE_ATTR_SELECTED:
185  return canParse<double>(value);
186  default:
187  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
188  }
189 }
190 
191 
192 bool
194  return true;
195 }
196 
197 
198 std::string
200  return getTagStr();
201 }
202 
203 
204 std::string
206  return getTagStr() + ": " + myClosedLane->getID();
207 }
208 
209 // ===========================================================================
210 // private
211 // ===========================================================================
212 
213 void
214 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
215  switch (key) {
216  case SUMO_ATTR_ID:
217  // update microsimID
218  setMicrosimID(value);
219  break;
220  case SUMO_ATTR_LANE:
222  break;
223  case SUMO_ATTR_ALLOW:
225  break;
226  case SUMO_ATTR_DISALLOW:
228  break;
229  case GNE_ATTR_SELECTED:
230  if (parse<bool>(value)) {
232  } else {
234  }
235  break;
237  shiftLaneIndex();
238  break;
239  default:
240  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
241  }
242 }
243 
244 
245 void
247  // nothing to do
248 }
249 
250 
251 void
252 GNEClosingLaneReroute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
253  // nothing to do
254 }
255 
256 /****************************************************************************/
@ GLO_REROUTER_CLOSINGLANEREROUTE
a closing lane reroute
@ REROUTER_CLOSINGLANEREROUTE
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.
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
@ GNE_ATTR_SELECTED
element is selected
@ 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
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
void reset()
Resets the boundary.
Definition: Boundary.cpp:65
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
const std::string & getID() const
get ID
void shiftLaneIndex()
shift lane index
void drawListedAddtional(const GUIVisualizationSettings &s, const Position &parentPosition, const int offsetX, const int extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
Boundary myAdditionalBoundary
Additional Boundary.
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
bool isAttributeEnabled(SumoXMLAttr key) const
Position getPositionInView() const
Returns position of additional in view.
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
writte 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
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
const std::vector< 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:125
const std::string & getID() const
get ID
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:248
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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:125
static const RGBColor YELLOW
Definition: RGBColor.h:188
static const RGBColor RED
named colors
Definition: RGBColor.h:185