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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <utils/common/ToString.h>
24 #include "GNEClosingLaneReroute.h"
29 
30 #include <netedit/GNEUndoList.h>
31 #include "GNERerouter.h"
32 #include <netedit/GNEViewNet.h>
33 #include <netedit/GNENet.h>
34 #include "GNERerouterInterval.h"
35 
36 
37 // ===========================================================================
38 // member method definitions
39 // ===========================================================================
40 
42  GNEAdditional(rerouterIntervalDialog->getEditedAdditional(), rerouterIntervalDialog->getEditedAdditional()->getViewNet(), GLO_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false),
43  myClosedLane(rerouterIntervalDialog->getEditedAdditional()->getFirstAdditionalParent()->getEdgeChilds().at(0)->getLanes().at(0)) {
44  // fill closing lane reroute interval with default values
46 }
47 
48 
49 GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
50  GNEAdditional(rerouterIntervalParent, rerouterIntervalParent->getViewNet(), GLO_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false),
51  myClosedLane(closedLane),
52  myPermissions(permissions) {
53 }
54 
55 
57 
58 
59 void
61  // This additional cannot be moved
62 }
63 
64 
65 void
67  // This additional cannot be moved
68 }
69 
70 
71 void
73  // Currently this additional doesn't own a Geometry
74 }
75 
76 
80 }
81 
82 
83 std::string
86 }
87 
88 
89 void
91  // Currently this additional isn't drawn
92 }
93 
94 
95 std::string
97  switch (key) {
98  case SUMO_ATTR_ID:
99  return getAdditionalID();
100  case SUMO_ATTR_LANE:
101  return myClosedLane->getID();
102  case SUMO_ATTR_ALLOW:
104  case SUMO_ATTR_DISALLOW:
106  case GNE_ATTR_PARENT:
107  return myFirstAdditionalParent->getID();
108  case GNE_ATTR_GENERIC:
109  return getGenericParametersStr();
110  default:
111  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
112  }
113 }
114 
115 
116 void
117 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
118  if (value == getAttribute(key)) {
119  return; //avoid needless changes, later logic relies on the fact that attributes have changed
120  }
121  switch (key) {
122  case SUMO_ATTR_ID:
123  case SUMO_ATTR_LANE:
124  case SUMO_ATTR_ALLOW:
125  case SUMO_ATTR_DISALLOW:
126  case GNE_ATTR_GENERIC:
127  undoList->p_add(new GNEChange_Attribute(this, key, value));
128  break;
129  default:
130  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
131  }
132 }
133 
134 
135 bool
136 GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
137  switch (key) {
138  case SUMO_ATTR_ID:
139  return isValidAdditionalID(value);
140  case SUMO_ATTR_LANE:
141  return (myViewNet->getNet()->retrieveLane(value, false) != nullptr);
142  case SUMO_ATTR_ALLOW:
143  case SUMO_ATTR_DISALLOW:
144  return canParseVehicleClasses(value);
145  case GNE_ATTR_GENERIC:
146  return isGenericParametersValid(value);
147  default:
148  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
149  }
150 }
151 
152 
153 std::string
155  return toString(getTag());
156 }
157 
158 
159 std::string
161  return toString(getTag()) + ": " + myClosedLane->getID();
162 }
163 
164 // ===========================================================================
165 // private
166 // ===========================================================================
167 
168 void
169 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
170  switch (key) {
171  case SUMO_ATTR_ID:
172  changeAdditionalID(value);
173  break;
174  case SUMO_ATTR_LANE:
176  break;
177  case SUMO_ATTR_ALLOW:
179  break;
180  case SUMO_ATTR_DISALLOW:
182  break;
183  case GNE_ATTR_GENERIC:
185  break;
186  default:
187  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
188  }
189 }
190 
191 /****************************************************************************/
std::string getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a &#39; &#39;.
Dialog for edit rerouter intervals.
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
returns Additional ID
lane of a reroute of type closing
Stores the information about how to visualize structures.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo) ...
void changeAdditionalID(const std::string &newID)
change ID of additional
generic attribute
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
std::string getAttribute(SumoXMLAttr key) const
void updateGeometry(bool updateGrid)
update pre-computed geometry information
friend class GNEChange_Attribute
declare friend class
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
a Rerouter
const std::string getID() const
function to support debugging
GNELane * myClosedLane
closed lane
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Position getPositionInView() const
Returns position of additional in view.
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:53
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
void moveGeometry(const Position &oldPos, const Position &offset)
change the position of the element geometry without saving in undoList
std::string getGenericParametersStr() const
return generic parameters in string format
GNENet * getNet() const
get the net object
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
parent of an additional element
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1074
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
std::string getParentName() const
Returns the name of the parent object.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GNEClosingLaneReroute(GNERerouterIntervalDialog *rerouterIntervalDialog)
constructor (Used in GNERerouterIntervalDialog)
GNEAdditional * myFirstAdditionalParent
pointer to first Addititional parent
SumoXMLTag getTag() const
get XML Tag assigned to this object
virtual Position getPositionInView() const =0
Returns position of additional in view.