Unify 2D arrows on the shared painter.

Drop orisys.util.draw_arrows; box live and replay both use
_paint_shared_flow_arrows with sdk_box_policy when no policy is passed.
Recovered box flow uses the same inverse as finger. Verified with
shared/tests/test_image_backend.py arrow/idle/recovered cases.
This commit is contained in:
ykcheungab
2026-10-09 13:34:10 +08:00
parent 091d0fda35
commit d4b66c65a1
7 changed files with 98 additions and 160 deletions
@@ -17,8 +17,8 @@ Where a failure would be invisible:
reference frame are read back from the dialog's own widgets;
* a recomputed force trace and a recorded one are different claims, so the charts' source
kind and the provenance's ``sources``/``synthetic`` are asserted, not just the pixels;
* a box result is recorded on the live painter's grid, so the canvas is compared with
``draw_arrows`` on the recovered field once its gaps are filled with zero.
* a box result is recorded on the box sample grid, so the canvas is compared with
``draw_arrow_display`` on the recovered field.
The fixture clip is the project's recorded box footage under ``dist/``, copied into the test's
own directory. If it is absent the test **fails** (``_require_clip``) rather than skipping: a
@@ -433,10 +433,10 @@ def test_a_bare_video_is_analysed_and_scrubbed_in_both_directions(
def test_the_box_arrow_canvas_is_painted_by_the_live_painter(
bare_clip, window, monkeypatch
):
"""A box pass stores the live painter's grid, so the window draws ``draw_arrows``.
"""A box pass stores the box sample grid; the panel redraws with that policy.
The recovered field is still NaN off the recorded cells. Filling those gaps with zero
is what the live painter reads as "no motion", and that picture is the panel.
The recovered field is NaN off the recorded cells. The shared selector only samples
finite cells, so the panel matches ``draw_arrow_display`` on that sparse field.
"""
open_bare_video(window, bare_clip, monkeypatch)
settle(window)
@@ -451,7 +451,6 @@ def test_the_box_arrow_canvas_is_painted_by_the_live_painter(
"draw_style": window._draw_style(),
"colormap": flow_colormap(window._theme),
"policy": policy,
"shared_painter": False,
}
set_mode(window, ARROW_PURE)
@@ -460,15 +459,14 @@ def test_the_box_arrow_canvas_is_painted_by_the_live_painter(
QApplication.processEvents()
shown = panel_bgr(window)
assert painted(shown, canvas) > 0, "the operator's arrow canvas is blank"
filled = np.nan_to_num(np.asarray(first.flow, dtype=np.float64), nan=0.0)
expected = draw_arrow_display(
first.base_bgr,
filled,
first.flow,
valid_mask=first.valid_mask,
**common,
)
assert np.array_equal(shown, np.asarray(expected)), (
"the panel's canvas is not the live painter's output for this frame"
"the panel's canvas is not the shared painter's output for this frame"
)