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-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/****************************************************************************/
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
22#include <netedit/GNEViewNet.h>
27
28#include "GNELaneType.h"
29#include "GNEEdgeType.h"
30
31// ===========================================================================
32// members methods
33// ===========================================================================
34
36 GNENetworkElement(edgeTypeParent->getNet(), "", SUMO_TAG_LANETYPE),
37 myEdgeTypeParent(edgeTypeParent) {
38}
39
40
42 GNENetworkElement(edgeTypeParent->getNet(), "", SUMO_TAG_LANETYPE),
43 NBTypeCont::LaneTypeDefinition(laneType),
44 myEdgeTypeParent(edgeTypeParent) {
45}
46
47
50
51
56
57
58void
59GNELaneType::copyLaneType(GNELaneType* originalLaneType, GNEUndoList* undoList) {
60 // copy speed
61 setAttribute(SUMO_ATTR_SPEED, originalLaneType->getAttribute(SUMO_ATTR_SPEED), undoList);
62 // copy allow (and disallow)
63 setAttribute(SUMO_ATTR_ALLOW, originalLaneType->getAttribute(SUMO_ATTR_ALLOW), undoList);
64 // copy width
65 setAttribute(SUMO_ATTR_WIDTH, originalLaneType->getAttribute(SUMO_ATTR_WIDTH), undoList);
66 // copy parameters
68}
69
70
71void
73 // nothing to do
74}
75
76
79 // currently unused
80 return Position(0, 0);
81}
82
83
84bool
86 return false;
87}
88
89
90bool
92 return false;
93}
94
95
96bool
98 return false;
99}
100
101
102bool
104 return false;
105}
106
107bool
109 return false;
110}
111
112
113bool
115 return false;
116}
117
118
119bool
121 return false;
122}
123
124
125bool
127 return false;
128}
129
130
133 return nullptr;
134}
135
136
137void
138GNELaneType::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
139 // nothing to do
140}
141
142
145 return nullptr;
146}
147
148
153
154
155void
156GNELaneType::updateCenteringBoundary(const bool /*updateGrid*/) {
157 // nothing to do
158}
159
160
161void
163 // nothing to draw
164}
165
166
167void
171
172
173void
177
178
179std::string
181 switch (key) {
182 case SUMO_ATTR_ID:
183 return "lane: " + toString(myEdgeTypeParent->getLaneTypeIndex(this));
184 case SUMO_ATTR_SPEED:
185 if (attrs.count(key) == 0) {
186 return toString(OptionsCont::getOptions().getFloat("default.speed"));
187 } else {
188 return toString(speed);
189 }
190 case SUMO_ATTR_ALLOW:
191 if ((permissions == SVCAll) || (permissions == -1)) {
192 return "all";
193 } else if (permissions == 0) {
194 return "";
195 } else {
197 }
199 if (permissions == 0) {
200 return "all";
201 } else if ((permissions == SVCAll) || (permissions == -1)) {
202 return "";
203 } else {
205 }
206 case SUMO_ATTR_WIDTH:
207 if (attrs.count(key) == 0) {
208 return "default";
209 } else {
210 return toString(width);
211 }
213 if (attrs.count(key) == 0) {
214 return "";
215 } else {
216 return toString(width);
217 }
218 default:
219 return getCommonAttribute(this, key);
220 }
221}
222
223
226 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
227}
228
229
230void
231GNELaneType::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
232 throw InvalidArgument("laneType attributes cannot be edited here");
233}
234
235
236bool
237GNELaneType::isValid(SumoXMLAttr key, const std::string& value) {
238 switch (key) {
239 case SUMO_ATTR_ID:
240 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
241 case SUMO_ATTR_SPEED:
242 if (value.empty() || (value == "default")) {
243 return true;
244 } else {
245 return canParse<double>(value) && (parse<double>(value) > 0);
246 }
247 case SUMO_ATTR_ALLOW:
249 return canParseVehicleClasses(value);
250 case SUMO_ATTR_WIDTH:
251 if (value.empty() || (value == "-1") || (value == "default")) {
252 return true;
253 } else {
254 return canParse<double>(value);
255 }
256 default:
257 return isCommonValid(key, value);
258 }
259}
260
261
266
267// ===========================================================================
268// private
269// ===========================================================================
270
271void
272GNELaneType::setAttribute(SumoXMLAttr key, const std::string& value) {
273 switch (key) {
274 case SUMO_ATTR_ID:
275 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
276 case SUMO_ATTR_SPEED:
277 if (value.empty() || (value == "default")) {
278 attrs.erase(key);
279 } else {
280 attrs.insert(key);
281 speed = parse<double>(value);
282 }
283 break;
284 case SUMO_ATTR_ALLOW:
285 // parse permissions
287 // check attrs
288 if ((permissions == SVCAll) || (permissions == -1)) {
289 attrs.insert(SUMO_ATTR_ALLOW);
291 } else if (permissions == 0) {
292 attrs.erase(SUMO_ATTR_ALLOW);
294 } else {
295 attrs.insert(SUMO_ATTR_ALLOW);
297 }
298 break;
300 // parse invert permissions
302 // check attrs
303 if ((permissions == SVCAll) || (permissions == -1)) {
304 attrs.insert(SUMO_ATTR_ALLOW);
306 } else if (permissions == 0) {
307 attrs.erase(SUMO_ATTR_ALLOW);
309 } else {
310 attrs.insert(SUMO_ATTR_ALLOW);
312 }
313 break;
314 case SUMO_ATTR_WIDTH:
315 if (value.empty() || (value == "-1") || (value == "default")) {
316 attrs.erase(key);
317 } else {
318 attrs.insert(key);
319 width = parse<double>(value);
320 }
321 break;
322 default:
323 setCommonAttribute(this, key, value);
324 break;
325 }
326 // update edge selector
327 if (myNet->getViewNet()->getViewParent()->getCreateEdgeFrame()->shown()) {
329 }
330}
331
332
333void
335 // nothing to do
336}
337
338
339void
340GNELaneType::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
341 // nothing to do
342}
343
344/****************************************************************************/
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
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
std::string getCommonAttribute(const Parameterised *parameterised, 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
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) const
void refreshAttributesEditor()
refresh attribute editor
Boundary getContourBoundary() const
get contour boundary
GNEAttributesEditor * getLaneTypeAttributes() const
get laneType attributes
int getLaneTypeIndex(const GNELaneType *laneType) const
get laneType index
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
GNEEdgeType * myEdgeTypeParent
pointer to EdgeTypeParent
PositionVector getAttributePositionVector(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool checkDrawOverContour() const
check if draw over contour (orange)
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 checkDrawMoveContour() const
check if draw move contour (red)
bool isValid(SumoXMLAttr key, const std::string &value)
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
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
bool checkDrawSelectContour() const
check if draw select contour (blue)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
~GNELaneType()
Destructor.
bool checkDrawToContour() const
check if draw from contour (magenta)
void updateGLObject()
update GLObject (geometry, ID, etc.)
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
bool checkDrawFromContour() const
check if draw from contour (green)
move operation
move result
void deleteNetworkElement(GNENetworkElement *networkElement, GNEUndoList *undoList)
delete network element
Definition GNENet.cpp:373
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
GNEContour myNetworkElementContour
network element contour
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.
A storage for available edgeTypes of edges.
Definition NBTypeCont.h:52
static OptionsCont & getOptions()
Retrieves the options.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
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