Skip to content

Commit

Permalink
sort data-menu, legend, and plot options tabs by z-order
Browse files Browse the repository at this point in the history
NOTE: for plot-options, when multiple viewers are selected, this will just take the z-order from the first viewer.
  • Loading branch information
kecnry committed Nov 14, 2024
1 parent 9443cfa commit 0869b57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions jdaviz/configs/default/plugins/data_menu/data_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(self, viewer, *args, **kwargs):
self.layer.remove_filter('filter_is_root')
self.layer.add_filter(is_not_wcs_only)
self.layer.multiselect = True
self.layer.sort_by = 'zorder'
self.layer._default_mode = 'empty'

# we'll use a modified version of the dataset mixin to have a filtered
Expand Down Expand Up @@ -218,8 +219,7 @@ def _dm_layer_selected_changed(self, event={}):
with self.during_select_sync():
# map index in dm_layer_selected (inverse order of layer_items)
# to set self.layer.selected
length = len(self.layer_items)
self.layer.selected = [self.layer_items[length-1-i]['label']
self.layer.selected = [self.layer_items[i]['label']
for i in self.dm_layer_selected]

@observe('layer_selected', 'layer_items')
Expand All @@ -229,7 +229,7 @@ def _layers_changed(self, event={}):
if not self._during_select_sync:
with self.during_select_sync():
# map list of strings in self.layer.selected to indices in dm_layer_selected
layer_labels = [layer['label'] for layer in self.layer_items][::-1]
layer_labels = [layer['label'] for layer in self.layer_items]
self.dm_layer_selected = [layer_labels.index(label) for label in self.layer.selected
if label in layer_labels]

Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/default/plugins/data_menu/data_menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<span class="invert-if-dark" style="margin-left: 30px; margin-right: 36px; line-height: 28px">{{viewer_reference || viewer_id}}</span>
</div>

<div v-for="item in layer_items.slice().reverse()" class="viewer-label">
<div v-for="item in layer_items" class="viewer-label">
<div v-if="item.visible">
<span style="float: right">
<j-layer-viewer-icon-stylized
Expand Down Expand Up @@ -142,7 +142,7 @@
dense
>
<div>
<v-list-item v-for="item in layer_items.slice().reverse()">
<v-list-item v-for="item in layer_items">
<v-list-item-icon>
<j-layer-viewer-icon-stylized
:label="item.label"
Expand Down
3 changes: 2 additions & 1 deletion jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ class PlotOptions(PluginTemplateMixin, ViewerSelectMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.layer = LayerSelect(self, 'layer_items', 'layer_selected',
'viewer_selected', 'layer_multiselect')
'viewer_selected', 'layer_multiselect',
sort_by='zorder')

self.layer.filters += [is_not_wcs_only]

Expand Down

0 comments on commit 0869b57

Please sign in to comment.