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-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 "GNEClosingLaneReroute.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_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false,
39 {}, {}, {}, {rerouterIntervalDialog->getEditedAdditional()}, {}, {}, {}, {}, {}, {}),
40 myClosedLane(rerouterIntervalDialog->getEditedAdditional()->getParentAdditionals().at(0)->getChildEdges().at(0)->getLanes().at(0)) {
41  // fill closing lane reroute interval with default values
42  setDefaultValues();
43 }
44 
45 
46 GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
47  GNEAdditional(rerouterIntervalParent, rerouterIntervalParent->getViewNet(), GLO_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false,
48 {}, {}, {}, {rerouterIntervalParent}, {}, {}, {}, {}, {}, {}),
49 myClosedLane(closedLane),
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 getParentAdditionals().at(0)->getPositionInView();
78 }
79 
80 
84 }
85 
86 
87 void
88 GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetElement* /*originalElement*/, const GNENetElement* /*newElement*/, GNEUndoList* /*undoList*/) {
89  // geometry of this element cannot be splitted
90 }
91 
92 
93 std::string
95  return getParentAdditionals().at(0)->getID();
96 }
97 
98 
99 void
101  // Currently this additional isn't drawn
102 }
103 
104 
105 std::string
107  switch (key) {
108  case SUMO_ATTR_ID:
109  return getAdditionalID();
110  case SUMO_ATTR_LANE:
111  return myClosedLane->getID();
112  case SUMO_ATTR_ALLOW:
114  case SUMO_ATTR_DISALLOW:
116  case GNE_ATTR_PARENT:
117  return getParentAdditionals().at(0)->getID();
118  case GNE_ATTR_PARAMETERS:
119  return getParametersStr();
120  default:
121  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
122  }
123 }
124 
125 
126 double
128  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
129 }
130 
131 
132 void
133 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
134  if (value == getAttribute(key)) {
135  return; //avoid needless changes, later logic relies on the fact that attributes have changed
136  }
137  switch (key) {
138  case SUMO_ATTR_ID:
139  case SUMO_ATTR_LANE:
140  case SUMO_ATTR_ALLOW:
141  case SUMO_ATTR_DISALLOW:
142  case GNE_ATTR_PARAMETERS:
143  undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), key, value));
144  break;
145  default:
146  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
147  }
148 }
149 
150 
151 bool
152 GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
153  switch (key) {
154  case SUMO_ATTR_ID:
155  return isValidAdditionalID(value);
156  case SUMO_ATTR_LANE:
157  return (myViewNet->getNet()->retrieveLane(value, false) != nullptr);
158  case SUMO_ATTR_ALLOW:
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() + ": " + myClosedLane->getID();
184 }
185 
186 // ===========================================================================
187 // private
188 // ===========================================================================
189 
190 void
191 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
192  switch (key) {
193  case SUMO_ATTR_ID:
194  changeAdditionalID(value);
195  break;
196  case SUMO_ATTR_LANE:
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 /****************************************************************************/
GNEClosingLaneReroute::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
Definition: GNEClosingLaneReroute.cpp:133
GNELane::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:764
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
@ SUMO_ATTR_DISALLOW
Definition: SUMOXMLDefinitions.h:783
GNEClosingLaneReroute::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEClosingLaneReroute.cpp:58
GNEClosingLaneReroute::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEClosingLaneReroute.cpp:170
GNEClosingLaneReroute::myClosedLane
GNELane * myClosedLane
closed lane
Definition: GNEClosingLaneReroute.h:134
GNEClosingLaneReroute::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEClosingLaneReroute.cpp:106
SUMO_ATTR_ID
@ SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
GNEClosingLaneReroute::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEClosingLaneReroute.cpp:182
SUMO_ATTR_LANE
@ SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:637
GNEAdditional::changeAdditionalID
void changeAdditionalID(const std::string &newID)
change ID of additional
Definition: GNEAdditional.cpp:502
GNEClosingLaneReroute.h
GNEAdditional::myViewNet
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
Definition: GNEAdditional.h:335
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
GNEHierarchicalParentElements::getParentAdditionals
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
Definition: GNEHierarchicalParentElements.cpp:85
GNEClosingLaneReroute::~GNEClosingLaneReroute
~GNEClosingLaneReroute()
destructor
Definition: GNEClosingLaneReroute.cpp:54
canParseVehicleClasses
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
Definition: SUMOVehicleClass.cpp:251
GNEClosingLaneReroute::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEClosingLaneReroute.cpp:176
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
GNEClosingLaneReroute::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEClosingLaneReroute.cpp:94
GNEClosingLaneReroute::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEClosingLaneReroute.cpp:100
GNEViewNet.h
GNERerouterIntervalDialog.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNE_ATTR_PARAMETERS
@ 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
GNEEdge.h
GNEClosingLaneReroute::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEClosingLaneReroute.cpp:64
GNENetElement
Definition: GNENetElement.h:43
GNELane.h
GNEClosingLaneReroute::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEClosingLaneReroute.cpp:127
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
GNEClosingLaneReroute::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEClosingLaneReroute.cpp:88
GNEClosingLaneReroute::myPermissions
SVCPermissions myPermissions
Definition: GNEClosingLaneReroute.h:137
GNEClosingLaneReroute::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEClosingLaneReroute.cpp:76
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
GLO_REROUTER
@ GLO_REROUTER
a Rerouter
Definition: GUIGlObjectTypes.h:85
SUMO_ATTR_ALLOW
@ SUMO_ATTR_ALLOW
Definition: SUMOXMLDefinitions.h:782
GNEClosingLaneReroute::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEClosingLaneReroute.cpp:82
GNENet::retrieveLane
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1228
config.h
SUMO_TAG_CLOSING_LANE_REROUTE
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
Definition: SUMOXMLDefinitions.h:194
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
GNEClosingLaneReroute::GNEClosingLaneReroute
GNEClosingLaneReroute(GNERerouterIntervalDialog *rerouterIntervalDialog)
constructor (Used in GNERerouterIntervalDialog)
Definition: GNEClosingLaneReroute.cpp:37
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
GNEClosingLaneReroute::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEClosingLaneReroute.cpp:70
GNEClosingLaneReroute::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEClosingLaneReroute.cpp:152
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
GNEChange_Attribute.h
GNENet.h
GNERerouterIntervalDialog
Dialog for edit rerouter intervals.
Definition: GNERerouterIntervalDialog.h:49
GNEUndoList.h
GNE_ATTR_PARENT
@ GNE_ATTR_PARENT
parent of an additional element
Definition: SUMOXMLDefinitions.h:987