Skip to content

Commit

Permalink
Make point manipulation reasonable: ALT+Click (add), ALT+SHIFT+Click …
Browse files Browse the repository at this point in the history
…(delete)

- Click: conflicts with selection and drag and drop
- Ctrl+Click: conflicts with group selection
  • Loading branch information
wkentaro committed Sep 20, 2024
1 parent ecc83c2 commit c7bd89f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions labelme/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ def mouseMoveEvent(self, ev):
self.hEdge = None
shape.highlightVertex(index, shape.MOVE_VERTEX)
self.overrideCursor(CURSOR_POINT)
self.setToolTip(self.tr("Click & drag to move point"))
self.setToolTip(
self.tr(
"Click & Drag to move point\n"
"ALT + SHIFT + Click to delete point"
)
)
self.setStatusTip(self.toolTip())
self.update()
break
Expand All @@ -354,7 +359,7 @@ def mouseMoveEvent(self, ev):
self.prevhShape = self.hShape = shape
self.prevhEdge = self.hEdge = index_edge
self.overrideCursor(CURSOR_POINT)
self.setToolTip(self.tr("Click to create point"))
self.setToolTip(self.tr("ALT + Click to create point"))
self.setStatusTip(self.toolTip())
self.update()
break
Expand Down Expand Up @@ -466,13 +471,11 @@ def mousePressEvent(self, ev):
self.drawingPolygon.emit(True)
self.update()
elif self.editing():
if self.selectedEdge():
if self.selectedEdge() and ev.modifiers() == QtCore.Qt.AltModifier:
self.addPointToEdge()
elif (
self.selectedVertex()
and int(ev.modifiers()) == QtCore.Qt.ShiftModifier
elif self.selectedVertex() and ev.modifiers() == (
QtCore.Qt.AltModifier | QtCore.Qt.ShiftModifier
):
# Delete point if: left-click + SHIFT on a point
self.removeSelectedPoint()

group_mode = int(ev.modifiers()) == QtCore.Qt.ControlModifier
Expand Down

0 comments on commit c7bd89f

Please sign in to comment.