Renaming Pen tool to polyline tool

This commit is contained in:
2025-12-09 23:38:23 +02:00
parent dad5c2bf74
commit c3d44ac945
3 changed files with 200 additions and 246 deletions

View File

@@ -81,14 +81,14 @@ class AnnotationTab(QWidget):
# Annotation tools section
self.annotation_tools = AnnotationToolsWidget(self.db_manager)
self.annotation_tools.pen_enabled_changed.connect(
self.annotation_canvas.set_pen_enabled
self.annotation_tools.polyline_enabled_changed.connect(
self.annotation_canvas.set_polyline_enabled
)
self.annotation_tools.pen_color_changed.connect(
self.annotation_canvas.set_pen_color
self.annotation_tools.polyline_pen_color_changed.connect(
self.annotation_canvas.set_polyline_pen_color
)
self.annotation_tools.pen_width_changed.connect(
self.annotation_canvas.set_pen_width
self.annotation_tools.polyline_pen_width_changed.connect(
self.annotation_canvas.set_polyline_pen_width
)
# RDP simplification controls
self.annotation_tools.simplify_on_finish_changed.connect(
@@ -97,13 +97,12 @@ class AnnotationTab(QWidget):
self.annotation_tools.simplify_epsilon_changed.connect(
self._on_simplify_epsilon_changed
)
# Class selection and class-color changes
self.annotation_tools.class_selected.connect(self._on_class_selected)
self.annotation_tools.class_color_changed.connect(self._on_class_color_changed)
self.annotation_tools.clear_annotations_requested.connect(
self._on_clear_annotations
)
self.annotation_tools.process_annotations_requested.connect(
self._on_process_annotations
)
self.right_splitter.addWidget(self.annotation_tools)
# Image loading section
@@ -299,10 +298,37 @@ class AnnotationTab(QWidget):
self.annotation_canvas.simplify_epsilon = float(epsilon)
logger.debug(f"Annotation simplification epsilon set to {epsilon}")
def _on_class_selected(self, class_data: dict):
"""Handle when an object class is selected."""
logger.debug(f"Object class selected: {class_data['class_name']}")
# When a class is selected, update which annotations are visible
def _on_class_color_changed(self):
"""
Handle changes to the selected object's class color.
When the user updates a class color in the tools widget, reload the
annotations for the current image so that all polylines are redrawn
using the updated per-class colors.
"""
if not self.current_image_id:
return
logger.debug(
f"Class color changed; reloading annotations for image ID {self.current_image_id}"
)
self._load_annotations_for_current_image()
def _on_class_selected(self, class_data):
"""
Handle when an object class is selected or cleared.
When a specific class is selected, only annotations of that class are drawn.
When the selection is cleared (\"-- Select Class --\"), all annotations are shown.
"""
if class_data:
logger.debug(f"Object class selected: {class_data['class_name']}")
else:
logger.debug(
'No class selected ("-- Select Class --"), showing all annotations'
)
# Whenever the selection changes, update which annotations are visible
self._redraw_annotations_for_current_filter()
def _on_clear_annotations(self):
@@ -310,28 +336,6 @@ class AnnotationTab(QWidget):
self.annotation_canvas.clear_annotations()
logger.info("Cleared all annotations")
def _on_process_annotations(self):
"""
Legacy hook kept for UI compatibility.
Annotations are now saved automatically when a stroke is completed,
so this handler does not perform any additional database writes.
"""
if not self.current_image or not self.current_image_id:
QMessageBox.warning(
self,
"No Image",
"Please load an image before working with annotations.",
)
return
QMessageBox.information(
self,
"Annotations Already Saved",
"Annotations are saved automatically as you draw. "
"There is no separate processing step required.",
)
def _load_annotations_for_current_image(self):
"""
Load all annotations for the current image from the database and