Grid mode using vispy ViewBox and linked cameras - #7870
Conversation
Co-authored-by: Wouter-Michiel Vierdag <w-mv@hotmail.com>
for more information, see https://pre-commit.ci
443e246 to
da63dc6
Compare
|
Todo from pairing with @melonora:
|
| center = tuple(np.round(np.divide(screenshot.shape[:2], 2)).astype(int)) | ||
| np.testing.assert_almost_equal(screenshot[center], [0, 255, 255, 255]) |
There was a problem hiding this comment.
maybe here and above, comment out the code and add a note, as you did with other tests above, so that we know to revive the test as soon as we can?
There was a problem hiding this comment.
Will do, good catch! Didn't realize Lorenzo commented these out too ... another lead on how this issue is happening. 😬
There was a problem hiding this comment.
or, why does it need commented out? the test passes?
There was a problem hiding this comment.
ok actually I'm just confused on what I'm looking at. Is this the most recent commit? It's not what I see locally and I think it's the most recent commit. But this does look like a diff that has this code removed.
|
I am merging this PR because it has had many eyes from the team:
We will open follow-up PRs to address a few things, and others revealed during the pre-release including
|
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/test-out-the-upcoming-napari-0-6-2-release/114029/1 |
# References and and Description Follow up to #7870. After that PR, on main, stride results in layers stacking up in the wrong order, where lower indexed layers are on top of the stack. See #8053 and #8044 for original discussion ```python import napari from skimage import data viewer, layer = napari.imshow( data.lily(), name='lily', channel_axis=2, colormap=['red', 'green', 'blue', 'gray'], blending='translucent', opacity=1, ) viewer.grid.enabled = True viewer.grid.stride = 2 napari.run() ``` main:  this PR:  --------- Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
|
for release notes. this includes #8053 2025-06-29.16-52-45.mp4 |
# References and relevant issues - depends on napari/napari#7870 # Description Updated the descripion of grid mode to better reflect the new version, and added a small video to showcase it. --------- Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com> Co-authored-by: TimMonko <47310455+TimMonko@users.noreply.github.com>
Alternative to #8044 Depends on #8057 More context #8044 (comment) and #7870 (comment) Test with this script: ```python import napari from skimage import data viewer, layer = napari.imshow( data.lily(), name='lily', channel_axis=2, colormap=['red', 'green', 'blue', 'gray'], blending='translucent', opacity=1, ) viewer.grid.enabled = True viewer.grid.stride = 2 napari.run() ``` This PR reverses the default order of the panels with a default stride, so that later layers end up to the bottom-right of earlier layers. To enable the earlier behaviour, set a stride of -1, which can be set as default in the viewer preferences.  ## Script output: main:  this PR:  this PR with negative grid stride:  Co-authored-by: TimMonko <47310455+TimMonko@users.noreply.github.com>
# References and relevant issues - #7870 # Description We use grid mode in a few examples, but there's no explicit example just to showcase it, especially now that we have extra related features such as the `Overlay.gridded` attributes.
# References and relevant issues - closes #7956 - closes (kinda?) #6055 # Description 1. This issue has been bothering me for a long time and I finally figured it out. On main, if you have the scalebar enabled and zoom out beyond 1000, it will suddenly collapse to a single pixel. Turns out, when the scalebar is dimensionless we need to ensure to keep the world pixel length to the *real* lenght, because we don't have unit multiples. Funny thing is, we already had this check in place, but for some reason only applied to high zooms, and not low zooms. Anyways, AFAICT this works. 2. The second issue is ultimately caused by our camera reporting a zoom of `1` when it reaches a low enough scale factor. This code points to #2875, but I can't figure out why. EDIT: it seems to be #2958. I tried to remove this guard completely and I don't actually see that issue anymore... I think it might be solved, either by the fact that we moved a lot of camera updates to `on_draw` in #7870 specifically because the viewbox was degenerate, or for some other reason. Maybe we can just remove this? --------- Co-authored-by: Tim Monko <timmonko@gmail.com>

References and relevant issues
Feature: Highlight currently selected layer in grid mode #2954EDIT: postponed to a followup PRDescription
This PR replaces the current transform-based grid mode with a viewbox-based one using linked cameras.
Drag events will remain relative to the original viewbox, making annotation at the edges a breeze. Interacting with one viewbox, such as during annotation, will update the corresponding active layer, potentially in a different grid view.
Additionally, viewer canvas overlays (such as
scale_bar) now have agriddedproperty which, when set toTrue, will make it so the overlay appears in every grid box instead that on the general canvas.Grid mode spacing now works proportionally to the layer extensions (i.e. [0,1), as before this PR) or as a pixel value (1,1500]. If spacing amount exceeds a limit that will result in degenerate viewboxes, the spacing will automatically adjust and present a warning to the user. Stride continues to work as before. For discussion on changing the grid layout see #8044.