Skip to content
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
15 changes: 10 additions & 5 deletions src/biaplotter/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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

Expand Down
Loading