SUMO - Simulation of Urban MObility
GNEClosingReroute.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 "GNEClosingReroute.h"
27 
28 #include <netedit/GNEUndoList.h>
29 #include <netedit/GNEViewNet.h>
30 #include <netedit/GNENet.h>
31 
32 
33 // ===========================================================================
34 // member method definitions
35 // ===========================================================================
36 
38  GNEAdditional(rerouterIntervalDialog->getEditedAdditional(), rerouterIntervalDialog->getEditedAdditional()->getViewNet(), GLO_CALIBRATOR, SUMO_TAG_CLOSING_REROUTE, "", false),
39  myClosedEdge(rerouterIntervalDialog->getEditedAdditional()->getFirstAdditionalParent()->getEdgeChilds().at(0)) {
40  // fill closing reroute interval with default values
42 }
43 
44 
45 GNEClosingReroute::GNEClosingReroute(GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) :
46  GNEAdditional(rerouterIntervalParent, rerouterIntervalParent->getViewNet(), GLO_CALIBRATOR, SUMO_TAG_CLOSING_REROUTE, "", false),
47  myClosedEdge(closedEdge),
48  myPermissions(permissions) {
49 }
50 
51 
53 
54 
55 void
57  // This additional cannot be moved
58 }
59 
60 
61 void
63  // This additional cannot be moved
64 }
65 
66 
67 void
68 GNEClosingReroute::updateGeometry(bool /*updateGrid*/) {
69  // Currently this additional doesn't own a Geometry
70 }
71 
72 
76 }
77 
78 
79 std::string
82 }
83 
84 
85 void
87  // Currently this additional isn't drawn
88 }
89 
90 
91 std::string
93  switch (key) {
94  case SUMO_ATTR_ID:
95  return getAdditionalID();
96  case SUMO_ATTR_EDGE:
97  return myClosedEdge->getID();
98  case SUMO_ATTR_ALLOW:
100  case SUMO_ATTR_DISALLOW:
102  case GNE_ATTR_PARENT:
103  return myFirstAdditionalParent->getID();
104  case GNE_ATTR_GENERIC:
105  return getGenericParametersStr();
106  default:
107  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
108  }
109 }
110 
111 
112 void
113 GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
114  if (value == getAttribute(key)) {
115  return; //avoid needless changes, later logic relies on the fact that attributes have changed
116  }
117  switch (key) {
118  case SUMO_ATTR_ID:
119  case SUMO_ATTR_EDGE:
120  case SUMO_ATTR_ALLOW:
121  case SUMO_ATTR_DISALLOW:
122  case GNE_ATTR_GENERIC:
123  undoList->p_add(new GNEChange_Attribute(this, key, value));
124  break;
125  default:
126  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
127  }
128 }
129 
130 
131 bool
132 GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
133  switch (key) {
134  case SUMO_ATTR_ID:
135  return isValidAdditionalID(value);
136  case SUMO_ATTR_EDGE:
137  return (myViewNet->getNet()->retrieveEdge(value, false) != nullptr);
138  case SUMO_ATTR_ALLOW:
139  return canParseVehicleClasses(value);
140  case SUMO_ATTR_DISALLOW:
141  return canParseVehicleClasses(value);
142  case GNE_ATTR_GENERIC:
143  return isGenericParametersValid(value);
144  default:
145  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
146  }
147 }
148 
149 
150 std::string
152  return getTagStr();
153 }
154 
155 
156 std::string
158  return getTagStr() + ": " + myClosedEdge->getID();
159 }
160 
161 // ===========================================================================
162 // private
163 // ===========================================================================
164 
165 void
166 GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
167  switch (key) {
168  case SUMO_ATTR_ID:
169  changeAdditionalID(value);
170  break;
171  case SUMO_ATTR_EDGE:
173  break;
174  case SUMO_ATTR_ALLOW:
176  break;
177  case SUMO_ATTR_DISALLOW:
179  break;
180  case GNE_ATTR_GENERIC:
182  break;
183  default:
184  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
185  }
186 }
187 
188 /****************************************************************************/
std::string getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a &#39; &#39;.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:900
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
Stores the information about how to visualize structures.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
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
GNEClosingReroute(GNERerouterIntervalDialog *rerouterIntervalDialog)
constructor (Used in GNERerouterIntervalDialog)
std::string getParentName() const
Returns the name of the parent object.
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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
~GNEClosingReroute()
destructor
friend class GNEChange_Attribute
declare friend class
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
std::string getAttribute(SumoXMLAttr key) const
const std::string getID() const
function to support debugging
Position getPositionInView() const
Returns position of additional in view.
GNEEdge * myClosedEdge
closed edge
a Calibrator
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
reroute of type closing
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
const std::string & getTagStr() const
get tag assigned to this object in string format
SVCPermissions myPermissions
std::string getGenericParametersStr() const
return generic parameters in string format
GNENet * getNet() const
get the net object
void updateGeometry(bool updateGrid)
update pre-computed geometry information
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
parent of an additional element
GNEAdditional * myFirstAdditionalParent
pointer to first Additional parent
virtual Position getPositionInView() const =0
Returns position of additional in view.