32 myMovedElement(movedElement) {
71 const bool maintainShapeClosed) {
78 const int lastIndex = (int)shapeToMove.size() - 1;
80 if (geometryPoints.size() > 0) {
82 if (maintainShapeClosed && ((geometryPoints.front() == 0) || (geometryPoints.front() == lastIndex))) {
84 return new GNEMoveOperation(
this, originalShape, {0, lastIndex}, shapeToMove, {0, lastIndex});
86 return new GNEMoveOperation(
this, originalShape, {geometryPoints.front()}, shapeToMove, {geometryPoints.front()});
149 throw ProcessError(
"trying to move an invalid position");
159 geometryPointIndex.
add(offset.
x, offset.
y, offset.
z);
163 throw ProcessError(
"trying to move an invalid position");
245 throw ProcessError(
"trying to move an invalid position");
257 geometryPointIndex.add(offset.
x, offset.
y, offset.
z);
261 throw ProcessError(
"trying to move an invalid position");
284 double laneOffset = 0;
286 const double offsetCentralPosition = (firstPosition + lastPosition) * 0.5;
288 const double middleLength = std::abs(lastPosition - firstPosition) * 0.5;
292 laneCentralPosition.
add(offset.
x, offset.
y, offset.
z);
298 if (offsetLaneCentralPositionPerpendicular == -1) {
302 if (offsetLaneCentralPosition == 0) {
303 laneOffset = firstPosition;
305 laneOffset = lastPosition - laneShapeLength;
309 if ((offsetLaneCentralPositionPerpendicular - middleLength) < 0) {
310 laneOffset = firstPosition;
311 }
else if ((offsetLaneCentralPositionPerpendicular + middleLength) > laneShapeLength) {
312 laneOffset = lastPosition - laneShapeLength;
314 laneOffset = (offsetCentralPosition - offsetLaneCentralPositionPerpendicular);
333 const double firstPosOverLane,
const double lastPosOverLane,
const GNEMoveOffset& offset) {
335 const double laneOffset =
calculateLaneOffset(viewNet, lane, firstPosOverLane, lastPosOverLane, offset);
344 const double firstPosOverLane,
const GNELane* lastLane,
const double lastPosOverLane,
347 double laneOffset = 0;
349 if (firstLaneClicked) {
353 laneOffset = (starPos - firstPosOverLane);
355 endPos = lastPosOverLane + laneOffset;
358 if (endPos > lastLaneLength) {
359 laneOffset = (lastLaneLength - lastPosOverLane);
362 laneOffset = (0 - lastPosOverLane);
368 laneOffset = (endPos - lastPosOverLane);
370 starPos = firstPosOverLane + laneOffset;
373 if (starPos > firstLaneLength) {
374 laneOffset = (firstLaneLength - firstPosOverLane);
377 laneOffset = (0 - firstPosOverLane);
381 starPos = firstPosOverLane + laneOffset;
382 endPos = lastPosOverLane + laneOffset;
393 if (lane != originalLane) {
395 const double offSet = lane->getLaneShape().nearest_offset_to_point2D(cursorPosition,
true);
397 const Position posOverLane = lane->getLaneShape().positionAtOffset2D(offSet);
407 laneOffset = posOverLane.
distanceTo2D(posOverMoveOperationLane);
430 double extrapolateValue = (10e5 - offset);
433 if (extrapolateValue < halfLength) {
434 extrapolateValue = (halfLength - POSITION_EPS);
437 if (extrapolateValue > halfLength) {
438 extrapolateValue = (halfLength - POSITION_EPS);
447 return extrapolatedShape;
449 return extrapolatedShape.
reverse();
GUIViewObjectsHandler gViewObjectsHandler
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const double INVALID_DOUBLE
invalid double
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const PositionVector & getLaneShape() const
get elements shape
double getLengthGeometryFactor() const
get length geometry factor
int getIndex() const
returns the index of the lane
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
static void calculateLanePositions(double &starPos, double &endPos, const GNEViewNet *viewNet, const GNELane *lane, const double firstPosOverLane, const double lastPosOverLane, const GNEMoveOffset &offset)
calculate lane position over one lane with two positions (stoppingPlaces, E2 single lanes)
GNEAttributeCarrier * myMovedElement
pointer to element
virtual ~GNEMoveElement()
static void commitMove(const GNEViewNet *viewNet, GNEMoveOperation *moveOperation, const GNEMoveOffset &offset, GNEUndoList *undoList)
commit move element for the given offset
static void calculateLanePosition(double &starPos, const GNEViewNet *viewNet, const GNELane *lane, const double posOverLane, const GNEMoveOffset &offset)
calculate lane position over one lane with only one position (accesss, E1, star/end positions,...
virtual double getMovingAttributeDouble(SumoXMLAttr key) const =0
get moving attribute double
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
virtual std::string getMovingAttribute(SumoXMLAttr key) const =0
get moving attribute
static void calculateNewLaneChange(const GNEViewNet *viewNet, const GNELane *originalLane, const GNELane *&newLane, double &laneOffset)
calculate new lane change
virtual void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
set moving attribute (using undo-list)
GNEMoveElement()=delete
invalidate default constructor
GNEMoveOperation * getEditShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
virtual bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const =0
check if the given moving attribute is valid
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)
static double calculateLaneOffset(const GNEViewNet *viewNet, const GNELane *lane, const double firstPosition, const double lastPosition, const GNEMoveOffset &offset)
calculate lane offset (used in calculateLanePosition)
bool getMergeGeometryPoints() const
check if merge geometry points
CommonMoveOptions * getCommonMoveOptions() const
get common mode options
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
const bool clickedFirstLane
@check if clicked the first lane or the last lane (used only in multilane elements like E2)
const GNELane * lastLane
original last lane
const double lastPosition
original last Position
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
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
const GNELane * newLastLane
new last Lane
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
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
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