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-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
21#include <netedit/GNENet.h>
23
25
26// ===========================================================================
27// member method definitions
28// ===========================================================================
29
34
35
37 const double probability, const bool visible):
38 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
54 return nullptr;
55}
56
57
60 return nullptr;
61}
62
63
64const Parameterised*
66 return nullptr;
67}
68
69
70void
73 // write common additional attributes
75 // write specific attributes
77 if (myProbability != 1.0) {
79 }
80 if (myVisible) {
81 device.writeAttr(SUMO_ATTR_VISIBLE, true);
82 }
83 device.closeTag();
84}
85
86
87bool
89 return true;
90}
91
92
93std::string
97
98
99void
101 // nothing to fix
102}
103
104
105bool
107 return false;
108}
109
110
111void
115
116
121
122
123void
125 // nothing to update
126}
127
128
129void
130GNEParkingAreaReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
131 // geometry of this element cannot be splitted
132}
133
134
135std::string
137 return getParentAdditionals().at(0)->getID();
138}
139
140
141void
147
148
149std::string
151 switch (key) {
152 case SUMO_ATTR_ID:
153 return getMicrosimID();
155 return getParentAdditionals().at(1)->getID();
156 case SUMO_ATTR_PROB:
157 return toString(myProbability);
159 return toString(myVisible);
160 case GNE_ATTR_PARENT:
161 return toString(getParentAdditionals().at(0)->getID());
162 default:
163 return getCommonAttribute(key);
164 }
165}
166
167
168double
172
173
178
179
184
185
186void
187GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
188 if (value == getAttribute(key)) {
189 return; //avoid needless changes, later logic relies on the fact that attributes have changed
190 }
191 switch (key) {
192 case SUMO_ATTR_ID:
194 case SUMO_ATTR_PROB:
196 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
197 break;
198 default:
199 setCommonAttribute(key, value, undoList);
200 break;
201 }
202}
203
204
205bool
206GNEParkingAreaReroute::isValid(SumoXMLAttr key, const std::string& value) {
207 switch (key) {
208 case SUMO_ATTR_ID:
209 return isValidAdditionalID(value);
211 return (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_PARKING_AREA, value, false) != nullptr);
212 case SUMO_ATTR_PROB:
213 return canParse<double>(value) && parse<double>(value) >= 0 && parse<double>(value) <= 1;
215 return canParse<bool>(value);
216 default:
217 return isCommonAttributeValid(key, value);
218 }
219}
220
221
222std::string
224 return getTagStr();
225}
226
227
228std::string
230 return getTagStr() + ": " + getParentAdditionals().at(1)->getID();
231}
232
233// ===========================================================================
234// private
235// ===========================================================================
236
237void
238GNEParkingAreaReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
239 switch (key) {
240 case SUMO_ATTR_ID:
241 // update microsimID
242 setAdditionalID(value);
243 break;
246 break;
247 case SUMO_ATTR_PROB:
248 myProbability = parse<double>(value);
249 break;
251 myVisible = parse<bool>(value);
252 break;
253 default:
254 setCommonAttribute(key, value);
255 break;
256 }
257}
258
259/****************************************************************************/
@ 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 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
const std::string getID() const
get ID (all Attribute Carriers have one)
double getCommonAttributeDouble(SumoXMLAttr key) const
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.
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:144
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
bool checkDrawMoveContour() const override
check if draw move contour (red)
bool isValid(SumoXMLAttr key, const std::string &value) override
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
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Position getAttributePosition(SumoXMLAttr key) const override
double getAttributeDouble(SumoXMLAttr key) const override
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Position getPositionInView() const
Returns position of additional in view.
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
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
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
std::string getParentName() const
Returns the name of the parent object.
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this parkingAreaReroute
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
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.
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:191
static const RGBColor RED
named colors
Definition RGBColor.h:188