31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Shared mapping for the sar3d bottom-view projection choices.
|
|
|
|
The bottom plot of the sar3d mode projects the imaged volume along a
|
|
horizontal direction rotated around the vertical Y axis: 0° = front view
|
|
(X horizontal), 90° = side view (Z horizontal). One shared mapping keeps the
|
|
combo box, the live-config build, the profile persistence and the plot labels
|
|
consistent.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
SAR3D_BOTTOM_VIEW_CHOICES: tuple[tuple[str, float], ...] = (
|
|
("front (0°)", 0.0),
|
|
("30°", 30.0),
|
|
("60°", 60.0),
|
|
("side (90°)", 90.0),
|
|
)
|
|
|
|
|
|
def sar3d_bottom_view_deg_from_label(label: str) -> float:
|
|
"""Map a bottom-view combo label to its projection angle in degrees."""
|
|
for choice_label, degrees in SAR3D_BOTTOM_VIEW_CHOICES:
|
|
if choice_label == label:
|
|
return degrees
|
|
return 0.0
|
|
|
|
|
|
def sar3d_bottom_view_label_from_deg(degrees: float) -> str:
|
|
"""Map a projection angle to the nearest bottom-view combo label."""
|
|
return min(SAR3D_BOTTOM_VIEW_CHOICES, key=lambda choice: abs(choice[1] - float(degrees)))[0]
|