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

Add support for 3D VisPy viewers #453

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Changes from 1 commit
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
Next Next commit
Add support for vispy 3D viewers
astrofrog committed Jun 26, 2024
commit 7897df44b313191ba76c4c13bb83aae50fccfdec
31 changes: 25 additions & 6 deletions glue_jupyter/app.py
Original file line number Diff line number Diff line change
@@ -371,7 +371,7 @@ def scatter2d(self, *, data=None, x=None, y=None, widget='bqplot', color=None,
view.layers[0].state.update_from_dict(layer_state)
return view

def scatter3d(self, *, data=None, x=None, y=None, z=None, show=True):
def scatter3d(self, *, data=None, x=None, y=None, z=None, widget='ipyvolume', show=True):
"""
Open an interactive 3d scatter plot viewer.

@@ -387,17 +387,26 @@ def scatter3d(self, *, data=None, x=None, y=None, z=None, show=True):
The attribute to show on the y axis.
z : str or `~glue.core.component_id.ComponentID`, optional
The attribute to show on the z axis.
widget : {'ipyvolume', 'vispy'}
Whether to use ipyvolume or VisPy as the front-end.
show : bool, optional
Whether to show the view immediately (`True`) or whether to only
show it later if the ``show()`` method is called explicitly
(`False`).
"""

from .ipyvolume import IpyvolumeScatterView
if widget == 'ipyvolume':
from .ipyvolume import IpyvolumeScatterView
viewer_cls = IpyvolumeScatterView
elif widget == 'vispy':
from glue_vispy_viewers.scatter.jupyter import JupyterVispyScatterViewer
viewer_cls = JupyterVispyScatterViewer
else:
raise ValueError("widget= should be 'ipyvolume' or 'vispy'")

data = validate_data_argument(self.data_collection, data)

view = self.new_data_viewer(IpyvolumeScatterView, data=data, show=show)
view = self.new_data_viewer(viewer_cls, data=data, show=show)
if x is not None:
x = data.id[x]
view.state.x_att = x
@@ -500,7 +509,7 @@ def profile1d(self, *, data=None, x=None, widget='bqplot', show=True):

return view

def volshow(self, *, data=None, x=None, y=None, z=None, show=True):
def volshow(self, *, data=None, x=None, y=None, z=None, widget='ipyvolume', show=True):
"""
Open an interactive volume viewer.

@@ -519,16 +528,26 @@ def volshow(self, *, data=None, x=None, y=None, z=None, show=True):
z : str or `~glue.core.component_id.ComponentID`, optional
The attribute to show on the z axis. This should be one of the
pixel axis attributes.
widget : {'ipyvolume', 'vispy'}
Whether to use ipyvolume or VisPy as the front-end.
show : bool, optional
Whether to show the view immediately (`True`) or whether to only
show it later if the ``show()`` method is called explicitly
(`False`).
"""
from .ipyvolume import IpyvolumeVolumeView

if widget == 'ipyvolume':
from .ipyvolume import IpyvolumeVolumeView
viewer_cls = IpyvolumeVolumeView
elif widget == 'vispy':
from glue_vispy_viewers.volume.jupyter import JupyterVispyVolumeViewer
viewer_cls = JupyterVispyVolumeViewer
else:
raise ValueError("widget= should be 'ipyvolume' or 'vispy'")

data = validate_data_argument(self.data_collection, data)

view = self.new_data_viewer(IpyvolumeVolumeView, data=data, show=show)
view = self.new_data_viewer(viewer_cls, data=data, show=show)

if x is not None:
x = data.id[x]