Eclipse SUMO - Simulation of Urban MObility
GNEMoveElement.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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 own a movable shape
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
24
25// ===========================================================================
26// class declaration
27// ===========================================================================
28
29class GNELane;
30class GNEMoveElement;
31class GNEUndoList;
32class GNEViewNet;
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
37
40
41public:
42 enum class OperationType {
43 POSITION,
44 ENTIRE_SHAPE,
45 GEOMETRY_POINTS,
46 WIDTH,
47 HEIGHT,
48 LENGTH,
49 ONE_LANE,
50 ONE_LANE_MOVEFIRST,
51 ONE_LANE_MOVESECOND,
52 ONE_LANE_MOVEBOTH,
53 TWO_LANES_MOVEFIRST,
54 TWO_LANES_MOVESECOND,
55 TWO_LANES_MOVEBOTH_FIRST,
56 TWO_LANES_MOVEBOTH_SECOND,
57 };
58
61 const Position originalPosition);
62
66
70 const bool firstGeometryPoint,
72
76 const std::vector<int> originalgeometryPoints,
78 const std::vector<int> geometryPointsToMove);
79
82 const GNELane* lane,
83 const double firstPosition,
84 const bool allowChangeLane);
85
88 const GNELane* lane,
89 const double firstPosition,
90 const double secondPosition,
91 const bool allowChangeLane,
93
96 const GNELane* firstLane,
97 const double firstStartPos,
98 const GNELane* secondLane,
99 const double secondStartPos,
100 const bool allowChangeLane,
102
105
108
111
113 const std::vector<int> originalGeometryPoints;
114
116 const GNELane* firstLane = nullptr;
117
120
122 const GNELane* secondLane = nullptr;
123
126
131
133 const std::vector<int> geometryPointsToMove;
134
136 const bool allowChangeLane;
137
140
143
144private:
147
150};
151
154
155public:
158
160 GNEMoveOffset(const double x, const double y);
161
163 GNEMoveOffset(const double z);
164
167
169 const double x;
170
172 const double y;
173
175 const double z;
176};
177
180
181public:
183 GNEMoveResult(const GNEMoveOperation* moveOperation);
184
187
189 void clearLanes();
190
193
195 std::vector<int> geometryPointsToMove;
196
199
202
205
208
211
214
217
218private:
220 GNEMoveResult(const GNEMoveResult&) = delete;
221};
222
223
226
227public:
230
232 virtual ~GNEMoveElement() {}
233
238
240 virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) = 0;
241
243 static void moveElement(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset);
244
246 static void commitMove(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset, GNEUndoList* undoList);
247
248protected:
251
253 GNEMoveOperation* calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour);
254
255private:
257 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
258
260 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
261
263 static double calculateLaneOffset(const GNEViewNet* viewNet, const GNELane* lane, const double firstPosition, const double secondPosition,
264 const GNEMoveOffset& offset, const double extremFrom, const double extremTo);
265
267 static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* lane, const double pos,
268 const GNEMoveOffset& offset, const double extremFrom, const double extremTo);
269
271 static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* lane, const double firstPos,
272 const double secondPos, const GNEMoveOffset& offset);
273
275 static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* firstLane, const double firstPos,
276 const GNELane* secondLane, const double secondPos, const GNEMoveOffset& offset);
277
279 static void calculateNewLane(const GNEViewNet* viewNet, const GNELane* originalLane, const GNELane*& newLane, double& laneOffset);
280
281 // @brief adjust both positions
282 static void adjustBothPositions(const GNEViewNet* viewNet, const GNEMoveOperation* moveOperation, GNEMoveResult& moveResult, const GNEMoveOffset& offset);
283
285 static PositionVector calculateExtrapolatedVector(const GNEMoveOperation* moveOperation, const GNEMoveResult& moveResult);
286
289
292};
const double INVALID_DOUBLE
Definition: StdDefs.h:60
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move element
static PositionVector calculateExtrapolatedVector(const GNEMoveOperation *moveOperation, const GNEMoveResult &moveResult)
calculate width/height shape
static void adjustBothPositions(const GNEViewNet *viewNet, const GNEMoveOperation *moveOperation, GNEMoveResult &moveResult, const GNEMoveOffset &offset)
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
GNEMoveElement()
constructor
GNEMoveOperation * calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour)
calculate move shape operation
static void calculateMoveResult(GNEMoveResult &moveResult, const GNEViewNet *viewNet, const GNELane *lane, const double pos, const GNEMoveOffset &offset, const double extremFrom, const double extremTo)
calculate single movement over one lane
static void commitMove(const GNEViewNet *viewNet, GNEMoveOperation *moveOperation, const GNEMoveOffset &offset, GNEUndoList *undoList)
commit move element for the given offset
static double calculateLaneOffset(const GNEViewNet *viewNet, const GNELane *lane, const double firstPosition, const double secondPosition, const GNEMoveOffset &offset, const double extremFrom, const double extremTo)
calculate lane offset
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
GNEMoveElement & operator=(const GNEMoveElement &)=delete
Invalidated assignment operator.
virtual ~GNEMoveElement()
GNEMoveElement(const GNEMoveElement &)=delete
Invalidated copy constructor.
static void calculateNewLane(const GNEViewNet *viewNet, const GNELane *originalLane, const GNELane *&newLane, double &laneOffset)
calculate new lane
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
static void moveElement(const GNEViewNet *viewNet, GNEMoveOperation *moveOperation, const GNEMoveOffset &offset)
move element the for given offset (note: offset can be X-Y-0, 0-0-Z or X-Y-Z)
virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)=0
remove geometry point in the clicked position
move offset
const double z
Z.
const double x
X.
const double y
Y.
GNEMoveOffset()
constructor
~GNEMoveOffset()
destructor
move operation
const OperationType operationType
operation type
GNEMoveOperation & operator=(const GNEMoveOperation &)=delete
Invalidated assignment operator.
const PositionVector originalShape
original shape
const std::vector< int > originalGeometryPoints
original shape points to move (of original shape)
const PositionVector shapeToMove
shape to move
GNEMoveOperation(GNEMoveElement *moveElement, const Position originalPosition)
constructor for values with a single position (junctions, E3, ParkingSpaces...)
~GNEMoveOperation()
destructor
const double secondPosition
original second Position
GNEMoveOperation(const GNEMoveOperation &)=delete
Invalidated copy constructor.
const GNELane * firstLane
original first lane
const GNELane * secondLane
original second lane
const std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
const double firstPosition
original first Position
const bool allowChangeLane
allow change lane
GNEMoveElement * moveElement
move element
const bool firstGeometryPoint
first position (used for edit with/height
move result
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
GNEMoveResult(const GNEMoveOperation *moveOperation)
constructor
GNEMoveResult(const GNEMoveResult &)=delete
Invalidated copy constructor.
~GNEMoveResult()
destructor
const GNELane * newSecondLane
new second Lane
void clearLanes()
clear lanes
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
double newSecondPos
new second position
PositionVector shapeToUpdate
shape to update (edited in moveElement)
double secondLaneOffset
lane offset
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.