UI updates

This commit is contained in:
Ayzen
2026-04-01 20:21:16 +03:00
parent 4abc95c372
commit 669205d8f8
43 changed files with 2055 additions and 973 deletions
@@ -4,8 +4,8 @@ from __future__ import annotations
from python_app.gui.preprocess_dialog import PreprocessDialog
from python_app.orchestration.preprocess_assets import (
PREPROCESS_ASSET_KEYS,
PREPROCESS_ASSET_SPECS,
VISIBLE_PREPROCESS_ASSET_KEYS,
preprocess_asset_channel,
preprocess_asset_display_name,
)
@@ -22,7 +22,7 @@ class AppWindowPreprocessMixin:
self._refresh_sets()
self._update_capture_dialog_state()
except Exception as exc: # noqa: BLE001
self._show_error(f"Failed to open preprocessing panel: {exc}")
self._show_exception("Failed to open preprocessing panel", exc)
return
dialog.showMaximized()
@@ -35,24 +35,39 @@ class AppWindowPreprocessMixin:
return self._preprocess_dialog
dialog = PreprocessDialog(self)
self._preprocess_dialog = dialog
dialog.set_set_name(self._preprocess_set_name)
dialog.set_selected_sets(self._selected_preprocess_sets, emit_signal=False)
dialog.refresh_requested.connect(self._refresh_sets)
dialog.selection_changed.connect(self._on_preprocess_selection_changed)
dialog.start_sequence_requested.connect(self._start_capture_sequence)
dialog.capture_next_requested.connect(self._capture_next_combo)
dialog.abort_sequence_requested.connect(self._abort_capture_sequence)
self._preprocess_dialog = dialog
self._update_capture_dialog_state()
return dialog
def _on_preprocess_selection_changed(self) -> None:
"""Persist selected preprocessing set names from dialog."""
dialog = self._ensure_preprocess_dialog()
previous_selection = dict(self._selected_preprocess_sets)
self._selected_preprocess_sets = dialog.selection_snapshot()
self._refresh_preprocess_summary_labels()
changes = []
for key in VISIBLE_PREPROCESS_ASSET_KEYS:
previous_value = previous_selection.get(key, "")
current_value = self._selected_preprocess_sets.get(key, "")
if previous_value == current_value:
continue
changes.append(
f"{preprocess_asset_display_name(key)}: "
f"{previous_value or '<not selected>'} -> {current_value or '<not selected>'}"
)
if changes:
self._log("Preprocess selection changed: " + "; ".join(changes))
def _refresh_preprocess_summary_labels(self) -> None:
"""Update compact summary labels in the main window."""
for key in PREPROCESS_ASSET_KEYS:
for key in VISIBLE_PREPROCESS_ASSET_KEYS:
self._selected_preprocess_labels[key].setText(self._selected_preprocess_sets.get(key, "") or "<not selected>")
def _refresh_sets(self) -> None:
@@ -63,22 +78,37 @@ class AppWindowPreprocessMixin:
available_sets = {
key: self._store.list_sets(PREPROCESS_ASSET_SPECS[key].set_kind, radar_key)
for key in PREPROCESS_ASSET_KEYS
for key in VISIBLE_PREPROCESS_ASSET_KEYS
}
dialog.set_available_sets(available_sets)
unavailable_selections: list[str] = []
for key, names in available_sets.items():
if self._selected_preprocess_sets.get(key, "") not in names:
self._selected_preprocess_sets[key] = names[0] if names else ""
current_value = self._selected_preprocess_sets.get(key, "")
if not current_value or current_value in names:
continue
unavailable_selections.append(
f"{preprocess_asset_display_name(key)}: "
f"{current_value} (not available for current radar key)"
)
dialog.set_selected_sets(self._selected_preprocess_sets)
self._refresh_preprocess_summary_labels()
self._log(f"Preprocess set lists refreshed for key={radar_key}")
available_counts = ", ".join(
f"{preprocess_asset_display_name(key)}={len(names)}"
for key, names in available_sets.items()
)
self._log(f"Preprocess set lists refreshed: radar_key={radar_key}, {available_counts}")
if unavailable_selections:
self._log_warning(
"Some selected preprocess sets are not currently available for this radar key.",
details="\n".join(unavailable_selections),
)
def _start_capture_sequence(self, kind: str) -> None:
"""Start sequential capture session for requested preprocess asset."""
if self._capture_session is not None:
self._show_error("Another capture sequence is already active")
self._show_error("Another capture sequence is already active", details=self._capture_state_details())
return
dialog = self._ensure_preprocess_dialog()
@@ -109,10 +139,13 @@ class AppWindowPreprocessMixin:
dialog.clear_capture_log()
dialog.set_status(f"{display_name} sequence started")
self._update_capture_dialog_state()
self._log(f"{display_name} sequence started for set={set_name}; fill all N*M combos")
self._log(
f"{display_name} sequence started: set={set_name}, radar_key={radar_key}, "
f"combos={session.state().total_count}"
)
except Exception as exc: # noqa: BLE001
self._cleanup_capture_session()
self._show_error(f"Failed to start {kind} sequence: {exc}")
self._show_exception(f"Failed to start {kind} sequence", exc)
self._resume_pipeline_if_needed()
def _capture_next_combo(self) -> None:
@@ -127,7 +160,6 @@ class AppWindowPreprocessMixin:
try:
trace = session.capture_current_combo()
state = session.state()
tx_label, rx_label = dialog.antenna_labels()
display_name = preprocess_asset_display_name(session.kind)
channel = preprocess_asset_channel(session.kind)
@@ -137,8 +169,6 @@ class AppWindowPreprocessMixin:
total_count=state.total_count,
input_pos=trace.combo.input_pos,
output_pos=trace.combo.output_pos,
tx_label=tx_label,
rx_label=rx_label,
)
dialog.draw_last_trace(trace, title=f"{display_name} captured", channel=channel)
@@ -164,7 +194,7 @@ class AppWindowPreprocessMixin:
else:
self._update_capture_dialog_state()
except Exception as exc: # noqa: BLE001
self._show_error(f"Failed to capture combo: {exc}")
self._show_exception("Failed to capture preprocess combo", exc)
self._abort_capture_sequence()
def _abort_capture_sequence(self, *, resume_pipeline: bool = True) -> None:
@@ -227,4 +257,4 @@ class AppWindowPreprocessMixin:
try:
self._start_run()
except Exception as exc: # noqa: BLE001
self._show_error(f"Failed to resume pipeline after capture: {exc}")
self._show_exception("Failed to resume pipeline after capture", exc)