Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-menu: remove/deprecate old data menu #3281

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions docs/imviz/displayimages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@ Right-click will open a dropdown with access to different options for each butto
Selecting a Data Set
====================

Data can be selected and de-selected in each viewer's data menu, opened by clicking the
|icon-viewer-data-select| button in the top left of the viewer. Here, you can click a
checkbox to the left of the listed data to make the data visible (checked) or invisible
(unchecked). The datasets available in each viewer are filtered
Data can be selected and de-selected in each viewer's data menu, opened by clicking on
the legend in the top right of the viewer. Here, all the data and subset layers are listed
and their visibility can be toggled with the "eye" icon on the right.

To add an addition data layer or interactively create a new subset, click the "+" icon in
the top right of the data menu. The datasets available in each viewer are filtered
to include only compatible data, so you may not see all loaded data in the menu for
every viewer. For example, 1D spectra will not be available in the image viewers.

In addition to selecting and de-selecting data to toggle its visibility in the viewer, you
can also unload the data from the viewer completely by clicking the ``X`` to the right of the
data label. Any data that still exists in Imviz but has been unloaded from the viewer
is listed in a separate section that is hidden by default but can can be expanded by clicking
on the section header:

.. image:: img/imviz_removed_data.png

This section can be hidden by clicking the section header again. Unloaded data will be available
to re-load into the viewer (by clicking the ``+`` icon) or remove permanently from the app (by
clicking the trashcan icon).
Clicking on the rows in the data menu selects entries for further actions available in the
bottom bar of the data menu. Here you can modify selected subsets, or remove layers from
either the viewer or the entire application instance.

.. warning::
Deleting the first image that was loaded into Imviz may be slow, as deleting this image
Expand Down
Binary file removed docs/imviz/img/imviz_removed_data.png
Binary file not shown.
15 changes: 6 additions & 9 deletions docs/specviz/displaying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ for each button.
Selecting/Showing Data Sets
===========================

Data can be selected and de-selected in each viewer's data menu, opened by clicking the
|icon-viewer-data-select| button in the top left of the viewer. Here, you can click a
checkbox next to the listed data to make the data visible (checked) or invisible (unchecked).

.. image:: img/data_tab.png
Data layers can be toggled in each viewer's data menu, opened by clicking the
leged in the top right of the viewer. Here, you can click the "eye" icon
next to the listed data to make the data visible (checked) or invisible (unchecked).

In addition to toggling the visibility of a data layer, the data can be unloaded from a viewer
by clicking the ``X`` button on the right. Data unloaded from the viewer will also be excluded
by clicking on the data row, and selecting "Remove from viewer" in the delete submenu on the
bottom bar. Data unloaded from the viewer will also be excluded
as options from dataset dropdown menus in the various plugins. Unloaded data will be available
to re-load into the viewer (by clicking the ``+`` icon) or remove permanently from the app (by
clicking the trashcan icon) from an expandable section in the data menu:
to re-load into the viewer (by clicking the ``+`` icon in the top right of the data menu).

.. image:: img/specviz_remove_data.png

.. _specviz_cursor_info:

Expand Down
Binary file removed docs/specviz/img/data_tab.png
Binary file not shown.
Binary file removed docs/specviz/img/specviz_remove_data.png
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/specviz2d/displaying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Displaying Spectra
******************

Specviz2D consists of a 2D spectrum viewer and a 1D spectrum viewer, with linked x-axes. Each
viewer window contains a toolbar, including a data menu.
viewer window contains a toolbar, legend, and data menu.

.. seealso::

Expand Down
58 changes: 2 additions & 56 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ def to_unit(self, data, cid, values, original_units, target_units):
custom_components = {'j-tooltip': 'components/tooltip.vue',
'j-external-link': 'components/external_link.vue',
'j-docs-link': 'components/docs_link.vue',
'j-viewer-data-select': 'components/viewer_data_select.vue',
'j-viewer-data-select-item': 'components/viewer_data_select_item.vue',
'j-layer-viewer-icon': 'components/layer_viewer_icon.vue',
'j-layer-viewer-icon-stylized': 'components/layer_viewer_icon_stylized.vue',
'j-tray-plugin': 'components/tray_plugin.vue',
Expand Down Expand Up @@ -433,15 +431,13 @@ def _update_live_plugin_results(self, trigger_data_lbl=None, trigger_subset=None
self.hub.broadcast(SnackbarMessage(
f"Auto-update for {plugin_inputs['add_results']['label']} failed: {e}",
sender=self, color="error"))
# TODO: should we delete the entry (but then any plot options, etc, are lost)
# self.vue_data_item_remove({'item_name': data.label})

def _remove_live_plugin_results(self, trigger_data_lbl=None, trigger_subset=None):
for data, plugin_inputs in self._iter_live_plugin_results(trigger_data_lbl, trigger_subset):
self.hub.broadcast(SnackbarMessage(
f"Removing {data.label} due to deletion of {trigger_subset.label if trigger_subset is not None else trigger_data_lbl}", # noqa
sender=self, color="warning"))
self.vue_data_item_remove({'item_name': data.label})
self.data_item_remove(data.label)

def _on_add_data_message(self, msg):
self._on_layers_changed(msg)
Expand Down Expand Up @@ -1674,12 +1670,6 @@ def remove_data_from_viewer(self, viewer_reference, data_label):
sender=self)
self.hub.broadcast(remove_data_message)

# update data menu entry
selected_items = viewer_item['selected_data_items']
data_id = self._data_id_from_label(data_label)
if data_id in selected_items:
_ = selected_items.pop(data_id)

def _data_id_from_label(self, label):
"""
Retrieve the data item given the Glue ``DataCollection`` data label.
Expand Down Expand Up @@ -2132,19 +2122,6 @@ def remove(stack_items):

self.hub.broadcast(ViewerRemovedMessage(cid, sender=self))

def vue_data_item_unload(self, event):
"""
Callback for selection events in the front-end data list when clicking to unload an entry
from the viewer.
"""
data_label = self._get_data_item_by_id(event['item_id'])['name']
self.remove_data_from_viewer(event['id'], data_label)

def vue_data_item_visibility(self, event):
self.set_data_visibility(event['id'],
self._get_data_item_by_id(event['item_id'])['name'],
visible=event['visible'], replace=event.get('replace', False))

def vue_change_reference_data(self, event):
self._change_reference_data(
self._get_data_item_by_id(event['item_id'])['name'],
Expand Down Expand Up @@ -2254,29 +2231,6 @@ def set_data_visibility(self, viewer_reference, data_label, visible=True, replac
else:
layer.visible = visible

# update data menu - selected_data_items should be READ ONLY, not modified by the user/UI.
# must update the visibility of `data_label` and its children:
selected_items = viewer_item['selected_data_items']
update_data_labels = [data_label] + assoc_children
for update_data_label in update_data_labels:
data_id = self._data_id_from_label(update_data_label)

if replace and update_data_label == data_label:
for id in selected_items:
if id != data_id:
selected_items[id] = 'hidden'

selected_items[data_id] = 'visible' if visible else 'hidden'

# remove WCS-only data from selected items, add to wcs_only_layers:
for layer in viewer.layers:
layer_is_wcs_only = getattr(layer.layer, 'meta', {}).get(_wcs_only_label, False)
if layer.layer.data.label == data_label and layer_is_wcs_only:
layer.visible = False
if data_label not in viewer.state.wcs_only_layers:
viewer.state.wcs_only_layers.append(data_label)
selected_items.pop(data_id)

# Sets the plot axes labels to be the units of the most recently
# active data.
viewer_data_labels = [layer.layer.label for layer in viewer.layers]
Expand All @@ -2286,9 +2240,7 @@ def set_data_visibility(self, viewer_reference, data_label, visible=True, replac
if self.config == 'imviz':
viewer.on_limits_change() # Trigger compass redraw

def vue_data_item_remove(self, event):

data_label = event['item_name']
def data_item_remove(self, data_label):
data = self.data_collection[data_label]
orientation_plugin = self._jdaviz_helper.plugins.get("Orientation")
if orientation_plugin is not None and orientation_plugin.align_by == "WCS":
Expand Down Expand Up @@ -2536,8 +2488,6 @@ def _create_viewer_item(self, viewer, vid=None, name=None, reference=None,
sender=self)
)

wcs_only_layers = getattr(viewer.state, 'wcs_only_layers', [])

reference_data = getattr(viewer.state, 'reference_data', None)
reference_data_label = getattr(reference_data, 'label', None)
linked_by_wcs = getattr(viewer.state, 'linked_by_wcs', False)
Expand All @@ -2548,17 +2498,13 @@ def _create_viewer_item(self, viewer, vid=None, name=None, reference=None,
'widget': "IPY_MODEL_" + viewer.figure_widget.model_id,
'toolbar': "IPY_MODEL_" + viewer.toolbar.model_id if viewer.toolbar else '', # noqa
'data_menu': 'IPY_MODEL_' + viewer._data_menu.model_id if hasattr(viewer, '_data_menu') else '', # noqa
# TODO: remove unused entries after old data menu deprecation period
'selected_data_items': {}, # noqa data_id: visibility state (visible, hidden, mixed), READ-ONLY
'wcs_only_layers': wcs_only_layers,
'reference_data_label': reference_data_label,
'canvas_angle': 0, # canvas rotation clockwise rotation angle in deg
'canvas_flip_horizontal': False, # canvas rotation horizontal flip
'config': self.config, # give viewer access to app config/layout
'collapse': True,
'reference': reference or name or vid,
'linked_by_wcs': linked_by_wcs,
'open_data_menu_if_empty': open_data_menu_if_empty # noqa open menu on init if viewer is empty
}

def _on_new_viewer(self, msg, vid=None, name=None, add_layers_to_viewer=False,
Expand Down
9 changes: 0 additions & 9 deletions jdaviz/components/tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ const tooltips = {
'viewer-toolbar-figure-save': 'Save figure',
'viewer-toolbar-menu': 'Adjust display: contrast, bias, stretch',
'viewer-toolbar-more': 'More options...',
'viewer-data-select-enabled': 'Allow multiple entries (click to enable replace)',
'viewer-data-radio-enabled': 'Replace current entry (click to enable multi-select)',
'viewer-data-select': 'Toggle visibility of all layers associated with this data entry',
'viewer-data-radio': 'Switch visibility to layers associated with this data entry',
'viewer-data-enable': 'Load data entry into this viewer',
'viewer-data-disable': 'Disable data within this viewer (will be hidden and unavailable from plugins until re-enabled)',
'viewer-wcs-delete': 'Remove orientation option across entire app',
'viewer-data-delete': 'Remove data entry across entire app (might affect existing subsets)',
'viewer-data-nowcs': 'Data does not have WCS, cannot add unless link type changed to pixel',

'table-prev': 'Select previous row in table',
'table-next': 'Select next row in table',
Expand Down
Loading
Loading