Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNERouteProbReroute.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
22#include <netedit/GNENet.h>
24
25#include "GNERouteProbReroute.h"
26
27// ===========================================================================
28// member method definitions
29// ===========================================================================
30
35
36
37GNERouteProbReroute::GNERouteProbReroute(GNEAdditional* rerouterIntervalParent, GNEDemandElement* route, double probability) :
38 GNEAdditional(rerouterIntervalParent, SUMO_TAG_ROUTE_PROB_REROUTE, ""),
40 myProbability(probability) {
41 // set parents
42 setParent<GNEAdditional*>(rerouterIntervalParent);
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
78 device.closeTag();
79}
80
81
82bool
84 return true;
85}
86
87
88std::string
92
93
94void
96 // nothing to fix
97}
98
99
100bool
102 return false;
103}
104
105
106void
110
111
116
117
118void
120 // nothing to do
121}
122
123
124void
125GNERouteProbReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
126 // geometry of this element cannot be splitted
127}
128
129
130std::string
132 return getParentAdditionals().at(0)->getID();
133}
134
135
136void
142
143
144std::string
146 switch (key) {
147 case SUMO_ATTR_ID:
148 return getMicrosimID();
149 case SUMO_ATTR_ROUTE:
150 return getParentDemandElements().front()->getID();
151 case SUMO_ATTR_PROB:
152 return toString(myProbability);
153 case GNE_ATTR_PARENT:
154 return getParentAdditionals().at(0)->getID();
155 default:
156 return getCommonAttribute(key);
157 }
158}
159
160
161double
165
166
171
172
177
178
179void
181 if (value == getAttribute(key)) {
182 return; //avoid needless changes, later logic relies on the fact that attributes have changed
183 }
184 switch (key) {
185 case SUMO_ATTR_ID:
186 case SUMO_ATTR_ROUTE:
187 case SUMO_ATTR_PROB:
188 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
189 break;
190 default:
191 setCommonAttribute(key, value, undoList);
192 break;
193 }
194}
195
196
197bool
199 switch (key) {
200 case SUMO_ATTR_ID:
202 case SUMO_ATTR_ROUTE:
203 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::routes, value, false) == nullptr);
204 case SUMO_ATTR_PROB:
205 return canParse<double>(value);
206 default:
207 return isCommonAttributeValid(key, value);
208 }
209}
210
211
212std::string
214 return getTagStr();
215}
216
217
218std::string
220 return getTagStr() + ": " + getParentDemandElements().front()->getID();
221}
222
223// ===========================================================================
224// private
225// ===========================================================================
226
227void
229 switch (key) {
230 case SUMO_ATTR_ID:
231 // update microsimID
233 break;
234 case SUMO_ATTR_ROUTE:
236 break;
237 case SUMO_ATTR_PROB:
239 break;
240 default:
242 break;
243 }
244}
245
246/****************************************************************************/
@ REROUTER_ROUTEPROBREROUTE
Definition GUITextures.h:42
const std::string invalid_return< std::string >::value
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ SUMO_TAG_ROUTE
description of a route
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_PROB
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_ID
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 setAdditionalID(const std::string &newID)
set additional ID
friend class GNEAdditionalListed
declare friend class
void writeAdditionalAttributes(OutputDevice &device) const
write common additional attributes
GNEAdditional(const std::string &id, GNENet *net, const std::string &filename, SumoXMLTag tag, const std::string &additionalName)
Constructor.
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
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
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
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
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
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
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
void setParent(ParentType parent)
edit parent and childrens without maintain integrity (use carefully)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
double myProbability
probability with which a vehicle will use the given edge as destination
bool isValid(SumoXMLAttr key, const std::string &value) override
std::string getParentName() const override
Returns the name of the parent object.
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this routeProbReroute
Position getPositionInView() const override
Returns position of additional in view.
Parameterised * getParameters() override
get parameters associated with this routeProbReroute
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
GNERouteProbReroute(GNENet *net)
default constructor
void updateGeometry() override
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const override
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
double getAttributeDouble(SumoXMLAttr key) const override
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
bool checkDrawMoveContour() const override
check if draw move contour (red)
std::string getAttribute(SumoXMLAttr key) const override
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Stores the information about how to visualize structures.
static const std::vector< SumoXMLTag > routes
route namespace
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