Skip to content

Commit b7be1eb

Browse files
committed
Make highlight feature optional, but enabled by default
1 parent d16cecc commit b7be1eb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/biaplotter/plotter.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ def __init__(
9292
napari_viewer: "napari.viewer.Viewer",
9393
parent: Optional[QWidget] = None,
9494
label_text: str = "Class:",
95+
highlight_enabled: bool = True,
9596
):
9697
super().__init__(napari_viewer, parent=parent)
9798
self.napari_viewer = napari_viewer
9899
self.add_single_axes()
99100

101+
# Highlighting feature toggle
102+
self.highlight_enabled = highlight_enabled
103+
100104
# Initialize UI components
101105
self._initialize_mpl_toolbar()
102106
self._initialize_selector_toolbar(label_text)
@@ -272,8 +276,8 @@ def _on_pick(self, event):
272276
if ind is None or len(ind) == 0:
273277
return
274278

275-
# Toggle highlight for the picked point
276-
if mouse_event.button == 1:
279+
# Toggle highlight for the picked point if enabled
280+
if mouse_event.button == 1 and self.highlight_enabled:
277281
self._toggle_point_highlight(ind[0], allow_multiple_highlights=self._allow_multiple_highlights)
278282

279283
def _toggle_point_highlight(self, index: int, allow_multiple_highlights: bool = False):
@@ -325,8 +329,9 @@ def _on_escape(self, event):
325329
elif self.toolbar.mode == 'pan/zoom':
326330
with self.toolbar.pan_toggled_signal.blocked():
327331
self.toolbar.pan()
328-
# Clear all highlighted points in Scatter and all highlighted bins in Histogram2D
329-
self._clear_all_highlights()
332+
# Only clear highlights if highlighting is enabled
333+
if self.highlight_enabled:
334+
self._clear_all_highlights()
330335

331336
def _on_click(self, event):
332337
"""
@@ -351,7 +356,7 @@ def _on_click(self, event):
351356

352357
elif event.button == 1:
353358
# Ensure the active artist is a Histogram2D instance
354-
if isinstance(self.active_artist, Histogram2D):
359+
if isinstance(self.active_artist, Histogram2D) and self.highlight_enabled:
355360
self._xdata_clicked = event.xdata
356361
self._ydata_clicked = event.ydata
357362

0 commit comments

Comments
 (0)