Ver Fonte

Revert "Deselect shape when clicking and already selected (#944)" (#949)

This reverts commit 9d9914e8a4ca22fd31baf14d707137bd0d358858.
Kentaro Wada há 3 anos atrás
pai
commit
4754b26e73
2 ficheiros alterados com 13 adições e 23 exclusões
  1. 1 0
      labelme/app.py
  2. 12 23
      labelme/widgets/canvas.py

+ 1 - 0
labelme/app.py

@@ -38,6 +38,7 @@ from labelme.widgets import ZoomWidget
 
 # TODO(unknown):
 # - [high] Add polygon movement with arrow keys
+# - [high] Deselect shape when clicking and already selected(?)
 # - [low,maybe] Preview images on file dialogs.
 # - Zoom is too "steppy".
 

+ 12 - 23
labelme/widgets/canvas.py

@@ -381,12 +381,6 @@ class Canvas(QtWidgets.QWidget):
             elif self.editing():
                 if self.selectedEdge():
                     self.addPointToEdge()
-                elif (
-                    self.selectedVertex()
-                    and int(ev.modifiers()) == QtCore.Qt.ShiftModifier
-                ):
-                    # Delete point if: left-click + SHIFT on a point
-                    self.removeSelectedPoint()
 
                 group_mode = int(ev.modifiers()) == QtCore.Qt.ControlModifier
                 self.selectShapePoint(pos, multiple_selection_mode=group_mode)
@@ -394,13 +388,9 @@ class Canvas(QtWidgets.QWidget):
                 self.repaint()
         elif ev.button() == QtCore.Qt.RightButton and self.editing():
             group_mode = int(ev.modifiers()) == QtCore.Qt.ControlModifier
-            if not self.selectedShapes or (
-                self.hShape is not None
-                and self.hShape not in self.selectedShapes
-            ):
-                self.selectShapePoint(pos, multiple_selection_mode=group_mode)
-                self.repaint()
+            self.selectShapePoint(pos, multiple_selection_mode=group_mode)
             self.prevPoint = pos
+            self.repaint()
 
     def mouseReleaseEvent(self, ev):
         if ev.button() == QtCore.Qt.RightButton:
@@ -413,6 +403,13 @@ class Canvas(QtWidgets.QWidget):
                 # Cancel the move by deleting the shadow copy.
                 self.selectedShapesCopy = []
                 self.repaint()
+        elif ev.button() == QtCore.Qt.LeftButton and self.selectedVertex():
+            if (
+                self.editing()
+                and int(ev.modifiers()) == QtCore.Qt.ShiftModifier
+            ):
+                # Delete point if: left-click + SHIFT on a point
+                self.removeSelectedPoint()
 
         if self.movingShape and self.hShape:
             index = self.shapes.index(self.hShape)
@@ -481,21 +478,13 @@ class Canvas(QtWidgets.QWidget):
                 if self.isVisible(shape) and shape.containsPoint(point):
                     self.calculateOffsets(shape, point)
                     self.setHiding()
-                    if shape not in self.selectedShapes:
-                        if multiple_selection_mode:
+                    if multiple_selection_mode:
+                        if shape not in self.selectedShapes:
                             self.selectionChanged.emit(
                                 self.selectedShapes + [shape]
                             )
-                        else:
-                            self.selectionChanged.emit([shape])
                     else:
-                        self.selectionChanged.emit(
-                            [
-                                x
-                                for x in self.selectedShapes
-                                if x != self.hShape
-                            ]
-                        )
+                        self.selectionChanged.emit([shape])
                     return
         self.deSelectShape()