Eclipse SUMO - Simulation of Urban MObility
GNELaneType.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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_LANE, SUMO_TAG_LANETYPE, GUIIconSubSys::getIcon(GUIIcon::LANETYPE), {}, {}, {}, {}, {}, {}),
38myEdgeTypeParent(edgeTypeParent) {
39}
40
41
43 GNENetworkElement(edgeTypeParent->getNet(), "", GLO_LANE, SUMO_TAG_LANETYPE, GUIIconSubSys::getIcon(GUIIcon::LANETYPE), {}, {}, {}, {}, {}, {}),
45myEdgeTypeParent(edgeTypeParent) {
46}
47
48
50}
51
52
55 return myEdgeTypeParent;
56}
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
103double
105 return 1;
106}
107
108
109void
110GNELaneType::updateCenteringBoundary(const bool /*updateGrid*/) {
111 // nothing to do
112}
113
114
115void
117 // nothing to draw
118}
119
120
121void
124}
125
126
127void
130}
131
132
133std::string
135 switch (key) {
136 case SUMO_ATTR_ID:
137 return "lane: " + toString(myEdgeTypeParent->getLaneTypeIndex(this));
138 case SUMO_ATTR_SPEED:
139 if (attrs.count(key) == 0) {
140 return "";
141 } else {
142 return toString(speed);
143 }
144 case SUMO_ATTR_ALLOW:
145 if ((permissions == SVCAll) || (permissions == -1)) {
146 return "all";
147 } else if (permissions == 0) {
148 return "";
149 } else {
151 }
153 if (permissions == 0) {
154 return "all";
155 } else if ((permissions == SVCAll) || (permissions == -1)) {
156 return "";
157 } else {
159 }
160 case SUMO_ATTR_WIDTH:
161 if (attrs.count(key) == 0) {
162 return "";
163 } else {
164 return toString(width);
165 }
167 if (attrs.count(key) == 0) {
168 return "";
169 } else {
170 return toString(width);
171 }
173 return getParametersStr();
174 default:
175 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
176 }
177}
178
179
180void
181GNELaneType::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
182 throw InvalidArgument("laneType attributes cannot be edited here");
183}
184
185
186bool
187GNELaneType::isValid(SumoXMLAttr key, const std::string& value) {
188 switch (key) {
189 case SUMO_ATTR_ID:
190 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
191 case SUMO_ATTR_SPEED:
192 return canParse<double>(value) && (parse<double>(value) > 0);
193 case SUMO_ATTR_ALLOW:
195 return canParseVehicleClasses(value);
196 case SUMO_ATTR_WIDTH:
197 return canParse<double>(value) && ((parse<double>(value) >= -1) || (parse<double>(value) == NBEdge::UNSPECIFIED_WIDTH));
200 default:
201 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
202 }
203}
204
205
208 return getParametersMap();
209}
210
211// ===========================================================================
212// private
213// ===========================================================================
214
215void
216GNELaneType::setAttribute(SumoXMLAttr key, const std::string& value) {
217 switch (key) {
218 case SUMO_ATTR_ID:
219 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
220 case SUMO_ATTR_SPEED:
221 if (value.empty()) {
222 attrs.erase(key);
223 } else {
224 attrs.insert(key);
225 speed = parse<double>(value);
226 }
227 break;
228 case SUMO_ATTR_ALLOW:
229 // parse permissions
231 // check attrs
232 if ((permissions == SVCAll) || (permissions == -1)) {
233 attrs.insert(SUMO_ATTR_ALLOW);
235 } else if (permissions == 0) {
236 attrs.erase(SUMO_ATTR_ALLOW);
238 } else {
239 attrs.insert(SUMO_ATTR_ALLOW);
241 }
242 break;
244 // parse invert permissions
246 // check attrs
247 if ((permissions == SVCAll) || (permissions == -1)) {
248 attrs.insert(SUMO_ATTR_ALLOW);
250 } else if (permissions == 0) {
251 attrs.erase(SUMO_ATTR_ALLOW);
253 } else {
254 attrs.insert(SUMO_ATTR_ALLOW);
256 }
257 break;
258 case SUMO_ATTR_WIDTH:
259 if (value.empty()) {
260 attrs.erase(key);
261 } else {
262 attrs.insert(key);
263 width = parse<double>(value);
264 }
265 break;
267 setParametersStr(value);
268 break;
269 default:
270 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
271 }
272 // update edge selector
273 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
275 }
276}
277
278
279void
281 // nothing to do
282}
283
284
285void
286GNELaneType::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
287 // nothing to do
288}
289
290/****************************************************************************/
@ GLO_LANE
a lane
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
Definition: GNELaneType.cpp:92
GNEEdgeType * myEdgeTypeParent
pointer to EdgeTypeParent
Definition: GNELaneType.h:132
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNELaneType.cpp:79
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void updateGeometry()
update pre-computed geometry information
Definition: GNELaneType.cpp:73
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.
Definition: GNELaneType.cpp:36
void copyLaneType(GNELaneType *originalLaneType, GNEUndoList *undoList)
copy values of given laneType in current laneType
Definition: GNELaneType.cpp:60
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNELaneType.cpp:86
GNEEdgeType * getEdgeTypeParent() const
get edge type parent
Definition: GNELaneType.cpp:54
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELaneType.cpp:98
~GNELaneType()
Destructor.
Definition: GNELaneType.cpp:49
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:334
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
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:357
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
Definition: Parameterised.h:45
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