Skip to content

Commit

Permalink
consider bitmap/contour_visible in logic for top image layer (#2818)
Browse files Browse the repository at this point in the history
* consider bitmap/contour_visible in logic for top image layer
* consolidate cubeviz/imviz logic
  • Loading branch information
kecnry authored Apr 19, 2024
1 parent 446fa4f commit a5983b4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Other Changes and Additions
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
---------

Expand Down
5 changes: 0 additions & 5 deletions jdaviz/configs/cubeviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions jdaviz/configs/cubeviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, GlobalDisplayUnitChanged
Expand Down Expand Up @@ -209,18 +208,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 _on_global_display_unit_changed(self, msg):
# Clear cache of slice values when units change
if 'slice_values' in self.__dict__:
Expand Down
3 changes: 2 additions & 1 deletion jdaviz/configs/default/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def active_image_layer(self):
visible_layers = [layer for layer in self.state.layers
if (layer.visible and
layer_is_image_data(layer.layer) and
layer_is_not_dq(layer.layer))]
layer_is_not_dq(layer.layer) and
(layer.bitmap_visible or layer.contour_visible))]
if len(visible_layers) == 0:
return None

Expand Down
6 changes: 5 additions & 1 deletion jdaviz/configs/imviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit a5983b4

Please sign in to comment.