Add object calibration
This commit is contained in:
@@ -26,7 +26,9 @@ import pyqtgraph as pg
|
||||
|
||||
from python_app.models.dataset_model import TraceData
|
||||
from python_app.orchestration.preprocess_assets import (
|
||||
CAPTURABLE_PREPROCESS_ASSET_KEYS,
|
||||
PREPROCESS_ASSET_SPECS,
|
||||
REQUIRED_PREPROCESS_ASSET_KEYS,
|
||||
VISIBLE_PREPROCESS_ASSET_KEYS,
|
||||
preprocess_asset_display_name,
|
||||
)
|
||||
@@ -47,6 +49,8 @@ class PreprocessDialog(QDialog):
|
||||
finalize_sequence_requested = pyqtSignal()
|
||||
abort_sequence_requested = pyqtSignal()
|
||||
create_neutral_sets_requested = pyqtSignal()
|
||||
import_object_calibration_requested = pyqtSignal()
|
||||
create_object_calibration_requested = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None) -> None:
|
||||
"""Initialize window metadata and compose dialog UI."""
|
||||
@@ -165,10 +169,25 @@ class PreprocessDialog(QDialog):
|
||||
for key in keys:
|
||||
combo = QComboBox(group)
|
||||
combo.setPlaceholderText("<not selected>")
|
||||
combo.setCurrentIndex(-1)
|
||||
combo.currentTextChanged.connect(self._emit_selection_changed)
|
||||
combo.setProperty("optional", key not in REQUIRED_PREPROCESS_ASSET_KEYS)
|
||||
self._set_combo_items(combo, [], "")
|
||||
combo.currentIndexChanged.connect(self._emit_selection_changed)
|
||||
self._set_combos[key] = combo
|
||||
form.addRow(self._asset_row_label(key), combo)
|
||||
field = combo
|
||||
if key == "s21_object_calibration":
|
||||
field = QWidget(group)
|
||||
row = QHBoxLayout(field)
|
||||
row.setContentsMargins(0, 0, 0, 0)
|
||||
row.addWidget(combo, stretch=1)
|
||||
self._import_object_calibration_button = QPushButton("Import…", field)
|
||||
self._import_object_calibration_button.setToolTip("Import an existing cal_*.npy MIMO calibration folder.")
|
||||
self._import_object_calibration_button.clicked.connect(self.import_object_calibration_requested.emit)
|
||||
self._create_object_calibration_button = QPushButton("Create…", field)
|
||||
self._create_object_calibration_button.setToolTip("Calculate a MIMO calibration from reflector measurements.")
|
||||
self._create_object_calibration_button.clicked.connect(self.create_object_calibration_requested.emit)
|
||||
row.addWidget(self._import_object_calibration_button)
|
||||
row.addWidget(self._create_object_calibration_button)
|
||||
form.addRow(self._asset_row_label(key), field)
|
||||
return group
|
||||
|
||||
def _build_sequence_group(self) -> QGroupBox:
|
||||
@@ -199,7 +218,7 @@ class PreprocessDialog(QDialog):
|
||||
def _build_sequence_button_grid(self, parent: QGroupBox) -> QGridLayout:
|
||||
"""Build per-asset capture start buttons."""
|
||||
layout = QGridLayout()
|
||||
for index, key in enumerate(VISIBLE_PREPROCESS_ASSET_KEYS):
|
||||
for index, key in enumerate(CAPTURABLE_PREPROCESS_ASSET_KEYS):
|
||||
button = QPushButton(f"Start {preprocess_asset_display_name(key)}", parent)
|
||||
button.clicked.connect(lambda _checked=False, asset_key=key: self.start_sequence_requested.emit(asset_key))
|
||||
layout.addWidget(button, index // 2, index % 2)
|
||||
@@ -316,7 +335,7 @@ class PreprocessDialog(QDialog):
|
||||
|
||||
def selection_snapshot(self) -> dict[str, str]:
|
||||
"""Return currently selected set names keyed by preprocess asset key."""
|
||||
return {key: self._set_combos[key].currentText().strip() for key in VISIBLE_PREPROCESS_ASSET_KEYS}
|
||||
return {key: self._set_combos[key].currentData() or "" for key in VISIBLE_PREPROCESS_ASSET_KEYS}
|
||||
|
||||
def clear_capture_log(self) -> None:
|
||||
"""Clear capture history text box."""
|
||||
@@ -398,7 +417,7 @@ class PreprocessDialog(QDialog):
|
||||
for key in VISIBLE_PREPROCESS_ASSET_KEYS:
|
||||
combo = self._set_combos[key]
|
||||
with QSignalBlocker(combo):
|
||||
self._set_combo_items(combo, available_sets.get(key, []), combo.currentText().strip())
|
||||
self._set_combo_items(combo, available_sets.get(key, []), combo.currentData() or "")
|
||||
|
||||
def set_selected_sets(self, selected_sets: dict[str, str], *, emit_signal: bool = True) -> None:
|
||||
"""Apply selected set names to all comboboxes and optionally emit update."""
|
||||
@@ -406,13 +425,10 @@ class PreprocessDialog(QDialog):
|
||||
selected_value = selected_sets.get(key, "")
|
||||
combo = self._set_combos[key]
|
||||
with QSignalBlocker(combo):
|
||||
if not selected_value:
|
||||
combo.setCurrentIndex(-1)
|
||||
continue
|
||||
index = combo.findText(selected_value)
|
||||
if index < 0:
|
||||
combo.addItem(selected_value)
|
||||
index = combo.findText(selected_value)
|
||||
index = combo.findData(selected_value)
|
||||
if index < 0 and selected_value:
|
||||
combo.addItem(selected_value, selected_value)
|
||||
index = combo.count() - 1
|
||||
combo.setCurrentIndex(index)
|
||||
if emit_signal:
|
||||
self._emit_selection_changed()
|
||||
@@ -538,12 +554,15 @@ class PreprocessDialog(QDialog):
|
||||
def _set_combo_items(combo: QComboBox, names: list[str], current_text: str) -> None:
|
||||
"""Replace combo contents and keep previous value when still available."""
|
||||
combo.clear()
|
||||
combo.addItems(names)
|
||||
if combo.property("optional"):
|
||||
combo.addItem("Off", "")
|
||||
for name in names:
|
||||
combo.addItem(name, name)
|
||||
if not current_text:
|
||||
combo.setCurrentIndex(-1)
|
||||
combo.setCurrentIndex(combo.findData(""))
|
||||
return
|
||||
index = combo.findText(current_text)
|
||||
index = combo.findData(current_text)
|
||||
if index < 0:
|
||||
combo.addItem(current_text)
|
||||
index = combo.findText(current_text)
|
||||
combo.addItem(current_text, current_text)
|
||||
index = combo.count() - 1
|
||||
combo.setCurrentIndex(index)
|
||||
|
||||
Reference in New Issue
Block a user