32#define ENDPOINT_TOLERANCE 2
50 const double geometryPointRadius =
myEdge->getGeometryPointRadius();
52 if (
myEdge->isAttributeCarrierSelected()) {
54 if (
myEdge->getFromJunction()->isAttributeCarrierSelected() &&
myEdge->getToJunction()->isAttributeCarrierSelected()) {
56 }
else if (
myEdge->getFromJunction()->isAttributeCarrierSelected()) {
58 }
else if (
myEdge->getToJunction()->isAttributeCarrierSelected()) {
60 }
else if (
myEdge->getNet()->getViewNet()->getMoveMultipleElementValues().isMovingSelectedEdge()) {
61 if (
myEdge->getNet()->getAttributeCarriers()->getNumberOfSelectedEdges() == 1) {
124 const double geometryPointRadius =
myEdge->getGeometryPointRadius();
128 const bool customStartPosition = (
myEdge->getNBEdge()->getGeometry().front().distanceSquaredTo2D(
myEdge->getFromJunction()->getNBNode()->getPosition()) >
ENDPOINT_TOLERANCE);
129 const bool customEndPosition = (
myEdge->getNBEdge()->getGeometry().back().distanceSquaredTo2D(
myEdge->getToJunction()->getNBNode()->getPosition()) >
ENDPOINT_TOLERANCE);
131 const int lastIndex = (int)
myEdge->getNBEdge()->getGeometry().size() - 1;
135 const int index =
myEdge->getNBEdge()->getGeometry().indexOfClosest(clickedPosition,
true);
141 if (shape[index].distanceSquaredTo2D(clickedPosition) > (geometryPointRadius * geometryPointRadius)) {
145 if (!customStartPosition && (index == 0)) {
149 if (!customEndPosition && (index == lastIndex)) {
160 }
else if (index == lastIndex) {
167 shape.erase(shape.begin() + index);
190 innenShape.pop_back();
193 myEdge->setShapeStartPos(shapeStart);
196 myEdge->setGeometry(innenShape,
true);
199 myEdge->setShapeEndPos(shapeEnd);
211 innenShapeToUpdate.pop_back();
219 if (innenShapeToUpdate.size() > 0) {
234 const double squaredSnapRadius = (snapRadius * snapRadius);
238 const int nearestIndex = originalShape.
indexOfClosest(mousePosition);
242 std::vector<int> indexes;
244 if (nearestIndex == -1) {
249 for (
int i = 1; i <= nearestIndex; i++) {
250 indexes.push_back(i);
253 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
257 }
else if (nearestPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= squaredSnapRadius) {
258 for (
int i = 1; i <= nearestIndex; i++) {
259 indexes.push_back(i);
262 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
265 const int newIndex = shapeToMove.
insertAtClosest(nearestPosition,
true);
266 for (
int i = 1; i <= newIndex; i++) {
267 indexes.push_back(i);
270 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
278 const double squaredSnapRadius = (snapRadius * snapRadius);
282 const int nearestIndex = originalShape.
indexOfClosest(mousePosition);
286 std::vector<int> indexes;
288 if (nearestIndex == -1) {
293 for (
int i = nearestIndex; i < ((int)originalShape.size() - 1); i++) {
294 indexes.push_back(i);
297 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
301 }
else if (nearestPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= squaredSnapRadius) {
302 for (
int i = nearestIndex; i < ((int)originalShape.size() - 1); i++) {
303 indexes.push_back(i);
306 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
309 const int newIndex = shapeToMove.
insertAtClosest(nearestPosition,
true);
310 for (
int i = newIndex; i < ((int)originalShape.size() - 1); i++) {
311 indexes.push_back(i);
314 return new GNEMoveOperation(
this, originalShape, indexes, shapeToMove, indexes);
321 std::vector<int> geometryPointsToMove;
322 for (
int i = 0; i < (int)
myEdge->getNBEdge()->getGeometry().size(); i++) {
323 geometryPointsToMove.push_back(i);
326 return new GNEMoveOperation(
this,
myEdge->getNBEdge()->getGeometry(), geometryPointsToMove,
myEdge->getNBEdge()->getGeometry(), geometryPointsToMove);
333 const auto& moveMultipleElementValues =
myEdge->getNet()->getViewNet()->getMoveMultipleElementValues();
337 if (shapeToMove.
length2D() < moveMultipleElementValues.getEdgeOffset()) {
343 if (
myEdge->isConvexAngle()) {
344 offset = moveMultipleElementValues.getEdgeOffset();
346 offset = shapeToMove.
length2D() - moveMultipleElementValues.getEdgeOffset();
349 const Position offsetPosition =
myEdge->getNBEdge()->getGeometry().positionAtOffset2D(offset);
351 const int nearestIndex =
myEdge->getNBEdge()->getGeometry().indexOfClosest(offsetPosition);
355 }
else if (offsetPosition.
distanceSquaredTo2D(shapeToMove[nearestIndex]) <= (snapRadius * snapRadius)) {
357 return new GNEMoveOperation(
this,
myEdge->getNBEdge()->getGeometry(), {nearestIndex}, shapeToMove, {nearestIndex});
360 const int newIndex = shapeToMove.
insertAtClosest(offsetPosition,
true);
362 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
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