Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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
21#include <netedit/GNENet.h>
23
25
26// ===========================================================================
27// member method definitions
28// ===========================================================================
29
30#ifdef _MSC_VER
31#pragma warning(push)
32#pragma warning(disable: 4355) // mask warning about "this" in initializers
33#endif
38
39
41 const double probability, const bool visible):
42 GNEAdditional(rerouterIntervalParent, SUMO_TAG_PARKING_AREA_REROUTE, ""),
44 myProbability(probability),
45 myVisible(visible) {
46 // set parents
47 setParents<GNEAdditional*>({rerouterIntervalParent, newParkingArea});
48 // update boundary of rerouter parent
49 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
50}
51#ifdef _MSC_VER
52#pragma warning(pop)
53#endif
54
55
57
58
61 return nullptr;
62}
63
64
67 return nullptr;
68}
69
70
71const Parameterised*
73 return nullptr;
74}
75
76
77void
80 // write common additional attributes
82 // write specific attributes
84 if (myProbability != 1.0) {
86 }
87 if (myVisible) {
88 device.writeAttr(SUMO_ATTR_VISIBLE, true);
89 }
90 device.closeTag();
91}
92
93
94bool
96 return true;
97}
98
99
100std::string
104
105
106void
108 // nothing to fix
109}
110
111
112bool
114 return false;
115}
116
117
118void
122
123
128
129
130void
132 // nothing to update
133}
134
135
136void
137GNEParkingAreaReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
138 // geometry of this element cannot be splitted
139}
140
141
142std::string
144 return getParentAdditionals().at(0)->getID();
145}
146
147
148void
154
155
156std::string
158 switch (key) {
159 case SUMO_ATTR_ID:
160 return getMicrosimID();
162 return getParentAdditionals().at(1)->getID();
163 case SUMO_ATTR_PROB:
164 return toString(myProbability);
166 return toString(myVisible);
167 case GNE_ATTR_PARENT:
168 return toString(getParentAdditionals().at(0)->getID());
169 default:
170 return getCommonAttribute(key);
171 }
172}
173
174
175double
179
180
185
186
191
192
193void
194GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
195 if (value == getAttribute(key)) {
196 return; //avoid needless changes, later logic relies on the fact that attributes have changed
197 }
198 switch (key) {
199 case SUMO_ATTR_ID:
201 case SUMO_ATTR_PROB:
203 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
204 break;
205 default:
206 setCommonAttribute(key, value, undoList);
207 break;
208 }
209}
210
211
212bool
213GNEParkingAreaReroute::isValid(SumoXMLAttr key, const std::string& value) {
214 switch (key) {
215 case SUMO_ATTR_ID:
216 return isValidAdditionalID(value);
218 return (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, value, false) != nullptr);
219 case SUMO_ATTR_PROB:
220 return canParse<double>(value) && parse<double>(value) >= 0 && parse<double>(value) <= 1;
222 return canParse<bool>(value);
223 default:
224 return isCommonAttributeValid(key, value);
225 }
226}
227
228
229std::string
231 return getTagStr();
232}
233
234
235std::string
237 return getTagStr() + ": " + getParentAdditionals().at(1)->getID();
238}
239
240// ===========================================================================
241// private
242// ===========================================================================
243
244void
245GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
246 switch (key) {
247 case SUMO_ATTR_ID:
248 // update microsimID
249 setAdditionalID(value);
250 break;
253 break;
254 case SUMO_ATTR_PROB:
255 myProbability = parse<double>(value);
256 break;
258 myVisible = parse<bool>(value);
259 break;
260 default:
261 setCommonAttribute(key, value);
262 break;
263 }
264}
265
266/****************************************************************************/
@ 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:49
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 setAdditionalID(const std::string &newID)
set additional ID
void writeAdditionalAttributes(OutputDevice &device) const
write common additional attributes
void drawListedAdditional(const GUIVisualizationSettings &s, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
Position getListedPositionInView() const
get listed position in view
void updateGeometryListedAdditional()
update geometry of listed additional
double getCommonAttributeDouble(SumoXMLAttr key) const
const std::string getID() const override
get ID (all Attribute Carriers have one)
PositionVector getCommonAttributePositionVector(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
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * myNet
pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) 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
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
bool checkDrawMoveContour() const override
check if draw move contour (red)
bool isValid(SumoXMLAttr key, const std::string &value) override
void updateCenteringBoundary(const bool updateGrid) override
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
std::string getAttribute(SumoXMLAttr key) const override
Position getAttributePosition(SumoXMLAttr key) const override
double getAttributeDouble(SumoXMLAttr key) const override
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Position getPositionInView() const override
Returns position of additional in view.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
void updateGeometry() override
update pre-computed geometry information
Parameterised * getParameters() override
get parameters associated with this parkingAreaReroute
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this parkingAreaReroute
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
std::string getParentName() const override
Returns the name of the parent object.
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
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 & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
static const RGBColor YELLOW
Definition RGBColor.h:195
static const RGBColor RED
named colors
Definition RGBColor.h:192