From b7be1ebffcf0852ce418aec9f374dc4803393dbc Mon Sep 17 00:00:00 2001 From: Marcelo Zoccoler Date: Tue, 29 Jul 2025 14:48:32 +0200 Subject: [PATCH] Make highlight feature optional, but enabled by default --- src/biaplotter/plotter.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/biaplotter/plotter.py b/src/biaplotter/plotter.py index 563d571..c63709b 100644 --- a/src/biaplotter/plotter.py +++ b/src/biaplotter/plotter.py @@ -92,11 +92,15 @@ def __init__( napari_viewer: "napari.viewer.Viewer", parent: Optional[QWidget] = None, label_text: str = "Class:", + highlight_enabled: bool = True, ): super().__init__(napari_viewer, parent=parent) self.napari_viewer = napari_viewer self.add_single_axes() + # Highlighting feature toggle + self.highlight_enabled = highlight_enabled + # Initialize UI components self._initialize_mpl_toolbar() self._initialize_selector_toolbar(label_text) @@ -272,8 +276,8 @@ def _on_pick(self, event): if ind is None or len(ind) == 0: return - # Toggle highlight for the picked point - if mouse_event.button == 1: + # Toggle highlight for the picked point if enabled + if mouse_event.button == 1 and self.highlight_enabled: self._toggle_point_highlight(ind[0], allow_multiple_highlights=self._allow_multiple_highlights) def _toggle_point_highlight(self, index: int, allow_multiple_highlights: bool = False): @@ -325,8 +329,9 @@ def _on_escape(self, event): elif self.toolbar.mode == 'pan/zoom': with self.toolbar.pan_toggled_signal.blocked(): self.toolbar.pan() - # Clear all highlighted points in Scatter and all highlighted bins in Histogram2D - self._clear_all_highlights() + # Only clear highlights if highlighting is enabled + if self.highlight_enabled: + self._clear_all_highlights() def _on_click(self, event): """ @@ -351,7 +356,7 @@ def _on_click(self, event): elif event.button == 1: # Ensure the active artist is a Histogram2D instance - if isinstance(self.active_artist, Histogram2D): + if isinstance(self.active_artist, Histogram2D) and self.highlight_enabled: self._xdata_clicked = event.xdata self._ydata_clicked = event.ydata