32#define ENDPOINT_TOLERANCE 2
56 const double geometryPointRadius =
myEdge->getGeometryPointRadius();
58 if (
myEdge->isAttributeCarrierSelected()) {
60 if (
myEdge->getFromJunction()->isAttributeCarrierSelected() &&
myEdge->getToJunction()->isAttributeCarrierSelected()) {
62 }
else if (
myEdge->getFromJunction()->isAttributeCarrierSelected()) {
64 }
else if (
myEdge->getToJunction()->isAttributeCarrierSelected()) {
66 }
else if (
myEdge->getNet()->getViewNet()->getMoveMultipleElementValues().isMovingSelectedEdge()) {
67 if (
myEdge->getNet()->getAttributeCarriers()->getNumberOfSelectedEdges() == 1) {
130 const double geometryPointRadius =
myEdge->getGeometryPointRadius();
134 const bool customStartPosition = (
myEdge->getNBEdge()->getGeometry().front().distanceSquaredTo2D(
myEdge->getFromJunction()->getNBNode()->getPosition()) >
ENDPOINT_TOLERANCE);
135 const bool customEndPosition = (
myEdge->getNBEdge()->getGeometry().back().distanceSquaredTo2D(
myEdge->getToJunction()->getNBNode()->getPosition()) >
ENDPOINT_TOLERANCE);
137 const int lastIndex = (int)
myEdge->getNBEdge()->getGeometry().size() - 1;
141 const int index =
myEdge->getNBEdge()->getGeometry().indexOfClosest(clickedPosition,
true);
147 if (shape[index].distanceSquaredTo2D(clickedPosition) > (geometryPointRadius * geometryPointRadius)) {
151 if (!customStartPosition && (index == 0)) {
155 if (!customEndPosition && (index == lastIndex)) {
166 }
else if (index == lastIndex) {
173 shape.erase(shape.begin() + index);
196 innenShape.pop_back();
199 myEdge->setShapeStartPos(shapeStart);
202 myEdge->setGeometry(innenShape,
true);
205 myEdge->setShapeEndPos(shapeEnd);
217 innenShapeToUpdate.pop_back();
225 if (innenShapeToUpdate.size() > 0) {
240 const double squaredSnapRadius = (snapRadius * snapRadius);
244 const int nearestIndex = originalShape.
indexOfClosest(mousePosition);
248 std::vector<int> indexes;
250 if (nearestIndex == -1) {
255 for (
int i = 1; i <= nearestIndex; i++) {
256 indexes.push_back(i);
259 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
263 }
else if (nearestPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= squaredSnapRadius) {
264 for (
int i = 1; i <= nearestIndex; i++) {
265 indexes.push_back(i);
268 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
271 const int newIndex = shapeToMove.
insertAtClosest(nearestPosition,
true);
272 for (
int i = 1; i <= newIndex; i++) {
273 indexes.push_back(i);
276 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
284 const double squaredSnapRadius = (snapRadius * snapRadius);
288 const int nearestIndex = originalShape.
indexOfClosest(mousePosition);
292 std::vector<int> indexes;
294 if (nearestIndex == -1) {
299 for (
int i = nearestIndex; i < ((int)originalShape.size() - 1); i++) {
300 indexes.push_back(i);
303 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
307 }
else if (nearestPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= squaredSnapRadius) {
308 for (
int i = nearestIndex; i < ((int)originalShape.size() - 1); i++) {
309 indexes.push_back(i);
312 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
315 const int newIndex = shapeToMove.
insertAtClosest(nearestPosition,
true);
316 for (
int i = newIndex; i < ((int)originalShape.size() - 1); i++) {
317 indexes.push_back(i);
320 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
327 std::vector<int> geometryPointsToMove;
328 for (
int i = 0; i < (int)
myEdge->getNBEdge()->getGeometry().size(); i++) {
329 geometryPointsToMove.push_back(i);
332 return new GNEMoveOperation(
this,
myEdge->getNBEdge()->getGeometry(), geometryPointsToMove,
myEdge->getNBEdge()->getGeometry(), geometryPointsToMove);
339 const auto& moveMultipleElementValues =
myEdge->getNet()->getViewNet()->getMoveMultipleElementValues();
343 if (shapeToMove.
length2D() < moveMultipleElementValues.getEdgeOffset()) {
349 if (
myEdge->isConvexAngle()) {
350 offset = moveMultipleElementValues.getEdgeOffset();
352 offset = shapeToMove.
length2D() - moveMultipleElementValues.getEdgeOffset();
355 const Position offsetPosition =
myEdge->getNBEdge()->getGeometry().positionAtOffset2D(offset);
357 const int nearestIndex =
myEdge->getNBEdge()->getGeometry().indexOfClosest(offsetPosition);
361 }
else if (offsetPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= (snapRadius * snapRadius)) {
363 return new GNEMoveOperation(
this,
myEdge->getNBEdge()->getGeometry(), {nearestIndex}, shapeToMove, {nearestIndex});
366 const int newIndex = shapeToMove.
insertAtClosest(offsetPosition,
true);
368 return new GNEMoveOperation(
this,
myEdge->getNBEdge()->getGeometry(), {nearestIndex}, shapeToMove, {newIndex});
#define ENDPOINT_TOLERANCE
const std::string invalid_return< std::string >::value
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)
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
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 * getMoveOperation() override
get move operation
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)
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
GNEEdge * getEdge() const
get pointer to edge
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
GNEAttributeCarrier * myMovedElement
pointer to element
GNEMoveElement(GNEAttributeCarrier *movedElement)
constructor
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)
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...
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