Skip to content
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

Fix use of scaling in vispy points #6894

Merged
merged 2 commits into from
May 16, 2024
Merged

Conversation

brisvag
Copy link
Contributor

@brisvag brisvag commented May 6, 2024

References and relevant issues

In #6025, the vispy update broke the efforts from #5312. This is actually because the changes in vispy apparently do not handle the scaling kwarg properly at initialization. We can fix it here by not passing it.

I can't believe this has been wrong for so long, and I somehow never connected this issue that kept bugging me with that PR... but here we are.

Description

Try the following on main and here and move the camera around:

import napari
import numpy as np
v = napari.Viewer(ndisplay=3)
pl = v.add_points(np.array([[1, 1, 1], [10, 10, 10]]), scale=[1, 5, 5])
pv = v.window._qt_viewer.canvas.layer_to_visual[pl]

This fixes two things:

  • point sizes being all messed up by scaling
  • the anisotropic scale rotation wobblyness you see above

This returns to the correct, pre-#6025 situation.

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.44%. Comparing base (7b46a84) to head (c13528d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6894      +/-   ##
==========================================
- Coverage   92.45%   92.44%   -0.02%     
==========================================
  Files         614      614              
  Lines       55164    55164              
==========================================
- Hits        51001    50994       -7     
- Misses       4163     4170       +7     

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

@brisvag brisvag added bugfix PR with bugfix vispy Vispy integration labels May 13, 2024
@brisvag brisvag added this to the 0.5.0 milestone May 13, 2024
Copy link
Member

@andy-sweet andy-sweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the point-size issue in the description which I also bumped into in #6914.

Code changes also look fine, as I understand that we want point sizes to only be dependent on Points.size and not Points.scale.

I don't see any wobble on main with the given example, so I cannot vouch for that. Maybe I'll defer to @psobolewskiPhD on that?

@brisvag
Copy link
Contributor Author

brisvag commented May 15, 2024

This is what I see on main with the code above (fresh env, ensure vispy's up to date):

Peek.2024-05-15.10-28.mp4

@brisvag brisvag added the ready to merge Last chance for comments! Will be merged in ~24h label May 15, 2024
@andy-sweet
Copy link
Member

This is what I see on main with the code above (fresh env, ensure vispy's up to date):

My env was a fresh napari dev install. But I was able to reproduce now, but only when I'm zoomed out.

@brisvag
Copy link
Contributor Author

brisvag commented May 16, 2024

Should be good to go then :)

@brisvag brisvag merged commit 4a56237 into napari:main May 16, 2024
45 checks passed
@brisvag brisvag deleted the fix/point-scaling branch May 16, 2024 09:36
@github-actions github-actions bot removed the ready to merge Last chance for comments! Will be merged in ~24h label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix vispy Vispy integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants