31#define ENDPOINT_TOLERANCE 2
140 if (shape[index].distanceSquaredTo2D(clickedPosition) > (geometryPointRadius * geometryPointRadius)) {
144 if (!customStartPosition && (index == 0)) {
148 if (!customEndPosition && (index == lastIndex)) {
159 }
else if (index == lastIndex) {
166 shape.erase(shape.begin() + index);
189 innenShape.pop_back();
210 innenShapeToUpdate.pop_back();
218 if (innenShapeToUpdate.size() > 0) {
233 const double squaredSnapRadius = (snapRadius * snapRadius);
237 const int nearestIndex = originalShape.
indexOfClosest(mousePosition);
241 std::vector<int> indexes;
243 if (nearestIndex == -1) {
248 for (
int i = 1; i <= nearestIndex; i++) {
249 indexes.push_back(i);
252 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
256 }
else if (nearestPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= squaredSnapRadius) {
257 for (
int i = 1; i <= nearestIndex; i++) {
258 indexes.push_back(i);
261 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
264 const int newIndex = shapeToMove.
insertAtClosest(nearestPosition,
true);
265 for (
int i = 1; i <= newIndex; i++) {
266 indexes.push_back(i);
269 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
277 const double squaredSnapRadius = (snapRadius * snapRadius);
281 const int nearestIndex = originalShape.
indexOfClosest(mousePosition);
285 std::vector<int> indexes;
287 if (nearestIndex == -1) {
292 for (
int i = nearestIndex; i < ((int)originalShape.size() - 1); i++) {
293 indexes.push_back(i);
296 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
300 }
else if (nearestPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= squaredSnapRadius) {
301 for (
int i = nearestIndex; i < ((int)originalShape.size() - 1); i++) {
302 indexes.push_back(i);
305 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
308 const int newIndex = shapeToMove.
insertAtClosest(nearestPosition,
true);
309 for (
int i = newIndex; i < ((int)originalShape.size() - 1); i++) {
310 indexes.push_back(i);
313 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
320 std::vector<int> geometryPointsToMove;
322 geometryPointsToMove.push_back(i);
336 if (shapeToMove.
length2D() < moveMultipleElementValues.getEdgeOffset()) {
343 offset = moveMultipleElementValues.getEdgeOffset();
345 offset = shapeToMove.
length2D() - moveMultipleElementValues.getEdgeOffset();
354 }
else if (offsetPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= (snapRadius * snapRadius)) {
359 const int newIndex = shapeToMove.
insertAtClosest(offsetPosition,
true);
#define ENDPOINT_TOLERANCE
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ GNE_ATTR_SHAPE_END
last coordinate of edge shape
@ GNE_ATTR_SHAPE_START
first coordinate of edge shape
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
double getCommonAttributeDouble(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * getNet() const
get pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) const
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
bool isConvexAngle() const
check if edge makes a convex angle [0 - 180) degrees
double getGeometryPointRadius() const
get geometry point radius
NBEdge * getNBEdge() const
returns the internal NBEdge
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
void setShapeStartPos(const Position &pos)
change Shape StartPos
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
void setShapeEndPos(const Position &pos)
change Shape EndPos
NBNode * getNBNode() const
Return net build node.
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
GNEMoveOperation * processMoveFromJunctionSelected(const PositionVector originalShape, const Position mousePosition, const double snapRadius)
process moving edge when only from junction is selected
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
GNEMoveOperation * processMoveToJunctionSelected(const PositionVector originalShape, const Position mousePosition, const double snapRadius)
process moving edge when only to junction is selected
GNEMoveElementEdge()=delete
invalidate default constructor
GNEMoveOperation * processNoneJunctionSelected(const double snapRadius)
process moving edge when none junction are selected
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
GNEMoveOperation * getMoveOperation()
get move operation
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
GNEEdge * myEdge
pointer to edge
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
GNEMoveOperation * processMoveBothJunctionSelected()
process moving edge when both junctions are selected
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
GNEAttributeCarrier * myMovedElement
pointer to element
GNEMoveOperation * getEditShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
PositionVector shapeToUpdate
shape to update (edited in moveElement)
int getNumberOfSelectedEdges() const
get number of selected edges
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
GNEViewNet * getViewNet() const
get view net
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GNEViewNetHelper::MoveMultipleElementModul & getMoveMultipleElementValues() const
get move multiple element values
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
const Position & getPosition() const
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 length2D() const
Returns the length.
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
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.
void pop_front()
pop first Position
bool isMovingSelectedEdge() const
flag for moving edge