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#include <config.h>
21
23#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
25
26#include "GNEMoveElementView.h"
27
28// ===========================================================================
29// Method definitions
30// ===========================================================================
31
33 SumoXMLAttr posAttr, Position& position) :
34 GNEMoveElement(element),
35 myPosAttr(posAttr),
36 myPosOverView(position),
37 myAttributesFormat(attributesFormat) {
38}
39
41
42
45 // move entire space
46 return new GNEMoveOperation(this, myPosOverView);
47}
48
49
50std::string
52 if (key == myPosAttr) {
53 return toString(myPosOverView);
54 } else {
56 }
57}
58
59
60double
64
65
68 if (key == myPosAttr) {
69 return myPosOverView;
70 } else {
72 }
73}
74
75
80
81
82void
83GNEMoveElementView::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
84 if (key == myPosAttr) {
86 } else {
87 myMovedElement->setCommonAttribute(key, value, undoList);
88 }
89}
90
91
92bool
93GNEMoveElementView::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {
94 if (key == myPosAttr) {
95 return GNEAttributeCarrier::canParse<Position>(value);
96 } else {
97 return myMovedElement->isCommonAttributeValid(key, value);
98 }
99}
100
101
102void
104 if (key == myPosAttr) {
105 myPosOverView = GNEAttributeCarrier::parse<Position>(value);
106 } else {
108 }
109}
110
111
112void
113GNEMoveElementView::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
114 // nothing to do here
115}
116
117
118void
120 // position format
123 } else {
124 // x-y format
128 }
129 // geo format
134 device.setPrecision();
135 }
136 // z
137 if (myPosOverView.z() != 0) {
139 }
140 }
141}
142
143
144void
146 myPosOverView = moveResult.shapeToUpdate.front();
147 // update geometry
149}
150
151
152void
154 undoList->begin(myMovedElement, TLF("position of %", myMovedElement->getTagStr()));
156 undoList->end();
157}
158
159/****************************************************************************/
#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
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
GNEMoveOperation * getMoveOperation() override
get move operation
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.