Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNELaneType.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-2023 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/****************************************************************************/
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
26
27
28#include "GNELaneType.h"
29#include "GNEEdgeType.h"
30
31
32// ===========================================================================
33// members methods
34// ===========================================================================
35
37 GNENetworkElement(edgeTypeParent->getNet(), "", GLO_LANETYPE, SUMO_TAG_LANETYPE, GUIIconSubSys::getIcon(GUIIcon::LANETYPE), {}, {}, {}, {}, {}, {}),
38myEdgeTypeParent(edgeTypeParent) {
39}
40
41
43 GNENetworkElement(edgeTypeParent->getNet(), "", GLO_LANETYPE, SUMO_TAG_LANETYPE, GUIIconSubSys::getIcon(GUIIcon::LANETYPE), {}, {}, {}, {}, {}, {}),
45myEdgeTypeParent(edgeTypeParent) {
46}
47
48
51
52
57
58
59void
60GNELaneType::copyLaneType(GNELaneType* originalLaneType, GNEUndoList* undoList) {
61 // copy speed
62 setAttribute(SUMO_ATTR_SPEED, originalLaneType->getAttribute(SUMO_ATTR_SPEED), undoList);
63 // copy allow (and disallow)
64 setAttribute(SUMO_ATTR_ALLOW, originalLaneType->getAttribute(SUMO_ATTR_ALLOW), undoList);
65 // copy width
66 setAttribute(SUMO_ATTR_WIDTH, originalLaneType->getAttribute(SUMO_ATTR_WIDTH), undoList);
67 // copy parameters
69}
70
71
72void
74 // nothing to do
75}
76
77
80 // currently unused
81 return Position(0, 0);
82}
83
84
87 return nullptr;
88}
89
90
91void
92GNELaneType::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
93 // nothing to do
94}
95
96
99 return nullptr;
100}
101
102
103void
104GNELaneType::updateCenteringBoundary(const bool /*updateGrid*/) {
105 // nothing to do
106}
107
108
109void
111 // nothing to draw
112}
113
114
115void
119
120
121void
125
126
127std::string
129 switch (key) {
130 case SUMO_ATTR_ID:
131 return "lane: " + toString(myEdgeTypeParent->getLaneTypeIndex(this));
132 case SUMO_ATTR_SPEED:
133 if (attrs.count(key) == 0) {
134 return "";
135 } else {
136 return toString(speed);
137 }
138 case SUMO_ATTR_ALLOW:
139 if ((permissions == SVCAll) || (permissions == -1)) {
140 return "all";
141 } else if (permissions == 0) {
142 return "";
143 } else {
145 }
147 if (permissions == 0) {
148 return "all";
149 } else if ((permissions == SVCAll) || (permissions == -1)) {
150 return "";
151 } else {
153 }
154 case SUMO_ATTR_WIDTH:
155 if (attrs.count(key) == 0) {
156 return "";
157 } else {
158 return toString(width);
159 }
161 if (attrs.count(key) == 0) {
162 return "";
163 } else {
164 return toString(width);
165 }
167 return getParametersStr();
168 default:
169 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
170 }
171}
172
173
174void
175GNELaneType::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
176 throw InvalidArgument("laneType attributes cannot be edited here");
177}
178
179
180bool
181GNELaneType::isValid(SumoXMLAttr key, const std::string& value) {
182 switch (key) {
183 case SUMO_ATTR_ID:
184 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
185 case SUMO_ATTR_SPEED:
186 return canParse<double>(value) && (parse<double>(value) > 0);
187 case SUMO_ATTR_ALLOW:
189 return canParseVehicleClasses(value);
190 case SUMO_ATTR_WIDTH:
191 return canParse<double>(value) && ((parse<double>(value) >= -1) || (parse<double>(value) == NBEdge::UNSPECIFIED_WIDTH));
194 default:
195 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
196 }
197}
198
199
204
205// ===========================================================================
206// private
207// ===========================================================================
208
209void
210GNELaneType::setAttribute(SumoXMLAttr key, const std::string& value) {
211 switch (key) {
212 case SUMO_ATTR_ID:
213 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
214 case SUMO_ATTR_SPEED:
215 if (value.empty()) {
216 attrs.erase(key);
217 } else {
218 attrs.insert(key);
219 speed = parse<double>(value);
220 }
221 break;
222 case SUMO_ATTR_ALLOW:
223 // parse permissions
225 // check attrs
226 if ((permissions == SVCAll) || (permissions == -1)) {
227 attrs.insert(SUMO_ATTR_ALLOW);
229 } else if (permissions == 0) {
230 attrs.erase(SUMO_ATTR_ALLOW);
232 } else {
233 attrs.insert(SUMO_ATTR_ALLOW);
235 }
236 break;
238 // parse invert permissions
240 // check attrs
241 if ((permissions == SVCAll) || (permissions == -1)) {
242 attrs.insert(SUMO_ATTR_ALLOW);
244 } else if (permissions == 0) {
245 attrs.erase(SUMO_ATTR_ALLOW);
247 } else {
248 attrs.insert(SUMO_ATTR_ALLOW);
250 }
251 break;
252 case SUMO_ATTR_WIDTH:
253 if (value.empty()) {
254 attrs.erase(key);
255 } else {
256 attrs.insert(key);
257 width = parse<double>(value);
258 }
259 break;
261 setParametersStr(value);
262 break;
263 default:
264 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
265 }
266 // update edge selector
267 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
269 }
270}
271
272
273void
275 // nothing to do
276}
277
278
279void
280GNELaneType::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
281 // nothing to do
282}
283
284/****************************************************************************/
@ GLO_LANETYPE
a laneType
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
const SVCPermissions SVCAll
all VClasses are allowed
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.
@ SUMO_TAG_LANETYPE
lane type
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_SPEED
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_FRICTION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
void refreshAttributesCreator()
refresh attribute creator
GNEAttributesCreator * getLaneTypeAttributes() const
get laneType attributes
int getLaneTypeIndex(const GNELaneType *laneType) const
get laneType index
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
GNEEdgeType * myEdgeTypeParent
pointer to EdgeTypeParent
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Position getPositionInView() const
Returns position of hierarchical element in view.
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void updateGeometry()
update pre-computed geometry information
bool isValid(SumoXMLAttr key, const std::string &value)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
std::string getAttribute(SumoXMLAttr key) const
void deleteGLObject()
delete element
const Parameterised::Map & getACParametersMap() const
get parameters map
GNELaneType(GNEEdgeType *edgeTypeParent)
Constructor.
void copyLaneType(GNELaneType *originalLaneType, GNEUndoList *undoList)
copy values of given laneType in current laneType
GNEMoveOperation * getMoveOperation()
get move operation
GNEEdgeType * getEdgeTypeParent() const
get edge type parent
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
~GNELaneType()
Destructor.
void updateGLObject()
update GLObject (geometry, ID, etc.)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
move operation
move result
void deleteNetworkElement(GNENetworkElement *networkElement, GNEUndoList *undoList)
delete network element
Definition GNENet.cpp:325
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
GNECreateEdgeFrame * getCreateEdgeFrame() const
get frame for NETWORK_CREATEEDGE
The popup menu of a globject.
Stores the information about how to visualize structures.
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition NBEdge.h:341
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
laneType definition
Definition NBTypeCont.h:59
double speed
The maximal velocity on a lane in m/s.
Definition NBTypeCont.h:74
SVCPermissions permissions
List of vehicle edgeTypes that are allowed on this lane.
Definition NBTypeCont.h:80
std::set< SumoXMLAttr > attrs
The attributes which have been set.
Definition NBTypeCont.h:89
double width
lane width [m]
Definition NBTypeCont.h:83