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 _secondPosition,
98 const bool _allowChangeLane,
100 moveElement(_moveElement),
102 firstPosition(_firstPosition * _lane->getLengthGeometryFactor()),
103 secondPosition(_secondPosition * _lane->getLengthGeometryFactor()),
104 allowChangeLane(_allowChangeLane),
105 firstGeometryPoint(false),
106 operationType(_operationType) {
112 const double _firstStartPos,
114 const double _secondStartPos,
115 const bool _allowChangeLane,
117 moveElement(_moveElement),
118 firstLane(_firstLane),
120 secondLane(_secondLane),
122 allowChangeLane(_allowChangeLane),
123 firstGeometryPoint(false),
124 operationType(_operationType) {
162 operationType(moveOperation->operationType),
164 newFirstLane(nullptr),
167 newSecondLane(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()});
279 throw ProcessError(
"trying to move an invalid position");
289 geometryPointIndex.
add(offset.
x, offset.
y, offset.
z);
293 throw ProcessError(
"trying to move an invalid position");
402 throw ProcessError(
"trying to move an invalid position");
414 geometryPointIndex.add(offset.
x, offset.
y, offset.
z);
418 throw ProcessError(
"trying to move an invalid position");
437 const GNEMoveOffset& offset,
const double extremFrom,
const double extremTo) {
439 double laneOffset = 0;
441 const double offsetCentralPosition = (firstPosition + secondPosition) * 0.5;
443 const double middleLength = std::abs(secondPosition - firstPosition) * 0.5;
447 laneCentralPosition.
add(offset.
x, offset.
y, offset.
z);
453 if (offsetLaneCentralPositionPerpendicular == -1) {
457 if (offsetLaneCentralPosition == 0) {
458 laneOffset = firstPosition;
464 if ((offsetLaneCentralPositionPerpendicular - middleLength) < extremFrom) {
465 laneOffset = firstPosition + extremFrom;
466 }
else if ((offsetLaneCentralPositionPerpendicular + middleLength) > extremTo) {
467 laneOffset = secondPosition - extremTo;
469 laneOffset = (offsetCentralPosition - offsetLaneCentralPositionPerpendicular);
478 const double pos,
const GNEMoveOffset& offset,
const double extremFrom,
const double extremTo) {
480 const double laneOffset =
calculateLaneOffset(viewNet, lane, pos, pos, offset, extremFrom, extremTo);
489 const double firstPos,
const double secondPos,
const GNEMoveOffset& offset) {
500 const double firstPos,
const GNELane* secondLane,
const double secondPos,
const GNEMoveOffset& offset) {
516 if (lane != originalLane) {
518 const double offSet = lane->getLaneShape().nearest_offset_to_point2D(cursorPosition,
true);
520 const Position posOverLane = lane->getLaneShape().positionAtOffset2D(offSet);
530 laneOffset = posOverLane.
distanceTo2D(posOverMoveOperationLane);
555 }
else if (moveResult.
newSecondPos > secondLaneLength) {
571 }
else if (moveResult.
newFirstPos > firstLaneLength) {
593 double extrapolateValue = (10e5 - offset);
596 if (extrapolateValue < halfLength) {
597 extrapolateValue = (halfLength - POSITION_EPS);
600 if (extrapolateValue > halfLength) {
601 extrapolateValue = (halfLength - POSITION_EPS);
610 return extrapolatedShape;
612 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
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
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
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...)
~GNEMoveOperation()
destructor
const double secondPosition
original second Position
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
@ TWO_LANES_MOVEBOTH_SECOND
@ TWO_LANES_MOVEBOTH_FIRST
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
GNEMoveResult(const GNEMoveOperation *moveOperation)
constructor
~GNEMoveResult()
destructor
const GNELane * newSecondLane
new second Lane
void clearLanes()
clear lanes
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
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.