Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEMoveElementCrossing.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 crossing shapes
19/****************************************************************************/
20#include <config.h>
21
24#include <netedit/GNENet.h>
25#include <netedit/GNEUndoList.h>
26
28
29// ===========================================================================
30// Method definitions
31// ===========================================================================
32
34 GNEMoveElement(crossing),
35 myCrossing(crossing) {
36}
37
38
40
41
42std::string
46
47
48double
52
53
58
59
64
65
66void
67GNEMoveElementCrossing::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
68 myMovedElement->setCommonAttribute(key, value, undoList);
69}
70
71
72bool
73GNEMoveElementCrossing::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {
74 return myMovedElement->isCommonAttributeValid(key, value);
75}
76
77
78void
82
83
86 // edit depending if shape is being edited
88 // calculate move shape operation
90 } else {
91 return nullptr;
92 }
93}
94
95
96void
98 // edit depending if shape is being edited
100 // get original shape
102 // check shape size
103 if (shape.size() > 2) {
104 // obtain index
105 int index = shape.indexOfClosest(clickedPosition);
106 // get snap radius
108 // check if we have to create a new index
109 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
110 // remove geometry point
111 shape.erase(shape.begin() + index);
112 // commit new shape
113 undoList->begin(myCrossing, TLF("remove geometry point of %", myCrossing->getTagStr()));
115 undoList->end();
116 }
117 }
118 }
119}
120
121
122void
124 // set custom shape
126 // update geometry
128}
129
130
131void
133 // commit new shape
134 undoList->begin(myCrossing, TLF("moving % of %", toString(SUMO_ATTR_CUSTOMSHAPE), myCrossing->getTagStr()));
136 undoList->end();
137}
138
139/****************************************************************************/
#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
NBNode::Crossing * getNBCrossing() const
get referente to NBode::Crossing
const PositionVector & getCrossingShape() const
get Crossing shape
void updateGeometry() override
update pre-computed geometry information
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
GNEMoveOperation * getMoveOperation() override
get move operation
GNEMoveElementCrossing()=delete
invalidate default constructor
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
GNECrossing * myCrossing
pointer to crossing
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
GNEAttributeCarrier * myMovedElement
pointer to element
GNEMoveOperation * getEditShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
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
PositionVector customShape
optional customShape for this crossing
Definition NBNode.h:160
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 crossingGeometryPointRadius
moving crossing geometry point radius