Explorar el Código

Adding ability to add or remove points from existing polygon when left-clicking while holding down the SHIFT-key.

Henrik Toft hace 4 años
padre
commit
7189f2c989
Se han modificado 1 ficheros con 13 adiciones y 0 borrados
  1. 13 0
      labelme/widgets/canvas.py

+ 13 - 0
labelme/widgets/canvas.py

@@ -376,6 +376,19 @@ class Canvas(QtWidgets.QWidget):
                 self.repaint()
         elif ev.button() == QtCore.Qt.LeftButton and self.selectedShapes:
             self.overrideCursor(CURSOR_GRAB)
+            if (
+                self.editing()
+                and int(ev.modifiers()) == QtCore.Qt.ShiftModifier
+            ):
+                # Add point to line if: left-click + SHIFT on a line segment
+                self.addPointToEdge()
+        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)