Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEMoveElementLane.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// Class used for moving lane shapes
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
24
25#include "GNEMoveElementLane.h"
26
27// ===========================================================================
28// Method definitions
29// ===========================================================================
30
32 GNEMoveElement(lane),
33 myLane(lane) {
34}
35
36
38
39
42 // edit depending if shape is being edited
43 if (myLane->isShapeEdited()) {
44 // calculate move shape operation
46 } else {
47 return nullptr;
48 }
49}
50
51
52std::string
56
57
58double
62
63
68
69
74
75
76void
77GNEMoveElementLane::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
78 myMovedElement->setCommonAttribute(key, value, undoList);
79}
80
81
82bool
83GNEMoveElementLane::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {
84 return myMovedElement->isCommonAttributeValid(key, value);
85}
86
87
88void
91}
92
93
94void
96 // edit depending if shape is being edited
97 if (myLane->isShapeEdited()) {
98 // get original shape
100 // check shape size
101 if (shape.size() > 2) {
102 // obtain index
103 int index = shape.indexOfClosest(clickedPosition);
104 // get snap radius
106 // check if we have to create a new index
107 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
108 // remove geometry point
109 shape.erase(shape.begin() + index);
110 // commit new shape
111 undoList->begin(myLane, TLF("remove geometry point of %", myLane->getTagStr()));
113 undoList->end();
114 }
115 }
116 }
117}
118
119
120void
122 // set custom shape
123 myLane->getParentEdges().front()->getNBEdge()->getLaneStruct(myLane->getIndex()).customShape = moveResult.shapeToUpdate;
124 // update geometry
126}
127
128
129void
131 // commit new shape
132 undoList->begin(myLane, TLF("moving custom shape of %", myLane->getTagStr()));
134 undoList->end();
135}
136
137/****************************************************************************/
#define TLF(string,...)
Definition MsgHandler.h:306
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_CUSTOMSHAPE
whether a given shape is user-defined
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
double getCommonAttributeDouble(SumoXMLAttr key) const
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
GNENet * getNet() const
get 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< GNEEdge * > & getParentEdges() const
get parent edges
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:232
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:624
void updateGeometry() override
update pre-computed geometry information
Definition GNELane.cpp:260
GNEAttributeCarrier * myMovedElement
pointer to element
GNEMoveOperation * getEditShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
GNEMoveOperation * getMoveOperation()
get move operation
GNEMoveElementLane()=delete
invalidate default constructor
GNELane * myLane
pointer to lane
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
PositionVector shapeToUpdate
shape to update (edited in moveElement)
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
bool isShapeEdited() const
check if shape is being edited
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
int indexOfClosest(const Position &p, bool twoD=false) const
static const double laneGeometryPointRadius
moving lane geometry point radius