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 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include "GNEClosingLaneReroute.h"
28 
29 #include <netedit/GNEUndoList.h>
30 #include <netedit/GNEViewNet.h>
31 #include <netedit/GNENet.h>
32 
33 
34 // ===========================================================================
35 // member method definitions
36 // ===========================================================================
37 
39  GNEAdditional(rerouterIntervalDialog->getEditedAdditional(), rerouterIntervalDialog->getEditedAdditional()->getViewNet(), GLO_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false,
40 {}, {}, {}, {rerouterIntervalDialog->getEditedAdditional()}, {}, {}, {}, {}, {}, {}),
41 myClosedLane(rerouterIntervalDialog->getEditedAdditional()->getAdditionalParents().at(0)->getEdgeChildren().at(0)->getLanes().at(0)) {
42  // fill closing lane reroute interval with default values
43  setDefaultValues();
44 }
45 
46 
47 GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :
48  GNEAdditional(rerouterIntervalParent, rerouterIntervalParent->getViewNet(), GLO_REROUTER, SUMO_TAG_CLOSING_LANE_REROUTE, "", false,
49 {}, {}, {}, {rerouterIntervalParent}, {}, {}, {}, {}, {}, {}),
50 myClosedLane(closedLane),
51 myPermissions(permissions) {
52 }
53 
54 
56 
57 
58 void
60  // This additional cannot be moved
61 }
62 
63 
64 void
66  // This additional cannot be moved
67 }
68 
69 
70 void
72  // Currently this additional doesn't own a Geometry
73 }
74 
75 
78  return getAdditionalParents().at(0)->getPositionInView();
79 }
80 
81 
85 }
86 
87 
88 std::string
90  return getAdditionalParents().at(0)->getID();
91 }
92 
93 
94 void
96  // Currently this additional isn't drawn
97 }
98 
99 
100 std::string
102  switch (key) {
103  case SUMO_ATTR_ID:
104  return getAdditionalID();
105  case SUMO_ATTR_LANE:
106  return myClosedLane->getID();
107  case SUMO_ATTR_ALLOW:
109  case SUMO_ATTR_DISALLOW:
111  case GNE_ATTR_PARENT:
112  return getAdditionalParents().at(0)->getID();
113  case GNE_ATTR_GENERIC:
114  return getGenericParametersStr();
115  default:
116  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
117  }
118 }
119 
120 
121 void
122 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
123  if (value == getAttribute(key)) {
124  return; //avoid needless changes, later logic relies on the fact that attributes have changed
125  }
126  switch (key) {
127  case SUMO_ATTR_ID:
128  case SUMO_ATTR_LANE:
129  case SUMO_ATTR_ALLOW:
130  case SUMO_ATTR_DISALLOW:
131  case GNE_ATTR_GENERIC:
132  undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), key, value));
133  break;
134  default:
135  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
136  }
137 }
138 
139 
140 bool
141 GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {
142  switch (key) {
143  case SUMO_ATTR_ID:
144  return isValidAdditionalID(value);
145  case SUMO_ATTR_LANE:
146  return (myViewNet->getNet()->retrieveLane(value, false) != nullptr);
147  case SUMO_ATTR_ALLOW:
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() + ": " + myClosedLane->getID();
167 }
168 
169 // ===========================================================================
170 // private
171 // ===========================================================================
172 
173 void
174 GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
175  switch (key) {
176  case SUMO_ATTR_ID:
177  changeAdditionalID(value);
178  break;
179  case SUMO_ATTR_LANE:
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 /****************************************************************************/
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:122
GNELane::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:723
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNEAdditional::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEAdditional.cpp:704
GNEAdditional::getAdditionalID
const std::string & getAdditionalID() const
Definition: GNEAdditional.cpp:578
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1187
SUMO_ATTR_DISALLOW
Definition: SUMOXMLDefinitions.h:780
GNEClosingLaneReroute::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEClosingLaneReroute.cpp:59
GNEClosingLaneReroute::myClosedLane
GNELane * myClosedLane
closed lane
Definition: GNEClosingLaneReroute.h:121
GNEClosingLaneReroute::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEClosingLaneReroute.cpp:101
GNEAttributeCarrier::isGenericParametersValid
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
Definition: GNEAttributeCarrier.cpp:1354
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
GNEClosingLaneReroute::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEClosingLaneReroute.cpp:165
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:635
GNEAdditional::changeAdditionalID
void changeAdditionalID(const std::string &newID)
change ID of additional
Definition: GNEAdditional.cpp:604
GNEClosingLaneReroute.h
GNEAdditional::myViewNet
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
Definition: GNEAdditional.h:365
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:132
GNEViewNet::getNet
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:927
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:223
GNEClosingLaneReroute::~GNEClosingLaneReroute
~GNEClosingLaneReroute()
destructor
Definition: GNEClosingLaneReroute.cpp:55
canParseVehicleClasses
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
Definition: SUMOVehicleClass.cpp:252
GNEClosingLaneReroute::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEClosingLaneReroute.cpp:159
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:219
GNEClosingLaneReroute::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEClosingLaneReroute.cpp:89
GNEClosingLaneReroute::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEClosingLaneReroute.cpp:95
GNEViewNet.h
GNERerouterIntervalDialog.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
getVehicleClassNames
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
Definition: SUMOVehicleClass.cpp:169
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEEdge.h
GNEClosingLaneReroute::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEClosingLaneReroute.cpp:65
GNELane.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
GNE_ATTR_GENERIC
generic attribute
Definition: SUMOXMLDefinitions.h:986
GNEClosingLaneReroute::myPermissions
SVCPermissions myPermissions
Definition: GNEClosingLaneReroute.h:124
GNEClosingLaneReroute::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEClosingLaneReroute.cpp:77
GNEHierarchicalElementParents::getAdditionalParents
const std::vector< GNEAdditional * > & getAdditionalParents() const
return vector of additionals that have as Parent this edge (For example, Calibrators)
Definition: GNEHierarchicalElementParents.cpp:86
InvalidArgument
Definition: UtilExceptions.h:57
GNEAdditional::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEAdditional.cpp:678
GLO_REROUTER
a Rerouter
Definition: GUIGlObjectTypes.h:86
SUMO_ATTR_ALLOW
Definition: SUMOXMLDefinitions.h:779
GNEClosingLaneReroute::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEClosingLaneReroute.cpp:83
GNENet::retrieveLane
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1179
config.h
SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
Definition: SUMOXMLDefinitions.h:195
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1165
GNEUndoList
Definition: GNEUndoList.h:49
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GNEClosingLaneReroute::GNEClosingLaneReroute
GNEClosingLaneReroute(GNERerouterIntervalDialog *rerouterIntervalDialog)
constructor (Used in GNERerouterIntervalDialog)
Definition: GNEClosingLaneReroute.cpp:38
GNEAdditional::isValidAdditionalID
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
Definition: GNEAdditional.cpp:584
invertPermissions
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
Definition: SUMOVehicleClass.cpp:286
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNEClosingLaneReroute::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEClosingLaneReroute.cpp:71
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:141
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
GNEChange_Attribute.h
GNENet.h
GNERerouterIntervalDialog
Dialog for edit rerouter intervals.
Definition: GNERerouterIntervalDialog.h:53
GNEUndoList.h
GNE_ATTR_PARENT
parent of an additional element
Definition: SUMOXMLDefinitions.h:984