napari: GUI point size slider does not control size of points

Two problems

  1. Dragging the point size slider bar does not control the size of the points, and
  2. Changing the point size in ipython does not update the position of the point size slider bar

To reproduce

import napari
import numpy as np

points = np.random.random((10,3))
viewer = napari.Viewer(ndisplay=3)
viewer.add_points = 
print(viewer.layers[-1])
print(viewer.layers[-1].size)  # shows an array of tens, the default point size value

Now drag the point size slider bar in the GUI and watch it fail to update the size of the points. There’s no change either when you query viewer.layers[-1].size.

However, you can update the point size from the terminal, eg:

viewer.layers[-1].size = 30

…which does change the point size, but not the position of the point size slider bar (or the value reported there). I expected that the slider bar position should be updated, unless the size value was above or below the ends of the slider bar (in which case I guess it should be moved to the end?)

Environment details

napari: 0.5.0a2.dev88+g95356e45 Platform: Windows-10-10.0.22621-SP0 Python: 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:00:38) [MSC v.1934 64 bit (AMD64)] Qt: 5.15.6 PyQt5: 5.15.7 NumPy: 1.24.2 SciPy: 1.10.1 Dask: 2023.4.0 VisPy: 0.12.2 magicgui: 0.7.2 superqt: unknown in-n-out: 0.1.7 app-model: 0.1.4 npe2: 0.7.0

OpenGL:

  • GL version: 4.6.0 NVIDIA 528.02
  • MAX_TEXTURE_SIZE: 32768

Screens:

  • screen 1: resolution 2560x1600, scale 1.0

Settings path:

  • C:\Users\Supervisor\AppData\Local\napari\napari-dev_8890fb02210b7dc05c421c3c65ceb0b896a7352b\settings.yaml#5685

Additional details

I have also seen this problem occur while working on a Mac.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Symbol already behaves like size: #5312.

And what when have different size of points in selction?

Yes, this is a tricky case when you would have multiple selected points with all different sizes. Based on a few programs I’ve tried, it would show the value for the last selected item or no numerical value at all (MS Word does this with font size for example).

Switch to Select tool. Select the first point you made. Slider still shows 40 or whatnot, when it should show 10, because that’s the size of the selected point. Adjusting the slider does work and changes the size, but for me there is a disconnect there, an inconsistency.

Yup, this is definitely a bug!

if you programmatically added 50 points, having them be selected makes sense?

This already works; the problem is when creating a new layer. Maybe I’ll open a PR with this.

Let’s move the design discussions to a separate thread. Continuing that here will mean they are not very discoverable.

Just in case and for traceability, linking here an old issue I found that seems to be related to this: https://github.com/napari/napari/issues/702

I would vote for no value, set the slider to the middle, and then as soon as you move the slider everything selected gets resized.

I’m not too fond of this. For many projects, it will end with multiple problems. It should be median or dominant. Or at least the option to provide size by entering text to some text input, not only dragging the slider.

  • Dragging the point size slider bar does not control the size of the points, and

I can’t reproduce this? The slider controls size of any selected points or new points. I almost never use points, but this is as I’d expect from basically every other GUI program? So me this is intuitive. You make the layer, there’s a size set, you make points you get that size. You want to change point size, select some points to change.

Only slightly odd thing is that when adding points, the last point added is immediately selected. So you can easily end up changing its size inadvertently when intending to change the next point you place.

Now viewer.layers[-1].size weird — it changes the size of all existing points in a layer, regardless of selection, but does not affect new ones. Seems like a poor choice of name for a property? we’re not changing the size of the layer… But yes, then it’s further weird because the slider will not update for any selected points, so when you then want to use the slider, the behavior is like a small glitch.

I think there is value in programmatically setting the size of:

  1. all existing points – in the GUI this would be shown by slider for both the + tool and the selection tool
  2. all selected points (this can easily handle case 1, by select-all) – shown by slider for the selection tool, with those points selected
  3. new-to-be-placed points – shown by slider for the + tool