Files
radar_system/python_app/gui/controllers/app_window_plot_mixin.py
T
2026-10-05 16:46:28 +03:00

54 lines
2.4 KiB
Python

"""Facade mixin for processed-radar plot rendering."""
from __future__ import annotations
from python_app.gui.controllers.app_window_plot import (
AppWindowBscanPlotMixin,
AppWindowBscanReplayMixin,
AppWindowGprPlotMixin,
AppWindowSar3dPlotMixin,
AppWindowTracePlotMixin,
)
from python_app.models.dataset_model import ResultCollection
class AppWindowPlotMixin(
AppWindowTracePlotMixin,
AppWindowBscanPlotMixin,
AppWindowBscanReplayMixin,
AppWindowGprPlotMixin,
AppWindowSar3dPlotMixin,
):
"""Routes plotting to trace, B-scan, GPR, or 3D SAR-specific mixins."""
def _draw_results(self, collection: ResultCollection) -> bool:
"""Draw collection based on currently selected processing mode."""
expected_revision = getattr(self, "_required_processing_revision", None)
if expected_revision is not None and self._is_gpr_like_processing_mode(self._processing_mode.currentText()):
revision = next((payload for payload in collection.collection_payloads
if payload.processing_name == "processing_revision" and payload.kind == 4), None)
if revision is None or revision.table.shape != (1, 4):
return False
if any(not 0 <= word <= 0xffff or word != int(word) for word in revision.table[0]):
return False
actual_revision = sum(int(word) << (index * 16) for index, word in enumerate(revision.table[0]))
if actual_revision != expected_revision:
return False
if self._processing_mode.currentText() == "bscan":
return self._draw_bscan_heatmap(collection)
if self._processing_mode.currentText() in {"gpr", "legacy_gpr"}:
return self._draw_gpr_map(collection)
if self._processing_mode.currentText() == "sar3d":
return self._draw_sar3d_projections(collection)
return self._draw_trace_lines(collection)
def _result_collection_has_trace(self, collection: ResultCollection) -> bool:
"""Recognize processed output, including an empty trace after a valid depth/frequency cut."""
if any(payload.processing_name != "processing_revision" for payload in collection.collection_payloads):
return True
for block in collection.blocks:
for payload in block.payloads:
if payload.kind == 1:
return True
return False