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 /****************************************************************************/
14 //
15 /****************************************************************************/
16 
17 // ===========================================================================
18 // included modules
19 // ===========================================================================
20 #include <config.h>
21 
22 #include "GNEClosingReroute.h"
26 
27 #include <netedit/GNEUndoList.h>
28 #include <netedit/GNEViewNet.h>
29 #include <netedit/GNENet.h>
30 
31 
32 // ===========================================================================
33 // member method definitions
34 // ===========================================================================
35 
37  GNEAdditional(rerouterIntervalDialog->getEditedAdditional(), rerouterIntervalDialog->getEditedAdditional()->getViewNet(), GLO_CALIBRATOR, SUMO_TAG_CLOSING_REROUTE, "", false,
38 {}, {}, {}, {rerouterIntervalDialog->getEditedAdditional()}, {}, {}, {}, {}, {}, {}),
39 myClosedEdge(rerouterIntervalDialog->getEditedAdditional()->getParentAdditionals().at(0)->getChildEdges().at(0)) {
40  // fill closing reroute interval with default values
41  setDefaultValues();
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 {}, {}, {}, {rerouterIntervalParent}, {}, {}, {}, {}, {}, {}),
48 myClosedEdge(closedEdge),
49 myPermissions(permissions) {
50 }
51 
52 
54 
55 
56 void
58  // This additional cannot be moved
59 }
60 
61 
62 void
64  // This additional cannot be moved
65 }
66 
67 
68 void
70  // Currently this additional doesn't own a Geometry
71 }
72 
73 
76  return getParentAdditionals().at(0)->getPositionInView();
77 }
78 
79 
83 }
84 
85 
86 void
87 GNEClosingReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetElement* /*originalElement*/, const GNENetElement* /*newElement*/, GNEUndoList* /*undoList*/) {
88  // geometry of this element cannot be splitted
89 }
90 
91 
92 std::string
94  return getParentAdditionals().at(0)->getID();
95 }
96 
97 
98 void
100  // Currently this additional isn't drawn
101 }
102 
103 
104 std::string
106  switch (key) {
107  case SUMO_ATTR_ID:
108  return getAdditionalID();
109  case SUMO_ATTR_EDGE:
110  return myClosedEdge->getID();
111  case SUMO_ATTR_ALLOW:
113  case SUMO_ATTR_DISALLOW:
115  case GNE_ATTR_PARENT:
116  return getParentAdditionals().at(0)->getID();
117  case GNE_ATTR_PARAMETERS:
118  return getParametersStr();
119  default:
120  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
121  }
122 }
123 
124 
125 double
127  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
128 }
129 
130 
131 void
132 GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
133  if (value == getAttribute(key)) {
134  return; //avoid needless changes, later logic relies on the fact that attributes have changed
135  }
136  switch (key) {
137  case SUMO_ATTR_ID:
138  case SUMO_ATTR_EDGE:
139  case SUMO_ATTR_ALLOW:
140  case SUMO_ATTR_DISALLOW:
141  case GNE_ATTR_PARAMETERS:
142  undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), key, value));
143  break;
144  default:
145  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
146  }
147 }
148 
149 
150 bool
151 GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
152  switch (key) {
153  case SUMO_ATTR_ID:
154  return isValidAdditionalID(value);
155  case SUMO_ATTR_EDGE:
156  return (myViewNet->getNet()->retrieveEdge(value, false) != nullptr);
157  case SUMO_ATTR_ALLOW:
158  return canParseVehicleClasses(value);
159  case SUMO_ATTR_DISALLOW:
160  return canParseVehicleClasses(value);
161  case GNE_ATTR_PARAMETERS:
162  return Parameterised::areParametersValid(value);
163  default:
164  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
165  }
166 }
167 
168 
169 bool
171  return true;
172 }
173 
174 
175 std::string
177  return getTagStr();
178 }
179 
180 
181 std::string
183  return getTagStr() + ": " + myClosedEdge->getID();
184 }
185 
186 // ===========================================================================
187 // private
188 // ===========================================================================
189 
190 void
191 GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
192  switch (key) {
193  case SUMO_ATTR_ID:
194  changeAdditionalID(value);
195  break;
196  case SUMO_ATTR_EDGE:
198  break;
199  case SUMO_ATTR_ALLOW:
201  break;
202  case SUMO_ATTR_DISALLOW:
204  break;
205  case GNE_ATTR_PARAMETERS:
206  setParametersStr(value);
207  break;
208  default:
209  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
210  }
211 }
212 
213 /****************************************************************************/
GNEClosingReroute::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEClosingReroute.cpp:170
GNEClosingReroute::myPermissions
SVCPermissions myPermissions
Definition: GNEClosingReroute.h:136
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
Parameterised::getParametersStr
std::string getParametersStr() const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
Definition: Parameterised.cpp:112
GNEAdditional::getAdditionalID
const std::string & getAdditionalID() const
Definition: GNEAdditional.cpp:476
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1289
SUMO_ATTR_DISALLOW
Definition: SUMOXMLDefinitions.h:783
GNEEdge::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEEdge.cpp:448
SUMO_ATTR_EDGE
Definition: SUMOXMLDefinitions.h:423
GNEClosingReroute::myClosedEdge
GNEEdge * myClosedEdge
closed edge
Definition: GNEClosingReroute.h:133
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
GNEAdditional::changeAdditionalID
void changeAdditionalID(const std::string &newID)
change ID of additional
Definition: GNEAdditional.cpp:502
GNEClosingReroute::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEClosingReroute.cpp:151
GNEAdditional::myViewNet
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
Definition: GNEAdditional.h:335
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNEAttributeCarrier::GNEChange_Attribute
friend class GNEChange_Attribute
declare friend class
Definition: GNEAttributeCarrier.h:57
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:131
GNEViewNet::getNet
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:1014
parseVehicleClasses
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
Definition: SUMOVehicleClass.cpp:222
GNEClosingReroute::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEClosingReroute.cpp:75
GNEHierarchicalParentElements::getParentAdditionals
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
Definition: GNEHierarchicalParentElements.cpp:85
canParseVehicleClasses
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
Definition: SUMOVehicleClass.cpp:251
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
GNEClosingReroute::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEClosingReroute.cpp:87
GNEViewNet.h
GNERerouterIntervalDialog.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
Definition: SUMOXMLDefinitions.h:989
getVehicleClassNames
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
Definition: SUMOVehicleClass.cpp:168
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEClosingReroute::~GNEClosingReroute
~GNEClosingReroute()
destructor
Definition: GNEClosingReroute.cpp:53
GNEEdge.h
GNEClosingReroute::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEClosingReroute.cpp:105
GNEClosingReroute::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEClosingReroute.cpp:176
GNENetElement
Definition: GNENetElement.h:43
GNEClosingReroute::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEClosingReroute.cpp:182
SUMO_TAG_CLOSING_REROUTE
reroute of type closing
Definition: SUMOXMLDefinitions.h:192
Parameterised::setParametersStr
void setParametersStr(const std::string &paramsString)
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
Definition: Parameterised.cpp:139
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GNEClosingReroute::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEClosingReroute.cpp:63
GNEClosingReroute.h
Parameterised::areParametersValid
static bool areParametersValid(const std::string &value, bool report=false)
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
Definition: Parameterised.cpp:166
InvalidArgument
Definition: UtilExceptions.h:56
SUMO_ATTR_ALLOW
Definition: SUMOXMLDefinitions.h:782
GNEClosingReroute::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEClosingReroute.cpp:99
GLO_CALIBRATOR
a Calibrator
Definition: GUIGlObjectTypes.h:91
GNENet::retrieveEdge
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:1069
GNEClosingReroute::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEClosingReroute.cpp:69
config.h
GNEClosingReroute::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEClosingReroute.cpp:126
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1267
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEClosingReroute::GNEClosingReroute
GNEClosingReroute(GNERerouterIntervalDialog *rerouterIntervalDialog)
constructor (Used in GNERerouterIntervalDialog)
Definition: GNEClosingReroute.cpp:36
GNEClosingReroute::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEClosingReroute.cpp:93
GNEAdditional::isValidAdditionalID
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
Definition: GNEAdditional.cpp:482
invertPermissions
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
Definition: SUMOVehicleClass.cpp:285
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEClosingReroute::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
Definition: GNEClosingReroute.cpp:132
GNEChange_Attribute.h
GNENet.h
GNEClosingReroute::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEClosingReroute.cpp:81
GNERerouterIntervalDialog
Dialog for edit rerouter intervals.
Definition: GNERerouterIntervalDialog.h:49
GNEUndoList.h
GNE_ATTR_PARENT
parent of an additional element
Definition: SUMOXMLDefinitions.h:987
GNEClosingReroute::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEClosingReroute.cpp:57