diff --git a/jdaviz/configs/cubeviz/helper.py b/jdaviz/configs/cubeviz/helper.py index c7206327cd..fce4f61b15 100644 --- a/jdaviz/configs/cubeviz/helper.py +++ b/jdaviz/configs/cubeviz/helper.py @@ -18,9 +18,11 @@ class Cubeviz(CubeConfigHelper, LineListMixin): _default_uncert_viewer_reference_name = "uncert-viewer" _default_flux_viewer_reference_name = "flux-viewer" _default_image_viewer_reference_name = "image-viewer" + _cube_viewer_default_label = _default_flux_viewer_reference_name _loaded_flux_cube = None _loaded_uncert_cube = None + _cube_viewer_cls = CubevizImageView def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -28,17 +30,6 @@ def __init__(self, *args, **kwargs): self.app.hub.subscribe(self, AddDataMessage, handler=self._set_spectrum_x_axis) - self._update_slice_defaults() - - def _update_slice_defaults(self): - available_plugins = [ - tray_item['name'] for tray_item in self.app.state.tray_items - ] - if 'cube-slice' in available_plugins: - slice_plugin = self.app.get_tray_item_from_name('cube-slice') - slice_plugin._cube_viewer_default_label = self._default_flux_viewer_reference_name - slice_plugin._cube_viewer_cls = CubevizImageView - def _set_spectrum_x_axis(self, msg): viewer = self.app.get_viewer(self._default_spectrum_viewer_reference_name) if msg.viewer_id != viewer.reference_id: diff --git a/jdaviz/configs/cubeviz/plugins/slice/slice.py b/jdaviz/configs/cubeviz/plugins/slice/slice.py index 88ab2995b2..7bb0e4c149 100644 --- a/jdaviz/configs/cubeviz/plugins/slice/slice.py +++ b/jdaviz/configs/cubeviz/plugins/slice/slice.py @@ -47,8 +47,6 @@ class Slice(PluginTemplateMixin): * ``show_value`` Whether to show slice value in label to right of indicator. """ - _cube_viewer_cls = (CubevizImageView, RampvizImageView) - _cube_viewer_default_label = None # must be filled in by helper on initialization cube_viewer_exists = Bool(True).tag(sync=True) @@ -105,6 +103,18 @@ def __init__(self, *args, **kwargs): handler=self._on_global_display_unit_changed) self._initialize_location() + @property + def _cube_viewer_default_label(self): + if hasattr(self.app, '_jdaviz_helper') and self.app._jdaviz_helper is not None: + return getattr(self.app._jdaviz_helper, '_cube_viewer_default_label') + return tuple() + + @property + def _cube_viewer_cls(self): + if hasattr(self.app, '_jdaviz_helper') and self.app._jdaviz_helper is not None: + return getattr(self.app._jdaviz_helper, '_cube_viewer_cls') + return tuple() + def _initialize_location(self, *args): # initialize value_unit (this has to wait until data is loaded to an existing # slice_indicator_viewer, so we'll keep trying until it is set - after that, changes diff --git a/jdaviz/configs/rampviz/helper.py b/jdaviz/configs/rampviz/helper.py index 2213f09d5e..4fb68c717a 100644 --- a/jdaviz/configs/rampviz/helper.py +++ b/jdaviz/configs/rampviz/helper.py @@ -14,25 +14,16 @@ class Rampviz(CubeConfigHelper): _default_group_viewer_reference_name = "group-viewer" _default_diff_viewer_reference_name = "diff-viewer" _default_integration_viewer_reference_name = "integration-viewer" + _cube_viewer_default_label = _default_group_viewer_reference_name _loaded_flux_cube = None + _cube_viewer_cls = RampvizImageView def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.cube_cache = {} - self._update_slice_defaults() - - def _update_slice_defaults(self): - available_plugins = [ - tray_item['name'] for tray_item in self.app.state.tray_items - ] - if 'cube-slice' in available_plugins: - slice_plugin = self.app.get_tray_item_from_name('cube-slice') - slice_plugin._cube_viewer_default_label = self._default_group_viewer_reference_name - slice_plugin._cube_viewer_cls = RampvizImageView - def load_data(self, data, data_label=None, **kwargs): """ Load and parse a data cube with Cubeviz.