Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shapes interactivity with scale != 1 (selection, rotate/resize) (#…
…5802) # Description Scale layer interactivity and visualisation are currently not accounting for the layer scale. Try the following: ```py import numpy as np import napari v = napari.Viewer() il = v.add_image(np.random.rand(100, 100)) sl = v.add_shapes([[0, 0], [1, 1]], shape_type='path', scale=[100, 100], edge_width=0.1) ``` You'll see a few issues: - highlight line is not in screen space as advertised. (This is actually a problem with points as well) - the `rotate` handle is way too far because its position is also calculated not accounting for scale - interacting with the shape in any mode is basically impossible, cause coordinates do not account for the scaling of the layer. This PR basically adds a `/ layer.scale[-1]` in several places to get back into correct "sceen space". Note that I used the last dimension as we cannot do anisotropic sizes, just like we recently chose to do with points in #5582. This PR also fixes #4538 by changing the logic of how the "minimum drag" is calculated. PS: ideally we want to transition to using the `SelectionOverlay` in the future, but this is a much bigger effort. Also fixes #5752. ## Type of change <!-- Please delete options that are not relevant. --> - [x] Bug-fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
- Loading branch information
Showing
4 changed files
with
66 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters