Skip to content

Commit

Permalink
Merge pull request glue-viz#384 from astrofrog/fix-tool-activation
Browse files Browse the repository at this point in the history
FIx save/record tools in Qt and volume selection tools in Jupyter
  • Loading branch information
astrofrog authored May 24, 2024
2 parents 006e658 + 4dc4b95 commit 2fdab34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions glue_vispy_viewers/common/selection_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def __init__(self, viewer):
self.current_visible_array = None

def activate(self):
self.viewer.toolbar.activate_tool(self)
self.viewer.toolbar._enable_tool_interactions(self)
self.reset()

def deactivate(self):
self.viewer.toolbar.deactivate_tool(self)
self.viewer.toolbar._disable_tool_interactions(self)
self.reset()

def reset(self):
Expand Down
4 changes: 2 additions & 2 deletions glue_vispy_viewers/common/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

class VispyViewerToolbarMixin:

def activate_tool(self, mode):
def _enable_tool_interactions(self, mode):
if isinstance(mode, VispyMouseMode):
self._vispy_widget.canvas.events.mouse_press.connect(mode.press)
self._vispy_widget.canvas.events.mouse_release.connect(mode.release)
self._vispy_widget.canvas.events.mouse_move.connect(mode.move)
self.disable_camera_events()

def deactivate_tool(self, mode):
def _disable_tool_interactions(self, mode):
if isinstance(mode, VispyMouseMode):
self._vispy_widget.canvas.events.mouse_press.disconnect(mode.press)
self._vispy_widget.canvas.events.mouse_release.disconnect(mode.release)
Expand Down
2 changes: 2 additions & 0 deletions glue_vispy_viewers/volume/jupyter/volume_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ..volume_viewer import VispyVolumeViewerMixin
from .viewer_state_widget import Volume3DViewerStateWidget
from .layer_state_widget import Volume3DLayerStateWidget
from ...common.jupyter.toolbar import VispyJupyterToolbar

__all__ = ['JupyterVispyVolumeViewer']

Expand All @@ -12,6 +13,7 @@ class JupyterVispyVolumeViewer(VispyVolumeViewerMixin, IPyWidgetView):

_options_cls = Volume3DViewerStateWidget
_layer_style_widget_cls = Volume3DLayerStateWidget
_toolbar_cls = VispyJupyterToolbar

def __init__(self, *args, **kwargs):
# Vispy and jupyter_rfb don't work correctly on Linux unless DISPLAY is set
Expand Down

0 comments on commit 2fdab34

Please sign in to comment.