Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEMoveElementView.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 elements that can be moved over view
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
24
25#include "GNEMoveElementView.h"
26
27// ===========================================================================
28// Method definitions
29// ===========================================================================
30
32 SumoXMLAttr posAttr, Position& position) :
33 GNEMoveElement(element),
34 myPosAttr(posAttr),
35 myPosOverView(position),
36 myAttributesFormat(attributesFormat) {
37}
38
40
41
44 // move entire space
45 return new GNEMoveOperation(this, myPosOverView);
46}
47
48
49std::string
51 if (key == myPosAttr) {
52 return toString(myPosOverView);
53 } else {
55 }
56}
57
58
59double
63
64
67 if (key == myPosAttr) {
68 return myPosOverView;
69 } else {
71 }
72}
73
74
79
80
81void
82GNEMoveElementView::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
83 if (key == myPosAttr) {
85 } else {
86 myMovedElement->setCommonAttribute(key, value, undoList);
87 }
88}
89
90
91bool
92GNEMoveElementView::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {
93 if (key == myPosAttr) {
94 return GNEAttributeCarrier::canParse<Position>(value);
95 } else {
96 return myMovedElement->isCommonAttributeValid(key, value);
97 }
98}
99
100
101void
103 if (key == myPosAttr) {
104 myPosOverView = GNEAttributeCarrier::parse<Position>(value);
105 } else {
107 }
108}
109
110
111void
112GNEMoveElementView::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
113 // nothing to do here
114}
115
116
117void
119 // position format
122 } else {
123 // x-y format
127 }
128 // geo format
133 device.setPrecision();
134 }
135 // z
136 if (myPosOverView.z() != 0) {
138 }
139 }
140}
141
142
143void
145 myPosOverView = moveResult.shapeToUpdate.front();
146 // update geometry
148}
149
150
151void
153 undoList->begin(myMovedElement, TLF("position of %", myMovedElement->getTagStr()));
155 undoList->end();
156}
157
158/****************************************************************************/
#define TLF(string,...)
Definition MsgHandler.h:306
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LON
@ SUMO_ATTR_Y
@ SUMO_ATTR_Z
@ SUMO_ATTR_X
@ SUMO_ATTR_LAT
@ SUMO_ATTR_POSITION
int gPrecisionGeo
Definition StdDefs.cpp:29
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
virtual double getAttributeDouble(SumoXMLAttr key) const =0
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
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
virtual void updateGeometry()=0
update pre-computed geometry information
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
GNEAttributeCarrier * myMovedElement
pointer to element
AttributesFormat
attributes format
@ GEO
cartesian format (x, y, z)
AttributesFormat myAttributesFormat
pos attributes format
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
void writeMoveAttributes(OutputDevice &device) const
write move attributes
SumoXMLAttr myPosAttr
pos attribute
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
Position & myPosOverView
position over view
GNEMoveOperation * getMoveOperation()
get move operation
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
GNEMoveElementView(GNEAttributeCarrier *element, AttributesFormat attributesFormat, SumoXMLAttr posAttr, Position &position)
constructor for element with fixed size
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
PositionVector shapeToUpdate
shape to update (edited in moveElement)
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...
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:52
double z() const
Returns the z-position.
Definition Position.h:62
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.