统一 2D/3D 深度色条为同一量程。

将 2D 闩锁的深度色彩区间推给 3D 自动着色,固定量程仍跟旋钮。用 test_shared_depth_scale 与深度闩锁冒烟用例验证。
This commit is contained in:
ykcheungab
2026-10-06 21:31:53 +08:00
parent 829d2c1b53
commit 425f0dc9e2
8 changed files with 180 additions and 6 deletions
@@ -114,6 +114,8 @@ class Mesh3dPanel(QFrame):
#: The session's island latch, shared with the 2D canvas (see
#: ``set_domain_latch``). Held until the view exists.
self._domain_latch = None
#: The 2D canvas's latched depth colour span (see ``set_shared_depth_scale``).
self._shared_depth_scale: tuple[float, float] | None = None
# Reserve this top-level window's native handle *now*, before the window is
# shown and while no OpenGL widget exists yet.
@@ -227,6 +229,12 @@ class Mesh3dPanel(QFrame):
if self._view is not None and hasattr(self._view, "set_theme"):
self._view.set_theme(self._theme)
def set_shared_depth_scale(self, span: tuple[float, float] | None) -> None:
"""Share the 2D depth colour span with the 3D surface (and hold it until built)."""
self._shared_depth_scale = None if span is None else (float(span[0]), float(span[1]))
if self._view is not None and hasattr(self._view, "set_shared_depth_scale"):
self._view.set_shared_depth_scale(self._shared_depth_scale)
def set_domain_latch(self, latch) -> None:
"""Share the 2D canvas's island latch with the 3D pane (see ``Scene3DView``).
@@ -321,6 +329,8 @@ class Mesh3dPanel(QFrame):
view.set_theme(self._theme)
if self._domain_latch is not None and hasattr(view, "set_domain_latch"):
view.set_domain_latch(self._domain_latch)
if hasattr(view, "set_shared_depth_scale"):
view.set_shared_depth_scale(self._shared_depth_scale)
if self._pending_settings is not None:
view.restore_settings(self._pending_settings)
# The kind was decided before the view existed (the window sets it when the