Skip to content

feat: expose canvas integration and camera APIs - #285

Draft
kephale wants to merge 6 commits into
pyapp-kit:mainfrom
kephale:lodstone-integration
Draft

feat: expose canvas integration and camera APIs#285
kephale wants to merge 6 commits into
pyapp-kit:mainfrom
kephale:lodstone-integration

Conversation

@kephale

@kephale kephale commented Aug 23, 2026

Copy link
Copy Markdown

Human Kyle: I got here when working on a viewer-agnostic progressive loading module. I'm not pushy about any of this and can pull it down if you'd like. It is still a work in progress, but seems to be working reasonably-ish in ndv with both vispy+pygfx.

Summary

  • expose an ArrayViewer.canvas integration surface and application-thread dispatch hook
  • publish backend-neutral camera viewport/matrix state and camera change events
  • support independent scale/origin transforms on image and volume handles
  • keep VisPy and PyGFX behavior aligned, including volume downsampling and transforms

These APIs let renderer-neutral streaming engines integrate without importing private VisPy or PyGFX implementation details. The branch is consumed by Lodstone's experimental ndv adapter, but ndv does not depend on Lodstone.

Validation

  • 189 passed, 14 skipped
  • Ruff check and format pass for source/tests
  • backend transform coverage passes for VisPy and PyGFX

The full local pre-commit run additionally reports five existing wx typing diagnostics in _wx/range_slider.py and _wx/_array_view.py; none are in this PR's changed files.

@kephale

kephale commented Aug 23, 2026

Copy link
Copy Markdown
Author

The matrix found and helped fix two portability regressions in eb2aa51: initial PyGFX scale synchronization against an empty scene and a Qt-specific viewport assertion under Jupyter. The refreshed matrix passes the affected min-deps, PyGFX, VisPy, Jupyter, Pyright, docs, manifest, and cross-platform jobs.

Two teardown-only jobs remain red and need a maintainer rerun (GitHub does not allow the fork author to rerun upstream jobs):

  • test-array-libs (3.13): 168 passed / 12 skipped, then the existing top-level-widget leak detector reported Qt widgets retained from earlier viewer tests while tearing down test_canvas_to_world_scale_aware_offset.
  • windows-latest py3.13 wxpython pygfx: 157 passed / 13 skipped, then the Python process exited nonzero after repeated wx DestroyWindow invalid-handle messages.

Neither reports an assertion failure in the integration APIs. Locally the complete suite is 190 passed / 14 skipped, including the new empty-scene regression test.

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.08%. Comparing base (1c887ad) to head (1fc51e9).

Files with missing lines Patch % Lines
src/ndv/views/_pygfx/_array_canvas.py 55.55% 12 Missing ⚠️

❌ Your patch check has failed because the patch coverage (82.60%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
- Coverage   85.20%   85.08%   -0.12%     
==========================================
  Files          53       53              
  Lines        7192     7256      +64     
==========================================
+ Hits         6128     6174      +46     
- Misses       1064     1082      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tlambert03

Copy link
Copy Markdown
Member

thank you for this @kephale! I'm glad to see you're still playing around with ndv. I apologize for the delayed response. I'm buried under a backlog of things to respond to after my move. I can say up front that exposing camera APIs is a known high priority... and it touches stuff that @gselzer has been doing it abstracting away the heart of ndv into scenex... so i know there will be some overlap with #276

i apologize that i likely won't be able to give concrete feedback on this very soon. maybe @gselzer, who has been looking at these things more recently, might have thoughts on how to get you what you need (or perhaps even just merge this idea as is) without waiting for the whole refactor to land

@kephale

kephale commented Aug 27, 2026

Copy link
Copy Markdown
Author

yay, hey @tlambert03! no worries on my side, this is a slower push from me so I can wait on @gselzer and adapt my implementation accordingly. my intention is just to get progressive loading support into the world. that said, i did find ndv to be one of the snappiest viewers with this implementation so it might become my main testing vehicle while investigating the chunk sampling/prioritization strategies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants