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 
29 class GNELane;
30 class GNEMoveElement;
31 class GNEUndoList;
32 class GNEViewNet;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
37 
40 
41 public:
42  enum class OperationType {
43  POSITION,
46  WIDTH,
47  HEIGHT,
48  LENGTH,
49  ONE_LANE,
56  };
57 
60  const Position originalPosition);
61 
65 
69  const bool firstGeometryPoint,
71 
75  const std::vector<int> originalgeometryPoints,
77  const std::vector<int> geometryPointsToMove);
78 
81  const GNELane* lane,
82  const double firstPosition,
83  const bool allowChangeLane);
84 
87  const GNELane* lane,
88  const double firstPosition,
89  const double secondPosition,
90  const bool allowChangeLane,
92 
95  const GNELane* firstLane,
96  const double firstStartPos,
97  const GNELane* secondLane,
98  const double secondStartPos,
99  const bool allowChangeLane,
101 
104 
107 
110 
112  const std::vector<int> originalGeometryPoints;
113 
115  const GNELane* firstLane = nullptr;
116 
119 
121  const GNELane* secondLane = nullptr;
122 
125 
130 
132  const std::vector<int> geometryPointsToMove;
133 
135  const bool allowChangeLane;
136 
138  const bool firstGeometryPoint;
139 
142 
143 private:
146 
149 };
150 
153 
154 public:
156  GNEMoveOffset();
157 
159  GNEMoveOffset(const double x, const double y);
160 
162  GNEMoveOffset(const double z);
163 
165  ~GNEMoveOffset();
166 
168  const double x;
169 
171  const double y;
172 
174  const double z;
175 };
176 
179 
180 public:
182  GNEMoveResult(const GNEMoveOperation* moveOperation);
183 
185  ~GNEMoveResult();
186 
188  void clearLanes();
189 
192 
194  std::vector<int> geometryPointsToMove;
195 
198 
201 
204 
206  double newFirstPos;
207 
210 
213 
215  double newSecondPos;
216 
217 private:
219  GNEMoveResult(const GNEMoveResult&) = delete;
220 };
221 
222 
225 
226 public:
228  GNEMoveElement();
229 
234 
236  virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) = 0;
237 
239  static void moveElement(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset);
240 
242  static void commitMove(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset, GNEUndoList* undoList);
243 
244 protected:
247 
249  GNEMoveOperation* calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour);
250 
251 private:
253  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
254 
256  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
257 
259  static double calculateLaneOffset(const GNEViewNet* viewNet, const GNELane* lane, const double firstPosition, const double secondPosition,
260  const GNEMoveOffset& offset, const double extremFrom, const double extremTo);
261 
263  static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* lane, const double pos,
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 firstPos,
268  const double secondPos, const GNEMoveOffset& offset);
269 
271  static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* firstLane, const double firstPos,
272  const GNELane* secondLane, const double secondPos, const GNEMoveOffset& offset);
273 
275  static void calculateNewLane(const GNEViewNet* viewNet, const GNELane* originalLane, const GNELane*& newLane, double& laneOffset);
276 
278  static PositionVector calculateExtrapolatedVector(const GNEMoveOperation* moveOperation, const GNEMoveResult& moveResult);
279 
281  GNEMoveElement(const GNEMoveElement&) = delete;
282 
285 };
const double INVALID_DOUBLE
Definition: StdDefs.h:63
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
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(const GNEMoveElement &)=delete
Invalidated copy constructor.
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
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
GNEMoveElement & operator=(const GNEMoveElement &)=delete
Invalidated assignment operator.
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
const PositionVector originalShape
original shape
const std::vector< int > originalGeometryPoints
original shape points to move (of original shape)
GNEMoveOperation & operator=(const GNEMoveOperation &)=delete
Invalidated assignment operator.
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.