-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few points of feedback on the code.
src/tiled/editpolygontool.cpp
Outdated
@@ -618,6 +620,24 @@ void EditPolygonTool::showHandleContextMenu(PointHandle *clickedHandle, | |||
connect(joinNodesAction, SIGNAL(triggered()), SLOT(joinNodes())); | |||
connect(splitSegmentsAction, SIGNAL(triggered()), SLOT(splitSegments())); | |||
|
|||
const auto firstHandle = *mSelectedHandles.begin(); | |||
const auto secondHandle = *(mSelectedHandles.begin() + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please get the second handle only after checking if there is one.
src/tiled/editpolygontool.cpp
Outdated
bool enabled = false; | ||
if (mSelectedHandles.size() == 2) { | ||
int indexDifference = std::abs(firstHandle->pointIndex() - secondHandle->pointIndex()); | ||
if (indexDifference == 1 || indexDifference == mapObject->polygon().size() - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to also check that both points belong to the same object.
src/tiled/editpolygontool.cpp
Outdated
|
||
setSelectedHandles(QSet<PointHandle*>()); | ||
|
||
mapDocument()->mapObjectModel()->setObjectPolygon(mapObject, newPolygon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of setting it here, you could use the ChangePolygon
constructor that takes both the old and the new polygon.
I pushed a small change that was more in the direction where I was trying to hint in my last review. In general, I think users will wonder:
|
The first and second point mainly refer to the same point. Personally, I don't think such an action would be common.
Right, I'll rename it. |
I think it's quite normal to spend most of the time working on stuff that will be rarely used, but let's have this action as-is then and spend time on other things then. :-) |
If two consecutive nodes are selected, then you can delete the edge between them to convert a polygon to polyline.