34 moveElement(_moveElement),
35 originalShape({_originalPosition}),
36 shapeToMove({_originalPosition}),
37 allowChangeLane(
false),
38 firstGeometryPoint(
false),
39operationType(OperationType::POSITION) {
45 moveElement(_moveElement),
46 originalShape(_originalShape),
47 shapeToMove(_originalShape),
48 allowChangeLane(false),
49 firstGeometryPoint(false),
55 const bool _firstGeometryPoint,
57 moveElement(_moveElement),
58 originalShape(_originalShape),
59 shapeToMove(_originalShape),
60 allowChangeLane(false),
61 firstGeometryPoint(_firstGeometryPoint),
62 operationType(_operationType) {
67 const std::vector<int> _originalgeometryPoints,
69 const std::vector<int> _geometryPointsToMove) :
70 moveElement(_moveElement),
71 originalShape(_originalShape),
72 originalGeometryPoints(_originalgeometryPoints),
73 shapeToMove(_shapeToMove),
74 geometryPointsToMove(_geometryPointsToMove),
75 allowChangeLane(false),
76 firstGeometryPoint(false),
83 const double _firstPosition,
84 const bool _allowChangeLane) :
85 moveElement(_moveElement),
87 firstPosition(_firstPosition * _lane->getLengthGeometryFactor()),
88 allowChangeLane(_allowChangeLane),
89 firstGeometryPoint(false),
96 const double _firstPosition,
97 const double _lastPosition,
98 const bool _allowChangeLane,
100 moveElement(_moveElement),
102 firstPosition(_firstPosition * _lane->getLengthGeometryFactor()),
103 lastPosition(_lastPosition * _lane->getLengthGeometryFactor()),
104 allowChangeLane(_allowChangeLane),
105 firstGeometryPoint(false),
106 operationType(_operationType) {
112 const double _firstStartPos,
114 const double _lastStartPos,
115 const bool _allowChangeLane,
117 moveElement(_moveElement),
118 firstLane(_firstLane),
122 allowChangeLane(_allowChangeLane),
123 firstGeometryPoint(false),
124 operationType(_operationType) {
162 operationType(moveOperation->operationType),
164 newFirstLane(nullptr),
167 newLastLane(nullptr),
187 myMoveElementLateralOffset(0) {
193 const bool maintainShapeClosed) {
200 const int lastIndex = (int)shapeToMove.size() - 1;
202 if (geometryPoints.size() > 0) {
204 if (maintainShapeClosed && ((geometryPoints.front() == 0) || (geometryPoints.front() == lastIndex))) {
206 return new GNEMoveOperation(
this, originalShape, {0, lastIndex}, shapeToMove, {0, lastIndex});
208 return new GNEMoveOperation(
this, originalShape, {geometryPoints.front()}, shapeToMove, {geometryPoints.front()});
278 throw ProcessError(
"trying to move an invalid position");
288 geometryPointIndex.
add(offset.
x, offset.
y, offset.
z);
292 throw ProcessError(
"trying to move an invalid position");
387 throw ProcessError(
"trying to move an invalid position");
399 geometryPointIndex.add(offset.
x, offset.
y, offset.
z);
403 throw ProcessError(
"trying to move an invalid position");
422 const GNEMoveOffset& offset,
const double extremFrom,
const double extremTo) {
424 double laneOffset = 0;
426 const double offsetCentralPosition = (firstPosition + lastPosition) * 0.5;
428 const double middleLength = std::abs(lastPosition - firstPosition) * 0.5;
432 laneCentralPosition.
add(offset.
x, offset.
y, offset.
z);
438 if (offsetLaneCentralPositionPerpendicular == -1) {
442 if (offsetLaneCentralPosition == 0) {
443 laneOffset = firstPosition;
449 if ((offsetLaneCentralPositionPerpendicular - middleLength) < extremFrom) {
450 laneOffset = firstPosition + extremFrom;
451 }
else if ((offsetLaneCentralPositionPerpendicular + middleLength) > extremTo) {
452 laneOffset = lastPosition - extremTo;
454 laneOffset = (offsetCentralPosition - offsetLaneCentralPositionPerpendicular);
463 const double pos,
const GNEMoveOffset& offset,
const double extremFrom,
const double extremTo) {
465 const double laneOffset =
calculateLaneOffset(viewNet, lane, pos, pos, offset, extremFrom, extremTo);
474 const double firstPos,
const double lastPos,
const GNEMoveOffset& offset) {
485 const double firstPos,
const GNELane* lastLane,
const double lastPos,
const GNEMoveOffset& offset) {
501 if (lane != originalLane) {
503 const double offSet = lane->getLaneShape().nearest_offset_to_point2D(cursorPosition,
true);
505 const Position posOverLane = lane->getLaneShape().positionAtOffset2D(offSet);
515 laneOffset = posOverLane.
distanceTo2D(posOverMoveOperationLane);
538 double extrapolateValue = (10e5 - offset);
541 if (extrapolateValue < halfLength) {
542 extrapolateValue = (halfLength - POSITION_EPS);
545 if (extrapolateValue > halfLength) {
546 extrapolateValue = (halfLength - POSITION_EPS);
555 return extrapolatedShape;
557 return extrapolatedShape.
reverse();
GUIViewObjectsHandler gViewObjectsHandler
const double INVALID_DOUBLE
invalid double
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
const PositionVector & getLaneShape() const
get elements shape
double getLengthGeometryFactor() const
get length geometry factor
int getIndex() const
returns the index of the lane
double getLaneShapeLength() const
returns the length of the lane's shape
GNEEdge * getParentEdge() const
get parent edge
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
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
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
static void calculateNewLaneChange(const GNEViewNet *viewNet, const GNELane *originalLane, const GNELane *&newLane, double &laneOffset)
calculate new lane change
static double calculateLaneOffset(const GNEViewNet *viewNet, const GNELane *lane, const double firstPosition, const double lastPosition, const GNEMoveOffset &offset, const double extremFrom, const double extremTo)
calculate lane offset
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape 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)
bool getMergeGeometryPoints() const
check if merge geometry points
CommonModeOptions * getCommonModeOptions() const
get common mode options
GNEMoveOffset()
constructor
~GNEMoveOffset()
destructor
const OperationType operationType
operation type
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...)
const GNELane * lastLane
original last lane
const double lastPosition
original last Position
~GNEMoveOperation()
destructor
const GNELane * firstLane
original first lane
const std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
const double firstPosition
original first Position
const bool allowChangeLane
allow change lane
@ MULTIPLE_LANES_MOVE_BOTH_LAST
@ MULTIPLE_LANES_MOVE_FIRST
@ MULTIPLE_LANES_MOVE_BOTH_FIRST
@ MULTIPLE_LANES_MOVE_LAST
GNEMoveElement * moveElement
move element
const bool firstGeometryPoint
first position (used for edit with/height
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
double lastLaneOffset
lane offset
const GNELane * newLastLane
new last Lane
GNEMoveResult(const GNEMoveOperation *moveOperation)
constructor
~GNEMoveResult()
destructor
void clearLanes()
clear lanes
double firstLaneOffset
lane offset
std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
double newLastPos
new last position
PositionVector shapeToUpdate
shape to update (edited in moveElement)
GNEViewParent * getViewParent() const
get the net object
GNEMoveFrame * getMoveFrame() const
get frame for move elements
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
const Position & getSelectedPositionOverShape(const GUIGlObject *GLObject) const
get position over shape
const std::vector< int > & getSelectedGeometryPoints(const GUIGlObject *GLObject) const
get geometry points for the given glObject
A point in 2D or 3D with translation and scaling methods.
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void add(const Position &pos)
Adds the given position to this one.
double length2D() const
Returns the length.
void add(double xoff, double yoff, double zoff)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
int indexOfClosest(const Position &p, bool twoD=false) const
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
int insertAtClosest(const Position &p, bool interpolateZ)
inserts p between the two closest positions
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false, int beginOffset=0, int endOffset=0, bool resample=false)
Removes positions if too near.
PositionVector reverse() const
reverse position vector
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.