-
-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform mode of Labels layer pivots wrong when non-empty Shapes/Points present #6897
Comments
When you remove Shapes layer, you cannot longer even rotate this layer. |
Ok. This is not a problem with the order of layer creation. It is a bug connected to translation. If you first create a shape or point layer, then labels layer will be created with negative translation. Minimum script is: import napari
import numpy as np
from napari.utils.transforms import Affine
viewer = napari.Viewer()
labels = viewer.add_labels(np.ones((10, 10), dtype=np.uint8), translate=(10, 10), affine=Affine(rotate=45))
labels.mode = "transform"
napari.run() @brisvag it looks like we hit the same problem again... |
The problem is here: napari/napari/_vispy/layers/base.py Line 254 in 2102518
In general, for simple layer it should evaluate to |
Maybe naive but seems like changing napari/napari/_vispy/layers/base.py Lines 246 to 249 in 2102518
translate_child = (
simplified_transform.translate[dims_displayed]
)[::-1] - offset[::-1] Makes things work (at least when checking things from the GUI with the minimum reproducer script/code snippet): Is there a reason to not use the simplified transform for the translate value in the same way that it's used to get the rotate and scale values? |
I do not check it (Yes, I'm the author of this code too). Maybde it is enough, but I think that we should also find a way to test it and prepare excessive test coverage to validate all cases. |
This makes sense to me; agree that we need proper coverage here, but we don't even have proper agreements on the coordinate systems (#3783)... |
# References and relevant issues closes napari#6897 fix again bug from napari#6633 # Description This PR is fixing again problems with transforms of overlays, this time it contains basic tests. --------- Co-authored-by: Lorenzo Gaifas <brisvag@gmail.com> Co-authored-by: Juan Nunez-Iglesias <jni@fastmail.com>
🐛 Bug Report
If there is a non-empty Shapes or Points layer present and you use Transform mode on a Labels layer (activate using
7
), rotation pivots wrong: the bounding box desyncs the layer data.Kapture.2024-05-06.at.21.08.31.mp4
💡 Steps to Reproduce
7
) and try to rotate the labels layer💡 Expected Behavior
The transform box should match the layer data and remain functional.
🌎 Environment
napari: 0.5.0a2.dev649+g2d2cac676
Platform: macOS-13.3.1-arm64-arm-64bit
System: MacOS 13.3.1
Python: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:54:21) [Clang 16.0.6 ]
Qt: 6.6.1
PyQt6:
NumPy: 1.26.4
SciPy: 1.12.0
Dask: 2024.3.1
VisPy: 0.14.3.dev3
magicgui: 0.8.2
superqt: 0.6.2
in-n-out: 0.2.0
app-model: 0.2.5
npe2: 0.7.4
OpenGL:
Screens:
Optional:
Settings path:
💡 Additional Context
No response
The text was updated successfully, but these errors were encountered: