From 4b0a198bd4d71ec0c208bcb422d549ddba88bc8f Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Thu, 19 Sep 2024 16:11:26 +0900 Subject: [PATCH] Make point manipulation reasonable: ALT+Click (add), ALT+SHIFT+Click (delete) - Click: conflicts with selection and drag and drop - Ctrl+Click: conflicts with group selection --- labelme/widgets/canvas.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/labelme/widgets/canvas.py b/labelme/widgets/canvas.py index a78f073d3..0bdab1ea7 100644 --- a/labelme/widgets/canvas.py +++ b/labelme/widgets/canvas.py @@ -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 @@ -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 @@ -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