diff --git a/CHANGES.rst b/CHANGES.rst index e3c633b83c..2ba291912d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,7 +23,7 @@ New Features - Plugin APIs now include a ``close_in_tray()`` method. [#2562] -- Convert the layer select dropdown in Plot Options into a horizontal panel of buttons. [#2566, #2574] +- Convert the layer select dropdown in Plot Options into a horizontal panel of buttons. [#2566, #2574, #2582] Cubeviz ^^^^^^^ diff --git a/jdaviz/configs/default/plugins/plot_options/plot_options.py b/jdaviz/configs/default/plugins/plot_options/plot_options.py index a5ad8cbe69..8842ba298b 100644 --- a/jdaviz/configs/default/plugins/plot_options/plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/plot_options.py @@ -705,8 +705,7 @@ def _update_stretch_histogram(self, msg={}): return if not self.viewer.selected or not self.layer.selected: # pragma: no cover - # nothing to plot - self.stretch_histogram.clear_all_marks() + # nothing to plot, will be hidden in UI return if self.layer_multiselect and len(self.layer.selected) > 1: @@ -819,6 +818,7 @@ def _update_stretch_histogram(self, msg={}): 'stretch_hist_nbins', 'stretch_curve_visible', 'stretch_function_value', 'stretch_vmin_value', 'stretch_vmax_value', + 'layer_multiselect' ) @skip_if_no_updates_since_last_active() def _update_stretch_curve(self, msg=None): @@ -827,19 +827,19 @@ def _update_stretch_curve(self, msg=None): # or the stretch histogram hasn't been initialized: return - if self.viewer_multiselect or self.layer_multiselect: - self.stretch_histogram.clear_marks('stretch_curve', 'stretch_knots', 'colorbar') + if self.layer_multiselect and len(self.layer.selected) > 1: + # currently only support single-layer, if multiple layers are selected, the plot + # will be hidden in the UI return - if len(self.layer.selected_obj): - layer = self.layer.selected_obj[0] - else: - # skip further updates if no data are available: - return + # could be multi or single-viewer and/or multi-layer with a single entry, + # either way, we act on the first entry + layer = self.layer.selected_obj[0] + while isinstance(layer, list): + layer = layer[0] if isinstance(layer.layer, GroupedSubset): - # don't update histogram for subsets: - self.stretch_histogram.clear_marks('stretch_curve', 'stretch_knots', 'colorbar') + # don't update histogram for subsets, will be hidden in UI return # create the new/updated stretch curve following the colormapping @@ -945,5 +945,12 @@ def _viewer_is_image_viewer(self): from jdaviz.configs.cubeviz.plugins.viewers import CubevizImageView from jdaviz.configs.mosviz.plugins.viewers import MosvizImageView, MosvizProfile2DView - return isinstance(self.viewer.selected_obj, (ImvizImageView, CubevizImageView, - MosvizImageView, MosvizProfile2DView)) + def _is_image_viewer(viewer): + return isinstance(viewer, (ImvizImageView, CubevizImageView, + MosvizImageView, MosvizProfile2DView)) + + viewers = self.viewer.selected_obj + if not isinstance(viewers, list): + viewers = [viewers] + + return np.all([_is_image_viewer(viewer) for viewer in viewers])