SUMO - Simulation of Urban MObility
GNEParkingAreaReroute.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 
25 
26 #include "GNEParkingAreaReroute.h"
27 #include <netedit/GNEUndoList.h>
28 #include <netedit/GNEViewNet.h>
29 #include <netedit/GNENet.h>
30 
31 // ===========================================================================
32 // member method definitions
33 // ===========================================================================
34 
36  GNEAdditional(rerouterIntervalDialog->getEditedAdditional(),
37  rerouterIntervalDialog->getEditedAdditional()->getViewNet()->getNet()->getAdditionalByType(SUMO_TAG_PARKING_AREA).begin()->second,
38  rerouterIntervalDialog->getEditedAdditional()->getViewNet(), GLO_REROUTER, SUMO_TAG_PARKING_ZONE_REROUTE, "", false) {
39  // fill route type with default values
41 }
42 
43 
44 GNEParkingAreaReroute::GNEParkingAreaReroute(GNEAdditional* rerouterIntervalParent, GNEAdditional* newParkingArea, double probability, bool visible):
45  GNEAdditional(rerouterIntervalParent, newParkingArea, rerouterIntervalParent->getViewNet(), GLO_REROUTER, SUMO_TAG_PARKING_ZONE_REROUTE, "", false),
46  myProbability(probability),
47  myVisible(visible) {
48 }
49 
50 
52 
53 
54 void
56  // This additional cannot be moved
57 }
58 
59 
60 void
62  // This additional cannot be moved
63 }
64 
65 
66 void
68  // Currently this additional doesn't own a Geometry
69 }
70 
71 
75 }
76 
77 
78 std::string
81 }
82 
83 
84 void
86  // Currently this additional isn't drawn
87 }
88 
89 
90 std::string
92  switch (key) {
93  case SUMO_ATTR_ID:
94  return getAdditionalID();
95  case SUMO_ATTR_PARKING:
97  case SUMO_ATTR_PROB:
98  return toString(myProbability);
99  case SUMO_ATTR_VISIBLE:
100  return toString(myVisible);
101  case GNE_ATTR_PARENT:
103  case GNE_ATTR_GENERIC:
104  return getGenericParametersStr();
105  default:
106  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
107  }
108 }
109 
110 
111 void
112 GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
113  if (value == getAttribute(key)) {
114  return; //avoid needless changes, later logic relies on the fact that attributes have changed
115  }
116  switch (key) {
117  case SUMO_ATTR_ID:
118  case SUMO_ATTR_PARKING:
119  case SUMO_ATTR_PROB:
120  case SUMO_ATTR_VISIBLE:
121  case GNE_ATTR_GENERIC:
122  undoList->p_add(new GNEChange_Attribute(this, key, value));
123  break;
124  default:
125  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
126  }
127 }
128 
129 
130 bool
131 GNEParkingAreaReroute::isValid(SumoXMLAttr key, const std::string& value) {
132  switch (key) {
133  case SUMO_ATTR_ID:
134  return isValidAdditionalID(value);
135  case SUMO_ATTR_PARKING:
136  return isValidAdditionalID(value) && (myViewNet->getNet()->retrieveAdditional(SUMO_TAG_PARKING_AREA, value, false) != nullptr);
137  case SUMO_ATTR_PROB:
138  return canParse<double>(value) && parse<double>(value) >= 0 && parse<double>(value) <= 1;
139  case SUMO_ATTR_VISIBLE:
140  return canParse<bool>(value);
141  case GNE_ATTR_GENERIC:
142  return isGenericParametersValid(value);
143  default:
144  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
145  }
146 }
147 
148 
149 std::string
151  return getTagStr();
152 }
153 
154 
155 std::string
157  return getTagStr() + ": " + getSecondAdditionalParent()->getID();
158 }
159 
160 // ===========================================================================
161 // private
162 // ===========================================================================
163 
164 void
165 GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
166  switch (key) {
167  case SUMO_ATTR_ID:
168  changeAdditionalID(value);
169  break;
170  case SUMO_ATTR_PARKING:
172  break;
173  case SUMO_ATTR_PROB:
174  myProbability = parse<double>(value);
175  break;
176  case SUMO_ATTR_VISIBLE:
177  myVisible = parse<bool>(value);
178  break;
179  case GNE_ATTR_GENERIC:
181  break;
182  default:
183  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
184  }
185 }
186 
187 /****************************************************************************/
std::string getAttribute(SumoXMLAttr key) const
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.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo) ...
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
void changeAdditionalID(const std::string &newID)
change ID of additional
generic attribute
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.
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:1785
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Position getPositionInView() const
Returns position of additional in view.
double myProbability
probability with which a vehicle will use the given edge as destination
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
GNEAdditional * getSecondAdditionalParent() const
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
friend class GNEChange_Attribute
declare friend class
a Rerouter
bool myVisible
enable or disable visibility of Parking Area Reroute
const std::string getID() const
function to support debugging
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GNEParkingAreaReroute(GNERerouterIntervalDialog *rerouterIntervalDialog)
constructor (Used in GNERerouterIntervalDialog)
entry for an alternative parking zone
void changeSecondAdditionalParent(const std::string &newAdditionalParentID)
change second additional parent of additional
void updateGeometry(bool updateGrid)
update pre-computed geometry information
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
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
std::string getGenericParametersStr() const
return generic parameters in string format
std::string getParentName() const
Returns the name of the parent object.
GNENet * getNet() const
get the net object
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
parent of an additional element
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
GNEAdditional * myFirstAdditionalParent
pointer to first Additional parent
GNEAdditional * mySecondAdditionalParent
pointer to second Additional parent
virtual Position getPositionInView() const =0
Returns position of additional in view.