diff --git a/CHANGES.rst b/CHANGES.rst index 602fe56d63..484db76144 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,9 @@ 3.9.1 (unreleased) ================== +- Fix mouseover display's top-layer logic to account for the visibility and contour toggles in + the plot options plugin. [#2818] + Bug Fixes --------- diff --git a/jdaviz/configs/cubeviz/helper.py b/jdaviz/configs/cubeviz/helper.py index d0f5f2c89e..1b6df6f293 100644 --- a/jdaviz/configs/cubeviz/helper.py +++ b/jdaviz/configs/cubeviz/helper.py @@ -2,7 +2,6 @@ from astropy.io import fits from astropy.io import registry as io_registry from astropy.utils.decorators import deprecated -from glue.core import BaseData from specutils import Spectrum1D from specutils.io.registers import _astropy_has_priorities @@ -181,10 +180,6 @@ def get_aperture_photometry_results(self): return self.plugins['Aperture Photometry']._obj.export_table() -def layer_is_cube_image_data(layer): - return isinstance(layer, BaseData) and layer.ndim in (2, 3) - - # TODO: We can remove this when specutils supports it, i.e., # https://github.com/astropy/specutils/issues/592 and # https://github.com/astropy/specutils/pull/1009 diff --git a/jdaviz/configs/cubeviz/plugins/viewers.py b/jdaviz/configs/cubeviz/plugins/viewers.py index f2fb530238..b9118b877d 100644 --- a/jdaviz/configs/cubeviz/plugins/viewers.py +++ b/jdaviz/configs/cubeviz/plugins/viewers.py @@ -9,7 +9,6 @@ from jdaviz.core.registries import viewer_registry from jdaviz.core.marks import SliceIndicatorMarks, ShadowSpatialSpectral -from jdaviz.configs.cubeviz.helper import layer_is_cube_image_data from jdaviz.configs.default.plugins.viewers import JdavizViewerMixin from jdaviz.configs.specviz.plugins.viewers import SpecvizProfileView from jdaviz.core.events import AddDataMessage, RemoveDataMessage @@ -155,18 +154,6 @@ def _default_flux_viewer_reference_name(self): def _default_uncert_viewer_reference_name(self): return self.jdaviz_helper._default_uncert_viewer_reference_name - @property - def active_image_layer(self): - """Active image layer in the viewer, if available.""" - # Find visible layers - visible_layers = [layer for layer in self.state.layers - if (layer.visible and layer_is_cube_image_data(layer.layer))] - - if len(visible_layers) == 0: - return None - - return visible_layers[-1] - def _initial_x_axis(self, *args): # Make sure that the x_att is correct on data load ref_data = self.state.reference_data diff --git a/jdaviz/configs/default/plugins/viewers.py b/jdaviz/configs/default/plugins/viewers.py index 415d844c91..a6f6eb59fa 100644 --- a/jdaviz/configs/default/plugins/viewers.py +++ b/jdaviz/configs/default/plugins/viewers.py @@ -314,8 +314,9 @@ def active_image_layer(self): """Active image layer in the viewer, if available.""" # Find visible layers visible_layers = [layer for layer in self.state.layers - if (layer.visible and layer_is_image_data(layer.layer))] - + if (layer.visible and + layer_is_image_data(layer.layer) and + (layer.bitmap_visible or layer.contour_visible))] if len(visible_layers) == 0: return None diff --git a/jdaviz/configs/imviz/helper.py b/jdaviz/configs/imviz/helper.py index 6375818558..6e709c256d 100644 --- a/jdaviz/configs/imviz/helper.py +++ b/jdaviz/configs/imviz/helper.py @@ -398,8 +398,12 @@ def layer_is_2d(layer): return isinstance(layer, BaseData) and layer.ndim == 2 +def layer_is_2d_or_3d(layer): + return isinstance(layer, BaseData) and layer.ndim in (2, 3) + + def layer_is_image_data(layer): - return layer_is_2d(layer) and not layer.meta.get(_wcs_only_label, False) + return layer_is_2d_or_3d(layer) and not layer.meta.get(_wcs_only_label, False) def layer_is_wcs_only(layer):