Eclipse 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-2019 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 {}, {}, {}, {rerouterIntervalDialog->getEditedAdditional()}, {}, {}, {}, {}, {}, {}),
40 myClosedEdge(rerouterIntervalDialog->getEditedAdditional()->getAdditionalParents().at(0)->getEdgeChildren().at(0)) {
41  // fill closing reroute interval with default values
43 }
44 
45 
46 GNEClosingReroute::GNEClosingReroute(GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) :
47  GNEAdditional(rerouterIntervalParent, rerouterIntervalParent->getViewNet(), GLO_CALIBRATOR, SUMO_TAG_CLOSING_REROUTE, "", false,
48 {}, {}, {}, {rerouterIntervalParent}, {}, {}, {}, {}, {}, {}),
49 myClosedEdge(closedEdge),
50 myPermissions(permissions) {
51 }
52 
53 
55 
56 
57 void
59  // This additional cannot be moved
60 }
61 
62 
63 void
65  // This additional cannot be moved
66 }
67 
68 
69 void
71  // Currently this additional doesn't own a Geometry
72 }
73 
74 
77  return getAdditionalParents().at(0)->getPositionInView();
78 }
79 
80 
84 }
85 
86 
87 std::string
89  return getAdditionalParents().at(0)->getID();
90 }
91 
92 
93 void
95  // Currently this additional isn't drawn
96 }
97 
98 
99 std::string
101  switch (key) {
102  case SUMO_ATTR_ID:
103  return getAdditionalID();
104  case SUMO_ATTR_EDGE:
105  return myClosedEdge->getID();
106  case SUMO_ATTR_ALLOW:
108  case SUMO_ATTR_DISALLOW:
110  case GNE_ATTR_PARENT:
111  return getAdditionalParents().at(0)->getID();
112  case GNE_ATTR_GENERIC:
113  return getGenericParametersStr();
114  default:
115  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
116  }
117 }
118 
119 
120 void
121 GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
122  if (value == getAttribute(key)) {
123  return; //avoid needless changes, later logic relies on the fact that attributes have changed
124  }
125  switch (key) {
126  case SUMO_ATTR_ID:
127  case SUMO_ATTR_EDGE:
128  case SUMO_ATTR_ALLOW:
129  case SUMO_ATTR_DISALLOW:
130  case GNE_ATTR_GENERIC:
131  undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), key, value));
132  break;
133  default:
134  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
135  }
136 }
137 
138 
139 bool
140 GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
141  switch (key) {
142  case SUMO_ATTR_ID:
143  return isValidAdditionalID(value);
144  case SUMO_ATTR_EDGE:
145  return (myViewNet->getNet()->retrieveEdge(value, false) != nullptr);
146  case SUMO_ATTR_ALLOW:
147  return canParseVehicleClasses(value);
148  case SUMO_ATTR_DISALLOW:
149  return canParseVehicleClasses(value);
150  case GNE_ATTR_GENERIC:
151  return isGenericParametersValid(value);
152  default:
153  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
154  }
155 }
156 
157 
158 std::string
160  return getTagStr();
161 }
162 
163 
164 std::string
166  return getTagStr() + ": " + myClosedEdge->getID();
167 }
168 
169 // ===========================================================================
170 // private
171 // ===========================================================================
172 
173 void
174 GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
175  switch (key) {
176  case SUMO_ATTR_ID:
177  changeAdditionalID(value);
178  break;
179  case SUMO_ATTR_EDGE:
181  break;
182  case SUMO_ATTR_ALLOW:
184  break;
185  case SUMO_ATTR_DISALLOW:
187  break;
188  case GNE_ATTR_GENERIC:
190  break;
191  default:
192  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
193  }
194 }
195 
196 /****************************************************************************/
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:1020
Dialog for edit rerouter intervals.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:460
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
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
void updateGeometry()
update pre-computed geometry information
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
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
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:48
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
const std::vector< GNEAdditional * > & getAdditionalParents() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
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)
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a &#39; &#39;.
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
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
Definition: GNEViewNet.cpp:927
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
parent of an additional element
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.