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

Point selection highlights do not respect canvas size limits #6682

Closed
andreasmarnold opened this issue Feb 22, 2024 · 4 comments · Fixed by #6853
Closed

Point selection highlights do not respect canvas size limits #6682

andreasmarnold opened this issue Feb 22, 2024 · 4 comments · Fixed by #6853
Labels
bug Something isn't working priority-high High priority issue
Milestone

Comments

@andreasmarnold
Copy link

🐛 Bug Report

Setting points canvas size limits works fine. However, the point selection highlights are unchanged.
points-highlight-issue

💡 Steps to Reproduce

import napari
import numpy as np

image = np.random.random((100, 100))
points = np.array([[50, 50]])

viewer = napari.Viewer()
viewer.add_image(image)
pts_layer = viewer.add_points(points, size=100, canvas_size_limits=(5, 10), face_color='blue')

pts_layer.selected_data = {0}
pts_layer.refresh()

napari.run()

💡 Expected Behavior

I expected the selection highlights to be the same size as the points.

🌎 Environment

napari: 0.4.18
Platform: Windows-10-10.0.19045-SP0
Python: 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:01:37) [MSC v.1935 64 bit (AMD64)]
Qt: 5.15.8
PyQt5: 5.15.9
NumPy: 1.26.0
SciPy: 1.11.3
Dask: 2023.11.0
VisPy: 0.12.2
magicgui: 0.8.0
superqt: 0.6.1
in-n-out: 0.1.9
app-model: 0.2.2
npe2: 0.7.3

OpenGL:

  • GL version: 4.6.0 NVIDIA 516.40
  • MAX_TEXTURE_SIZE: 16384

Screens:

  • screen 1: resolution 1920x1200, scale 1.0
  • screen 2: resolution 1920x1200, scale 1.0

Settings path:

  • C:\Users\arnoldam\AppData\Local\napari\napari-env_c8fb36f02872a7d738a6aed04102ebfd9d7d2515\settings.yaml

💡 Additional Context

No response

@andreasmarnold andreasmarnold added the bug Something isn't working label Feb 22, 2024
@psobolewskiPhD
Copy link
Member

I can reproduce this on 0.4.19 and main.
Worse yet I can interact (drag) with points outside of the highlight area, so something else is bugged too.

@psobolewskiPhD psobolewskiPhD added the priority-high High priority issue label Feb 22, 2024
@psobolewskiPhD psobolewskiPhD added this to the 0.5.0 milestone Feb 22, 2024
@aeisenbarth
Copy link
Contributor

Possibly related to this, I noticed that click targets mismatch and make it hard to move a point without accidentially adding new point. When zoomed out, the visible point is at the lower canvas limit size (larger than data size). When dragging the point not perfectly from the center, it does not move.

This would be explained by this bug if point selection highlights correspond to click targets.

@jni
Copy link
Member

jni commented Mar 4, 2024

I think that's the opposite problem @aeisenbarth — the point selection is defined by the point "data" size, not the canvas size, when you are way zoomed out, selecting the point is harder. (There may of course also be a bug in the target detection, but I do think that is unrelated to this one.) This is made worse by macOS's implementation of OpenGL which has an absurdly small maximum point size (regardless of what canvas size limits says) — so sometimes napari thinks that a point is on top of another point, but there is no visual indication at all that this is the case. I don't really know how to fix this though, because I don't know how to introspect what the OpenGL maximum point size is...

@psobolewskiPhD
Copy link
Member

There are a couple things at play:

  1. the highlight not "sticking" to the point marker when canvas_size_limits is changed -- this issue, fixed by Fix selection size when canvas limits are set for Points #6853
  2. the highlight (including, crucially, thickness) re-sizes differently than the marker, so at certain zoom levels and highlight thicknesses it's harder/impossible to tell what is selected. (this seems to be worse on highDPI screens) I think this may be a different bug.

I've not experienced selection issues when zoomed out, but when zoomed in. Those may be due to the macOS limit, but I'm not sure -- I need to do some tests with linux size by side.

brisvag added a commit that referenced this issue May 3, 2024
# References and relevant issues
Closes #6682

# Description
The selection markers were not updated accordingly.

This is still not perfect (zooming in and out beyond the limits will
change the thickness of the highlight), but it's a limitation of how
hilight is implemented (by just using extra markers). Ideally we want to
have a single marker take care of hilight as well, but this requires
rewriting the shaders and it's not trivial.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-high High priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants