Skip to content

Commit

Permalink
include astrowidgets API
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Nov 27, 2023
1 parent 0480a43 commit 8e7dcb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ API Changes
-----------

- Viewer API now exposed via ``viz.viewer`` dictionary, currently containing APIs to set axes
limits. [#2563]
limits as well as astrowidgets API commands for Imviz. [#2563]

Cubeviz
^^^^^^^
Expand Down
10 changes: 8 additions & 2 deletions jdaviz/configs/default/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from jdaviz.configs.imviz.helper import layer_is_image_data
from jdaviz.components.toolbar_nested import NestedJupyterToolbar
from jdaviz.core.astrowidgets_api import AstrowidgetsImageViewerMixin
from jdaviz.core.registries import viewer_registry
from jdaviz.core.user_api import ViewerUserApi
from jdaviz.utils import ColorCycler, get_subset_type
Expand Down Expand Up @@ -36,8 +37,13 @@ def __init__(self, *args, **kwargs):
def user_api(self):
# default exposed user APIs. Can override this method in any particular viewer.
if isinstance(self, BqplotImageView):
if hasattr(self, 'zoom_level'):
expose = ['zoom', 'zoom_level']
if isinstance(self, AstrowidgetsImageViewerMixin):
expose = ['save',
'center_on', 'offset_by', 'zoom_level', 'zoom',
'colormap_options', 'set_colormap',
'stretch_options', 'stretch',
'autocut_options', 'cuts',
'marker', 'add_markers', 'remove_markers', 'reset_markers']
else:
# cubeviz image viewers don't inherit from AstrowidgetsImageViewerMixin yet,
# but also shouldn't expose set_limits because of equal aspect ratio concerns
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def __init__(self, *args, **kwargs):
def default_viewer(self):
"""Default viewer instance. This is typically the first viewer
(e.g., "imviz-0" or "cubeviz-0")."""
return self._default_viewer
return self._default_viewer.user_api

def load_regions_from_file(self, region_file, region_format='ds9', max_num_regions=20,
**kwargs):
Expand Down

0 comments on commit 8e7dcb5

Please sign in to comment.