为二维与三维深度色标增加每帧自适应选项。
默认仍锁定本会话首帧,勾选后两视图按当前帧有效深度共用同一范围。已用深度色标与显示设置测试验证。
This commit is contained in:
@@ -57,6 +57,7 @@ def test_the_pane_holds_a_legend_and_no_settings(panel):
|
||||
panel.deform_check,
|
||||
panel.gain_spin,
|
||||
panel.scale_combo,
|
||||
panel.depth_adaptive_check,
|
||||
panel.fps_combo,
|
||||
panel.reset_button,
|
||||
):
|
||||
@@ -89,10 +90,22 @@ def test_the_settings_dialog_hosts_the_panes_own_controls(panel):
|
||||
assert not dialog.isVisible()
|
||||
assert panel.enable_check.text(), "closing the dialog destroyed its controls"
|
||||
assert panel.settings().max_fps == 30
|
||||
assert panel.settings().depth_scale_adaptive is False
|
||||
finally:
|
||||
dialog.deleteLater()
|
||||
|
||||
|
||||
def test_adaptive_depth_scale_round_trips_through_the_dialog(panel):
|
||||
"""The per-frame colour bar is a saved setting, not a one-shot toggle."""
|
||||
from orisys_app_shared.scene3d.contracts import DisplaySettings
|
||||
|
||||
panel.apply_settings(DisplaySettings(depth_scale_adaptive=True))
|
||||
assert panel.depth_adaptive_check.isChecked()
|
||||
assert panel.settings().depth_scale_adaptive is True
|
||||
panel.apply_settings(DisplaySettings())
|
||||
assert panel.settings().depth_scale_adaptive is False
|
||||
|
||||
|
||||
def test_the_pane_header_offers_the_two_actions(qt_app):
|
||||
"""A gear and a view reset: the two things that belong to *looking*."""
|
||||
from orisys_studio.ui.mesh3d_panel import Mesh3dPanel
|
||||
|
||||
@@ -473,6 +473,7 @@ def test_the_display_settings_round_trip():
|
||||
flow_off_px=0.35,
|
||||
flow_grid_spacing=12,
|
||||
max_arrows=250,
|
||||
depth_scale_adaptive=True,
|
||||
color_scale=ColorScale(
|
||||
descriptor=FieldDescriptor("flow_magnitude", "px", "approximate", False),
|
||||
lower=0.25,
|
||||
@@ -495,6 +496,8 @@ def test_the_display_settings_round_trip():
|
||||
assert restored.color_scale is not None
|
||||
assert (restored.color_scale.lower, restored.color_scale.upper) == (0.25, 4.5)
|
||||
assert restored.color_scale.mode == "fixed"
|
||||
assert restored.depth_scale_adaptive is True
|
||||
assert scene3d_prefs.settings_from_prefs({}).depth_scale_adaptive is False
|
||||
|
||||
|
||||
def test_a_saved_descriptor_is_never_restored_as_a_measurement():
|
||||
|
||||
@@ -920,11 +920,6 @@ def test_depth_view_reports_missing_data_and_fixes_its_scale(make_window):
|
||||
window._on_run_tick()
|
||||
latched = window.arrow_panel.depth_scale_label.text()
|
||||
assert latched
|
||||
shared = window.mesh3d_panel._shared_depth_scale
|
||||
assert shared == window._depth_range_value
|
||||
assert shared is not None
|
||||
assert shared[0] == pytest.approx(0.0)
|
||||
assert shared[1] == pytest.approx(1.0)
|
||||
|
||||
window._last_rendered_view_mode = None
|
||||
stuck.emit(ui_check._fake_packet(2, depth=np.linspace(0.0, 9.0, 64).reshape(8, 8)))
|
||||
@@ -932,12 +927,61 @@ def test_depth_view_reports_missing_data_and_fixes_its_scale(make_window):
|
||||
assert window.arrow_panel.depth_scale_label.text() == latched, (
|
||||
"the depth colour scale re-fitted on every frame"
|
||||
)
|
||||
assert window.mesh3d_panel._shared_depth_scale == shared, (
|
||||
"the 3D depth colour span must stay locked to the 2D latch"
|
||||
assert window.mesh3d_panel.shared_depth_scale() == window._depth_range(), (
|
||||
"the 3D depth colour scale is not the 2D canvas's latched span"
|
||||
)
|
||||
_finish(window, stuck)
|
||||
|
||||
|
||||
def test_adaptive_depth_scale_refits_both_views(make_window):
|
||||
"""The setting restores the per-frame colour bar, and both views share it."""
|
||||
import numpy as np
|
||||
from orisys_app_shared.scene3d.contracts import DisplaySettings
|
||||
|
||||
window, stuck = _running_window(make_window)
|
||||
window.arrow_panel.set_view_mode("depth")
|
||||
window.mesh3d_panel.set_display_settings(
|
||||
DisplaySettings(depth_scale_adaptive=True)
|
||||
)
|
||||
|
||||
window._last_rendered_view_mode = None
|
||||
stuck.emit(ui_check._fake_packet(1, depth=np.linspace(0.0, 1.0, 64).reshape(8, 8)))
|
||||
window._on_run_tick()
|
||||
from orisys_app_shared.i18n import t
|
||||
|
||||
first = window.arrow_panel.depth_scale_label.text()
|
||||
assert window.mesh3d_panel.shared_depth_scale() == (0.0, 1.0)
|
||||
assert "1.000" in first
|
||||
assert window.arrow_panel.depth_scale_label.toolTip() == t(
|
||||
"panels.depth_scale_tip_adaptive"
|
||||
)
|
||||
|
||||
window._last_rendered_view_mode = None
|
||||
stuck.emit(ui_check._fake_packet(2, depth=np.linspace(0.0, 9.0, 64).reshape(8, 8)))
|
||||
window._on_run_tick()
|
||||
assert window.arrow_panel.depth_scale_label.text() != first, (
|
||||
"the adaptive colour bar stayed on the first frame"
|
||||
)
|
||||
assert window.mesh3d_panel.shared_depth_scale() == (0.0, 9.0)
|
||||
assert window._depth_range_value is None
|
||||
|
||||
window.mesh3d_panel.set_display_settings(DisplaySettings())
|
||||
window._last_rendered_view_mode = None
|
||||
stuck.emit(ui_check._fake_packet(3, depth=np.linspace(0.0, 4.0, 64).reshape(8, 8)))
|
||||
window._on_run_tick()
|
||||
latched = window.mesh3d_panel.shared_depth_scale()
|
||||
assert latched == (0.0, 4.0)
|
||||
|
||||
window._last_rendered_view_mode = None
|
||||
stuck.emit(ui_check._fake_packet(4, depth=np.linspace(0.0, 8.0, 64).reshape(8, 8)))
|
||||
window._on_run_tick()
|
||||
assert window.mesh3d_panel.shared_depth_scale() == latched, (
|
||||
"leaving adaptive did not return to the session latch"
|
||||
)
|
||||
assert window.arrow_panel.depth_scale_label.toolTip() == t("panels.depth_scale_tip")
|
||||
_finish(window, stuck)
|
||||
|
||||
|
||||
def test_the_domain_boundary_is_latched_for_the_session(make_window):
|
||||
"""The 2D boundary is the device's island: rebuilt per frame, decided once.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user