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  GUIIconSubSys::getIcon(GUIIcon::CLOSINGLANEREROUTE), "", {}, {}, {}, {}, {}, {}),
36  myClosedLane(nullptr),
37 myPermissions(0) {
38  // reset default values
39  resetDefaultValues();
40 }
41 
42 
43 GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
45  GUIIconSubSys::getIcon(GUIIcon::CLOSINGLANEREROUTE), "", {}, {}, {}, {rerouterIntervalParent}, {}, {}),
46 myClosedLane(closedLane),
47 myPermissions(permissions) {
48  // update boundary of rerouter parent
49  rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
50 }
51 
52 
54 
55 
56 void
60  if (getAttribute(SUMO_ATTR_ALLOW) != "authority") {
61  if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {
63  } else {
65  }
66  }
67  device.closeTag();
68 }
69 
70 
73  // GNEClosingLaneReroute cannot be moved
74  return nullptr;
75 }
76 
77 
78 void
80  // update centering boundary (needed for centering)
82 }
83 
84 
87  // get rerouter parent position
88  Position signPosition = getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView();
89  // set position depending of indexes
90  signPosition.add(4.5 + 6.25, (getDrawPositionIndex() * -1) - getParentAdditionals().front()->getDrawPositionIndex() + 1, 0);
91  // return signPosition
92  return signPosition;
93 }
94 
95 
96 void
101 }
102 
103 
104 void
105 GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
106  // geometry of this element cannot be splitted
107 }
108 
109 
110 std::string
112  return getParentAdditionals().at(0)->getID();
113 }
114 
115 
116 void
118  // draw closing lane reroute as listed attribute
123 }
124 
125 
126 std::string
128  switch (key) {
129  case SUMO_ATTR_ID:
130  return getMicrosimID();
131  case SUMO_ATTR_LANE:
132  return myClosedLane->getID();
133  case SUMO_ATTR_ALLOW:
135  case SUMO_ATTR_DISALLOW:
137  case GNE_ATTR_PARENT:
138  return getParentAdditionals().at(0)->getID();
139  case GNE_ATTR_SELECTED:
142  return "";
143  default:
144  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
145  }
146 }
147 
148 
149 double
151  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
152 }
153 
154 
155 const Parameterised::Map&
157  return PARAMETERS_EMPTY;
158 }
159 
160 
161 void
162 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
163  switch (key) {
164  case SUMO_ATTR_ID:
165  case SUMO_ATTR_LANE:
166  case SUMO_ATTR_ALLOW:
167  case SUMO_ATTR_DISALLOW:
168  case GNE_ATTR_SELECTED:
170  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
171  break;
172  default:
173  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
174  }
175 }
176 
177 
178 bool
179 GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
180  switch (key) {
181  case SUMO_ATTR_ID:
182  return isValidAdditionalID(value);
183  case SUMO_ATTR_LANE:
184  return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);
185  case SUMO_ATTR_ALLOW:
186  case SUMO_ATTR_DISALLOW:
187  return canParseVehicleClasses(value);
188  case GNE_ATTR_SELECTED:
189  return canParse<double>(value);
190  default:
191  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
192  }
193 }
194 
195 
196 std::string
198  return getTagStr();
199 }
200 
201 
202 std::string
204  return getTagStr() + ": " + myClosedLane->getID();
205 }
206 
207 // ===========================================================================
208 // private
209 // ===========================================================================
210 
211 void
212 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
213  switch (key) {
214  case SUMO_ATTR_ID:
215  // update microsimID
216  setMicrosimID(value);
217  break;
218  case SUMO_ATTR_LANE:
220  break;
221  case SUMO_ATTR_ALLOW:
223  break;
224  case SUMO_ATTR_DISALLOW:
226  break;
227  case GNE_ATTR_SELECTED:
228  if (parse<bool>(value)) {
230  } else {
232  }
233  break;
235  shiftLaneIndex();
236  break;
237  default:
238  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
239  }
240 }
241 
242 
243 void
245  // nothing to do
246 }
247 
248 
249 void
250 GNEClosingLaneReroute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
251  // nothing to do
252 }
253 
254 /****************************************************************************/
@ GLO_REROUTER_CLOSINGLANEREROUTE
a closing lane reroute
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
@ CLOSINGLANEREROUTE
@ 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:78
void reset()
Resets the boundary.
Definition: Boundary.cpp:66
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
void shiftLaneIndex()
shift lane index
void drawListedAddtional(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
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
const std::string getID() const
get ID (all Attribute Carriers have one)
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
static const Parameterised::Map PARAMETERS_EMPTY
empty parameter maps (used by ACs without parameters)
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const Parameterised::Map & getACParametersMap() const
get parameters map
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
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
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 correspondent 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:132
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.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
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:251
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
Definition: Parameterised.h:45
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