New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds option to remove an edge from polygon #1685

Merged
merged 6 commits into from Aug 15, 2017

Review changes

  • Loading branch information...
ketanhwr committed Aug 15, 2017
commit 16b7ad355d4bed04d0c97f1abed7301504090af4
Copy path View file
@@ -621,14 +621,15 @@ void EditPolygonTool::showHandleContextMenu(PointHandle *clickedHandle,
connect(splitSegmentsAction, SIGNAL(triggered()), SLOT(splitSegments()));
const auto firstHandle = *mSelectedHandles.begin();
const auto secondHandle = *(mSelectedHandles.begin() + 1);
const auto secondHandle = (n > 1) ? *(mSelectedHandles.begin() + 1) : nullptr;
MapObject *mapObject = firstHandle->mapObjectItem()->mapObject();
MapObject *secondMapObject = (n > 1) ? secondHandle->mapObjectItem()->mapObject(): nullptr;
if (mapObject->shape() == MapObject::Polygon) {
QAction *deleteEdge = menu.addAction(tr("Delete Edge"));
bool enabled = false;
if (mSelectedHandles.size() == 2) {
if (mSelectedHandles.size() == 2 && mapObject == secondMapObject) {
int indexDifference = std::abs(firstHandle->pointIndex() - secondHandle->pointIndex());
if (indexDifference == 1 || indexDifference == mapObject->polygon().size() - 1)

This comment has been minimized.

@bjorn

bjorn Aug 15, 2017

Owner

Don't forget to also check that both points belong to the same object.

enabled = true;
@@ -918,10 +919,8 @@ void EditPolygonTool::deleteEdge()
setSelectedHandles(QSet<PointHandle*>());
mapDocument()->mapObjectModel()->setObjectPolygon(mapObject, newPolygon);
mapDocument()->undoStack()->beginMacro(tr("Delete Edge"));
mapDocument()->undoStack()->push(new ChangePolygon(mapDocument(), mapObject, polygon));
mapDocument()->undoStack()->push(new ChangePolygon(mapDocument(), mapObject, newPolygon, polygon));
mapDocument()->undoStack()->push(new TogglePolygonPolyline(mapObject));
mapDocument()->undoStack()->endMacro();
}
ProTip! Use n and p to navigate between commits in a pull request.