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 point highlight thickness #6896

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions napari/_vispy/layers/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ def _on_highlight_change(self):
border_width = np.array([0])

scale = self.layer.scale[-1]
scaled_highlight = (
settings.appearance.highlight.highlight_thickness
* self.layer.scale_factor
)
highlight_thickness = settings.appearance.highlight.highlight_thickness
scaled_highlight = highlight_thickness * self.layer.scale_factor
scaled_size = (size + border_width) * scale
highlight_color = tuple(settings.appearance.highlight.highlight_color)

self.node.selection_markers.set_data(
data[:, ::-1],
size=(size + border_width) * scale,
size=scaled_size,
symbol=symbol,
edge_width=scaled_highlight * 2,
edge_color=highlight_color,
Expand All @@ -131,15 +130,13 @@ def _on_highlight_change(self):
or 0 in self.layer._highlight_box.shape
):
pos = np.zeros((1, self.layer._slice_input.ndisplay))
width = 0
Copy link
Member

Choose a reason for hiding this comment

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

This change is responsible for the example crashing reported:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/vispy.20.22Last.20dimension.20should.20be.202.20not.203.22.20error

@dalthviz you can try highlight_thickness = 0 here maybe this also fixes #6819 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahn... For some reason I though it was initialized at 0 and this was a noop... My bad :/

Copy link
Member

Choose a reason for hiding this comment

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

Checked and seems like for #6819 (comment) the change is not enough but thank you for letting me know!

else:
pos = self.layer._highlight_box
width = scaled_highlight

self.node.highlight_lines.set_data(
pos=pos[:, ::-1],
color=highlight_color,
width=width,
width=highlight_thickness,
)

self.node.update()
Expand Down Expand Up @@ -195,14 +192,13 @@ def _on_canvas_size_limits_change(self):
self.node.points_markers.canvas_size_limits = (
self.layer.canvas_size_limits
)
scaled_highlight = (
highlight_thickness = (
get_settings().appearance.highlight.highlight_thickness
* self.layer.scale_factor
)
low, high = self.layer.canvas_size_limits
self.node.selection_markers.canvas_size_limits = (
low + scaled_highlight,
high + scaled_highlight,
low + highlight_thickness,
high + highlight_thickness,
)
self.node.update()

Expand Down
Loading