Skip to content

Commit

Permalink
stretch histogram support multi-select (#2582)
Browse files Browse the repository at this point in the history
* stretch histogram support multi-select (but hidden for multiple layers)
* fix updating colorbar when switching between multi/single select
  • Loading branch information
kecnry authored Nov 29, 2023
1 parent 66db3f8 commit c014ee9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^
Expand Down
33 changes: 20 additions & 13 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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])

0 comments on commit c014ee9

Please sign in to comment.