Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEParkingAreaReroute.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18//
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
25
27
28// ===========================================================================
29// member method definitions
30// ===========================================================================
31
35
36
38 const double probability, const bool visible):
39 GNEAdditional(rerouterIntervalParent, SUMO_TAG_PARKING_AREA_REROUTE, ""),
40 myProbability(probability),
41 myVisible(visible) {
42 // set parents
43 setParents<GNEAdditional*>({rerouterIntervalParent, newParkingArea});
44 // update boundary of rerouter parent
45 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
46}
47
48
50
51
52void
64
65
66bool
68 return true;
69}
70
71
72std::string
76
77
78void
82
83
84bool
86 return false;
87}
88
89
92 // GNEParkingAreaReroutes cannot be moved
93 return nullptr;
94}
95
96
97void
99 // update centering boundary (needed for centering)
101}
102
103
106 // get rerouter parent position
107 Position signPosition = getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView();
108 // set position depending of indexes
109 signPosition.add(4.5 + 6.25, (getDrawPositionIndex() * -1) - getParentAdditionals().front()->getDrawPositionIndex() + 1, 0);
110 // return signPosition
111 return signPosition;
112}
113
114
115void
117 // nothing to update
118}
119
120
121void
122GNEParkingAreaReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
123 // geometry of this element cannot be splitted
124}
125
126
127std::string
129 return getParentAdditionals().at(0)->getID();
130}
131
132
133void
141
142
143std::string
145 switch (key) {
146 case SUMO_ATTR_ID:
147 return getMicrosimID();
149 return getParentAdditionals().at(1)->getID();
150 case SUMO_ATTR_PROB:
151 return toString(myProbability);
153 return toString(myVisible);
154 case GNE_ATTR_PARENT:
155 return toString(getParentAdditionals().at(0)->getID());
156 default:
157 return getCommonAttribute(this, key);
158 }
159}
160
161
162double
164 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
165}
166
167
172
173
174void
175GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
176 if (value == getAttribute(key)) {
177 return; //avoid needless changes, later logic relies on the fact that attributes have changed
178 }
179 switch (key) {
180 case SUMO_ATTR_ID:
182 case SUMO_ATTR_PROB:
184 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
185 break;
186 default:
187 setCommonAttribute(key, value, undoList);
188 break;
189 }
190}
191
192
193bool
194GNEParkingAreaReroute::isValid(SumoXMLAttr key, const std::string& value) {
195 switch (key) {
196 case SUMO_ATTR_ID:
197 return isValidAdditionalID(value);
199 return (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, value, false) != nullptr);
200 case SUMO_ATTR_PROB:
201 return canParse<double>(value) && parse<double>(value) >= 0 && parse<double>(value) <= 1;
203 return canParse<bool>(value);
204 default:
205 return isCommonValid(key, value);
206 }
207}
208
209
210std::string
212 return getTagStr();
213}
214
215
216std::string
218 return getTagStr() + ": " + getParentAdditionals().at(1)->getID();
219}
220
221// ===========================================================================
222// private
223// ===========================================================================
224
225void
226GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
227 switch (key) {
228 case SUMO_ATTR_ID:
229 // update microsimID
230 setAdditionalID(value);
231 break;
234 break;
235 case SUMO_ATTR_PROB:
236 myProbability = parse<double>(value);
237 break;
239 myVisible = parse<bool>(value);
240 break;
241 default:
242 setCommonAttribute(this, key, value);
243 break;
244 }
245}
246
247
248void
250 // nothing to do
251}
252
253
254void
256 // nothing to do
257}
258
259
260/****************************************************************************/
@ REROUTER_PARKINGAREAREROUTE
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_PARKING_AREA
A parking area.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_PARKING
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_PROB
@ SUMO_ATTR_ID
@ SUMO_ATTR_VISIBLE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
void drawListedAdditional(const GUIVisualizationSettings &s, const Position &parentPosition, const double offsetX, const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
void setAdditionalID(const std::string &newID)
set additional ID
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const std::string getID() const
get ID (all Attribute Carriers have one)
std::string getCommonAttribute(const Parameterised *parameterised, SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) const
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
move operation
move result
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
double myProbability
probability with which a vehicle will use the given edge as destination
GNEParkingAreaReroute(GNENet *net)
constructor
bool myVisible
enable or disable visibility of Parking Area Reroute
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of additional in view.
double getAttributeDouble(SumoXMLAttr key) const
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
bool checkDrawMoveContour() const
check if draw move contour (red)
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
void updateGeometry()
update pre-computed geometry information
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
const Parameterised::Map & getACParametersMap() const
get parameters map
std::string getParentName() const
Returns the name of the parent object.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string getAttribute(SumoXMLAttr key) const
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
GNEMoveOperation * getMoveOperation()
get move operation
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:129
static const RGBColor YELLOW
Definition RGBColor.h:191
static const RGBColor RED
named colors
Definition RGBColor.h:188