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.dev/sumo
3 // Copyright (C) 2001-2024 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 class GUIGlObject;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 
41 
42 public:
43  enum class OperationType {
44  POSITION,
47  WIDTH,
48  HEIGHT,
49  LENGTH,
50  ONE_LANE,
58  };
59 
62  const Position originalPosition);
63 
67 
71  const bool firstGeometryPoint,
73 
77  const std::vector<int> originalgeometryPoints,
79  const std::vector<int> geometryPointsToMove);
80 
83  const GNELane* lane,
84  const double firstPosition,
85  const bool allowChangeLane);
86 
89  const GNELane* lane,
90  const double firstPosition,
91  const double secondPosition,
92  const bool allowChangeLane,
94 
97  const GNELane* firstLane,
98  const double firstStartPos,
99  const GNELane* secondLane,
100  const double secondStartPos,
101  const bool allowChangeLane,
103 
106 
109 
112 
114  const std::vector<int> originalGeometryPoints;
115 
117  const GNELane* firstLane = nullptr;
118 
121 
123  const GNELane* secondLane = nullptr;
124 
127 
132 
134  const std::vector<int> geometryPointsToMove;
135 
137  const bool allowChangeLane;
138 
140  const bool firstGeometryPoint;
141 
144 
145 private:
148 
151 };
152 
155 
156 public:
158  GNEMoveOffset();
159 
161  GNEMoveOffset(const double x, const double y);
162 
164  GNEMoveOffset(const double z);
165 
167  ~GNEMoveOffset();
168 
170  const double x;
171 
173  const double y;
174 
176  const double z;
177 };
178 
181 
182 public:
184  GNEMoveResult(const GNEMoveOperation* moveOperation);
185 
187  ~GNEMoveResult();
188 
190  void clearLanes();
191 
194 
196  std::vector<int> geometryPointsToMove;
197 
200 
203 
206 
208  double newFirstPos;
209 
212 
215 
217  double newSecondPos;
218 
219 private:
221  GNEMoveResult(const GNEMoveResult&) = delete;
222 };
223 
224 
227 
228 public:
230  GNEMoveElement();
231 
233  virtual ~GNEMoveElement() {}
234 
239 
241  virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) = 0;
242 
244  static void moveElement(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset);
245 
247  static void commitMove(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset, GNEUndoList* undoList);
248 
249 protected:
252 
254  GNEMoveOperation* calculateMoveShapeOperation(const GUIGlObject* obj, const PositionVector originalShape, const bool maintainShapeClosed);
255 
256 private:
258  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
259 
261  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
262 
264  static double calculateLaneOffset(const GNEViewNet* viewNet, const GNELane* lane, const double firstPosition, const double secondPosition,
265  const GNEMoveOffset& offset, const double extremFrom, const double extremTo);
266 
268  static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* lane, const double pos,
269  const GNEMoveOffset& offset, const double extremFrom, const double extremTo);
270 
272  static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* lane, const double firstPos,
273  const double secondPos, const GNEMoveOffset& offset);
274 
276  static void calculateMoveResult(GNEMoveResult& moveResult, const GNEViewNet* viewNet, const GNELane* firstLane, const double firstPos,
277  const GNELane* secondLane, const double secondPos, const GNEMoveOffset& offset);
278 
280  static void calculateNewLane(const GNEViewNet* viewNet, const GNELane* originalLane, const GNELane*& newLane, double& laneOffset);
281 
282  // @brief adjust both positions
283  static void adjustBothPositions(const GNEViewNet* viewNet, const GNEMoveOperation* moveOperation, GNEMoveResult& moveResult, const GNEMoveOffset& offset);
284 
286  static PositionVector calculateExtrapolatedVector(const GNEMoveOperation* moveOperation, const GNEMoveResult& moveResult);
287 
289  GNEMoveElement(const GNEMoveElement&) = delete;
290 
293 };
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
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
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
virtual ~GNEMoveElement()
GNEMoveElement(const GNEMoveElement &)=delete
Invalidated copy constructor.
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape 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.