add remaining high value features

This commit is contained in:
2026-03-27 23:53:49 -07:00
parent 61d7b0fdcc
commit 240a2529eb
10 changed files with 1648 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
from __future__ import annotations
from backend.data_types import DataField
_LENGTH_UNITS = {"m", "km", "cm", "mm", "um", "µm", "nm", "pm", "fm"}
def unit_dimension_key(unit: str) -> str:
text = str(unit or "").strip().replace("µ", "u")
if not text:
return ""
if text in _LENGTH_UNITS:
return "length"
return text
def require_compatible_xy_z_units(field: DataField, node_name: str) -> None:
xy_key = unit_dimension_key(field.si_unit_xy)
z_key = unit_dimension_key(field.si_unit_z)
if xy_key and z_key and xy_key != z_key:
raise ValueError(f"{node_name} requires compatible XY and Z units, matching Gwyddion's topography-only behavior.")