Adding feature to remove annotations
This commit is contained in:
@@ -58,6 +58,8 @@ class AnnotationToolsWidget(QWidget):
|
||||
class_selected = Signal(dict)
|
||||
class_color_changed = Signal()
|
||||
clear_annotations_requested = Signal()
|
||||
# Request deletion of the currently selected annotation on the canvas
|
||||
delete_selected_annotation_requested = Signal()
|
||||
|
||||
def __init__(self, db_manager: DatabaseManager, parent=None):
|
||||
"""
|
||||
@@ -182,6 +184,12 @@ class AnnotationToolsWidget(QWidget):
|
||||
self.clear_btn.clicked.connect(self._on_clear_annotations)
|
||||
actions_layout.addWidget(self.clear_btn)
|
||||
|
||||
# Delete currently selected annotation (enabled when a selection exists)
|
||||
self.delete_selected_btn = QPushButton("Delete Selected Annotation")
|
||||
self.delete_selected_btn.clicked.connect(self._on_delete_selected_annotation)
|
||||
self.delete_selected_btn.setEnabled(False)
|
||||
actions_layout.addWidget(self.delete_selected_btn)
|
||||
|
||||
actions_group.setLayout(actions_layout)
|
||||
layout.addWidget(actions_group)
|
||||
|
||||
@@ -439,6 +447,20 @@ class AnnotationToolsWidget(QWidget):
|
||||
self.clear_annotations_requested.emit()
|
||||
logger.debug("Clear annotations requested")
|
||||
|
||||
def _on_delete_selected_annotation(self):
|
||||
"""Handle delete selected annotation button."""
|
||||
self.delete_selected_annotation_requested.emit()
|
||||
logger.debug("Delete selected annotation requested")
|
||||
|
||||
def set_has_selected_annotation(self, has_selection: bool):
|
||||
"""
|
||||
Enable/disable actions that require a selected annotation.
|
||||
|
||||
Args:
|
||||
has_selection: True if an annotation is currently selected on the canvas.
|
||||
"""
|
||||
self.delete_selected_btn.setEnabled(bool(has_selection))
|
||||
|
||||
def get_current_class(self) -> Optional[Dict]:
|
||||
"""Get currently selected object class."""
|
||||
return self.current_class
|
||||
|
||||
Reference in New Issue
Block a user