Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEClosingReroute.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-2024 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 "GNEClosingReroute.h"
24
25#include <netedit/GNEUndoList.h>
26#include <netedit/GNENet.h>
27
28
29// ===========================================================================
30// member method definitions
31// ===========================================================================
32
35 GUIIconSubSys::getIcon(GUIIcon::CLOSINGREROUTE), "", {}, {}, {}, {}, {}, {}),
36 myClosedEdge(nullptr),
37myPermissions(0) {
38 // reset default values
39 resetDefaultValues();
40}
41
42
43GNEClosingReroute::GNEClosingReroute(GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) :
45 GUIIconSubSys::getIcon(GUIIcon::CLOSINGREROUTE), "", {}, {}, {}, {rerouterIntervalParent}, {}, {}),
46myClosedEdge(closedEdge),
47myPermissions(permissions) {
48 // update boundary of rerouter parent
49 rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
50}
51
52
54
55
56void
69
70
71bool
73 return true;
74}
75
76
77std::string
79 return "";
80}
81
82
83void
85 // nothing to fix
86}
87
88
89bool
91 return false;
92}
93
94
97 // GNEClosingReroutes cannot be moved
98 return nullptr;
99}
100
101
102void
104 // update centering boundary (needed for centering)
106}
107
108
111 // get rerouter parent position
112 Position signPosition = getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView();
113 // set position depending of indexes
114 signPosition.add(4.5 + 6.25, (getDrawPositionIndex() * -1) - getParentAdditionals().front()->getDrawPositionIndex() + 1, 0);
115 // return signPosition
116 return signPosition;
117}
118
119
120void
122 // nothing to update
123}
124
125
126void
127GNEClosingReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
128 // geometry of this element cannot be splitted
129}
130
131
132std::string
134 return getParentAdditionals().at(0)->getID();
135}
136
137
138void
146
147
148std::string
150 switch (key) {
151 case SUMO_ATTR_ID:
152 return getMicrosimID();
153 case SUMO_ATTR_EDGE:
154 return myClosedEdge->getID();
155 case SUMO_ATTR_ALLOW:
159 case GNE_ATTR_PARENT:
160 return getParentAdditionals().at(0)->getID();
163 default:
164 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
165 }
166}
167
168
169double
171 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
172}
173
174
179
180
181void
182GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
183 if (value == getAttribute(key)) {
184 return; //avoid needless changes, later logic relies on the fact that attributes have changed
185 }
186 switch (key) {
187 case SUMO_ATTR_ID:
188 case SUMO_ATTR_EDGE:
189 case SUMO_ATTR_ALLOW:
192 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
193 break;
194 default:
195 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
196 }
197}
198
199
200bool
201GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
202 switch (key) {
203 case SUMO_ATTR_ID:
204 return isValidAdditionalID(value);
205 case SUMO_ATTR_EDGE:
206 return (myNet->getAttributeCarriers()->retrieveEdge(value, false) != nullptr);
207 case SUMO_ATTR_ALLOW:
208 return canParseVehicleClasses(value);
210 return canParseVehicleClasses(value);
211 default:
212 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
213 }
214}
215
216
217std::string
219 return getTagStr();
220}
221
222
223std::string
225 return getTagStr() + ": " + myClosedEdge->getID();
226}
227
228// ===========================================================================
229// private
230// ===========================================================================
231
232void
233GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
234 switch (key) {
235 case SUMO_ATTR_ID:
236 // update microsimID
237 setAdditionalID(value);
238 break;
239 case SUMO_ATTR_EDGE:
241 break;
242 case SUMO_ATTR_ALLOW:
244 break;
247 break;
249 if (parse<bool>(value)) {
251 } else {
253 }
254 break;
255 default:
256 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
257 }
258}
259
260
261void
263 // nothing to do
264}
265
266
267void
268GNEClosingReroute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
269 // nothing to do
270}
271
272
273/****************************************************************************/
@ GLO_REROUTER_CLOSINGREROUTE
a closing reroute
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ CLOSINGREROUTE
@ REROUTER_CLOSINGREROUTE
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_EDGE
@ GNE_ATTR_PARENT
parent of an additional element
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
An Element which don't belong to GNENet but has influence in the simulation.
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
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)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
static const Parameterised::Map PARAMETERS_EMPTY
empty parameter maps (used by ACs without parameters)
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
const Parameterised::Map & getACParametersMap() const
get parameters map
SVCPermissions myPermissions
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
void updateGeometry()
update pre-computed geometry information
GNEEdge * myClosedEdge
closed edge
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
std::string getParentName() const
Returns the name of the parent object.
double getAttributeDouble(SumoXMLAttr key) const
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
GNEMoveOperation * getMoveOperation()
get move operation
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
GNEClosingReroute(GNENet *net)
default constructor
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
std::string getAttribute(SumoXMLAttr key) const
bool checkDrawMoveContour() const
check if draw move contour (red)
Position getPositionInView() const
Returns position of additional in view.
~GNEClosingReroute()
destructor
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
move operation
move result
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
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:127
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
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:132
static const RGBColor YELLOW
Definition RGBColor.h:188
static const RGBColor RED
named colors
Definition RGBColor.h:185