This commit is contained in:
2025-12-09 22:44:23 +02:00
parent 73cb698488
commit dad5c2bf74
3 changed files with 411 additions and 224 deletions

View File

@@ -12,6 +12,8 @@ from PySide6.QtWidgets import (
QPushButton,
QComboBox,
QSpinBox,
QDoubleSpinBox,
QCheckBox,
QColorDialog,
QInputDialog,
QMessageBox,
@@ -49,10 +51,11 @@ class AnnotationToolsWidget(QWidget):
pen_enabled_changed = Signal(bool)
pen_color_changed = Signal(QColor)
pen_width_changed = Signal(int)
simplify_on_finish_changed = Signal(bool)
simplify_epsilon_changed = Signal(float)
class_selected = Signal(dict)
clear_annotations_requested = Signal()
process_annotations_requested = Signal()
show_annotations_requested = Signal()
def __init__(self, db_manager: DatabaseManager, parent=None):
"""
@@ -110,6 +113,23 @@ class AnnotationToolsWidget(QWidget):
color_layout.addStretch()
pen_layout.addLayout(color_layout)
# Simplification controls (RDP)
simplify_layout = QHBoxLayout()
self.simplify_checkbox = QCheckBox("Simplify on finish")
self.simplify_checkbox.setChecked(True)
self.simplify_checkbox.stateChanged.connect(self._on_simplify_toggle)
simplify_layout.addWidget(self.simplify_checkbox)
simplify_layout.addWidget(QLabel("epsilon (px):"))
self.eps_spin = QDoubleSpinBox()
self.eps_spin.setRange(0.0, 1000.0)
self.eps_spin.setSingleStep(0.5)
self.eps_spin.setValue(2.0)
self.eps_spin.valueChanged.connect(self._on_eps_change)
simplify_layout.addWidget(self.eps_spin)
simplify_layout.addStretch()
pen_layout.addLayout(simplify_layout)
pen_group.setLayout(pen_layout)
layout.addWidget(pen_group)
@@ -155,13 +175,6 @@ class AnnotationToolsWidget(QWidget):
)
actions_layout.addWidget(self.process_btn)
self.show_btn = QPushButton("Show Saved Annotations")
self.show_btn.clicked.connect(self._on_show_annotations)
self.show_btn.setStyleSheet(
"QPushButton { background-color: #4CAF50; color: white; }"
)
actions_layout.addWidget(self.show_btn)
self.clear_btn = QPushButton("Clear All Annotations")
self.clear_btn.clicked.connect(self._on_clear_annotations)
actions_layout.addWidget(self.clear_btn)
@@ -227,6 +240,18 @@ class AnnotationToolsWidget(QWidget):
self.pen_width_changed.emit(width)
logger.debug(f"Pen width changed to {width}")
def _on_simplify_toggle(self, state: int):
"""Handle simplify-on-finish checkbox toggle."""
enabled = bool(state)
self.simplify_on_finish_changed.emit(enabled)
logger.debug(f"Simplify on finish set to {enabled}")
def _on_eps_change(self, val: float):
"""Handle epsilon (RDP tolerance) value changes."""
epsilon = float(val)
self.simplify_epsilon_changed.emit(epsilon)
logger.debug(f"Simplification epsilon changed to {epsilon}")
def _on_color_picker(self):
"""Open color picker dialog with alpha support."""
color = QColorDialog.getColor(
@@ -364,11 +389,6 @@ class AnnotationToolsWidget(QWidget):
self.process_annotations_requested.emit()
logger.debug("Process annotations requested")
def _on_show_annotations(self):
"""Handle show annotations button."""
self.show_annotations_requested.emit()
logger.debug("Show annotations requested")
def get_current_class(self) -> Optional[Dict]:
"""Get currently selected object class."""
return self.current_class