提交 3a6e0764 编写于 作者: K Kentaro Wada

Fix bugs around removing points and point-empty shape

上级 3b732f58
......@@ -405,7 +405,7 @@ class MainWindow(QtWidgets.QMainWindow):
)
removePoint = action(
text="Remove Selected Point",
slot=self.canvas.removeSelectedPoint,
slot=self.removeSelectedPoint,
icon="edit",
tip="Remove selected point from polygon",
enabled=False,
......@@ -1168,6 +1168,10 @@ class MainWindow(QtWidgets.QMainWindow):
group_id = shape["group_id"]
other_data = shape["other_data"]
if not points:
# skip point-empty shape
continue
shape = Shape(
label=label,
shape_type=shape_type,
......@@ -1869,6 +1873,16 @@ class MainWindow(QtWidgets.QMainWindow):
def toggleKeepPrevMode(self):
self._config["keep_prev"] = not self._config["keep_prev"]
def removeSelectedPoint(self):
self.canvas.removeSelectedPoint()
if not self.canvas.hShape.points:
self.canvas.deleteShape(self.canvas.hShape)
self.remLabels([self.canvas.hShape])
self.setDirty()
if self.noShapes():
for action in self.actions.onShapesPresent:
action.setEnabled(False)
def deleteSelectedShape(self):
yes, no = QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No
msg = self.tr(
......
......@@ -524,6 +524,14 @@ class Canvas(QtWidgets.QWidget):
self.update()
return deleted_shapes
def deleteShape(self, shape):
if shape in self.selectedShapes:
self.selectedShapes.remove(shape)
if shape in self.shapes:
self.shapes.remove(shape)
self.storeShapes()
self.update()
def copySelectedShapes(self):
if self.selectedShapes:
self.selectedShapesCopy = [s.copy() for s in self.selectedShapes]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册