Skip to content

Commit

Permalink
Remove deprecated/stale code (#3270)
Browse files Browse the repository at this point in the history
* remove unused canvas rotation logic

* remove deprecated plugin API access

* remove unused import

* changelog entry

* fix canvas_flip_horizontal -> flip_horizontal in compass

* remove call to set_compass_rotation

* update concept notebook
  • Loading branch information
kecnry authored Nov 14, 2024
1 parent 01553da commit be9180b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 71 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Specviz2d

API Changes
-----------
- Removed API access to plugins that have passed the deprecation period: Links Control, Canvas Rotation, Export Plot. [#3270]

Cubeviz
^^^^^^^
Expand Down
24 changes: 4 additions & 20 deletions jdaviz/configs/imviz/plugins/compass/compass.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from traitlets import Bool, Float, Unicode, observe
from traitlets import Bool, Unicode, observe

from jdaviz.core.events import AddDataMessage, RemoveDataMessage, CanvasRotationChangedMessage
from jdaviz.core.events import AddDataMessage, RemoveDataMessage
from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import (PluginTemplateMixin, ViewerSelectMixin,
skip_if_no_updates_since_last_active)
Expand All @@ -18,7 +18,7 @@ class Compass(PluginTemplateMixin, ViewerSelectMixin):
:ref:`public plugin API <plugin-apis>`:
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.close_in_tray`
* ``viewer`` (:class:`~jdaviz.core.template_mixin.ViewerSelect`):
Viewer to show orientation/compass information.
Expand All @@ -30,15 +30,13 @@ class Compass(PluginTemplateMixin, ViewerSelectMixin):
icon = Unicode("").tag(sync=True)
data_label = Unicode("").tag(sync=True)
img_data = Unicode("").tag(sync=True)
canvas_angle = Float(0).tag(sync=True) # set by canvas rotation plugin
canvas_flip_horizontal = Bool(False).tag(sync=True) # set by canvas rotation plugin
flip_horizontal = Bool(False).tag(sync=True) # set by canvas rotation plugin

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.hub.subscribe(self, AddDataMessage, handler=self._on_viewer_data_changed)
self.hub.subscribe(self, RemoveDataMessage, handler=self._on_viewer_data_changed)
self.hub.subscribe(self, CanvasRotationChangedMessage, handler=self._on_canvas_rotation_changed) # noqa

@property
def user_api(self):
Expand All @@ -49,18 +47,6 @@ def _on_viewer_data_changed(self, msg=None):
viewer = self.viewer.selected_obj
viewer.on_limits_change() # Force redraw

def _on_canvas_rotation_changed(self, msg=None):
viewer_id = msg.viewer_id
if viewer_id != self.viewer_selected:
return

self._set_compass_rotation()

def _set_compass_rotation(self):
viewer_item = self.app._viewer_item_by_id(self.viewer.selected_id)
self.canvas_angle = viewer_item.get('canvas_angle', 0) # noqa
self.canvas_flip_horizontal = viewer_item.get('canvas_flip_horizontal', False)

@observe("viewer_selected", "is_active")
@skip_if_no_updates_since_last_active()
def _compass_with_new_viewer(self, msg={}):
Expand All @@ -76,8 +62,6 @@ def _compass_with_new_viewer(self, msg={}):
if vid == self.viewer.selected_id:
viewer.compass = self
viewer.on_limits_change() # Force redraw

self._set_compass_rotation()
else:
viewer.compass = None

Expand Down
8 changes: 4 additions & 4 deletions jdaviz/configs/imviz/plugins/compass/compass.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:link="docs_link || 'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#compass'"
:uses_active_status="uses_active_status"
@plugin-ping="plugin_ping($event)"
:popout_button="popout_button"
:popout_button="popout_button"
:scroll_to.sync="scroll_to">

<plugin-viewer-select
Expand All @@ -23,16 +23,16 @@
</v-chip>
</v-row>

<img class='invert-in-dark' v-if="img_data" :src="`data:image/png;base64,${img_data}`" :style="'width: 100%; max-width: 400px; margin-top: 50px; transform: rotateY('+viewer_rotateY(canvas_flip_horizontal)+') rotate('+canvas_angle+'deg)'" />
<img class='invert-in-dark' v-if="img_data" :src="`data:image/png;base64,${img_data}`" :style="'width: 100%; max-width: 400px; margin-top: 50px; transform: rotateY('+viewer_rotateY(flip_horizontal)+')'" />

</j-tray-plugin>
</template>

<script>
module.exports = {
methods: {
viewer_rotateY(canvas_flip_horizontal) {
if (canvas_flip_horizontal) {
viewer_rotateY(flip_horizontal) {
if (flip_horizontal) {
return '180deg'
} else {
return '0deg'
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/imviz/wcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def _get_rotated_nddata_from_label(
):
# if an east/west flip is necessary, pass that along to the compass:
compass_plugin = app.get_tray_item_from_name('imviz-compass')
compass_plugin.canvas_flip_horizontal = not compass_plugin.canvas_flip_horizontal
compass_plugin.flip_horizontal = not compass_plugin.flip_horizontal

if cdelt_signs is None:
cdelt_signs = [None, None]
Expand Down
13 changes: 1 addition & 12 deletions jdaviz/container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,14 @@
<jupyter-widget
:widget="viewer.widget"
:ref="'viewer-widget-'+viewer.id"
:style="'width: 100%; height: 100%; overflow: hidden; transform: rotateY('+viewer_rotateY(viewer.canvas_flip_horizontal)+') rotate('+viewer.canvas_angle+'deg)'"
style="width: 100%; height: 100%; overflow: hidden;"
></jupyter-widget>
</v-card>
</gl-component>
</component>
</template>

<style>
.imviz div.v-card.v-card--flat.v-sheet.v-sheet--tile {
/* black background beyond edges of canvas for canvas rotation */
background-color: black
}
</style>

<script>
Expand All @@ -102,13 +98,6 @@ module.exports = {
* between a user closing a tab or a re-render. However, when the user closes a tab, the
* source of the event is a vue component. We can use that distinction as a close signal. */
source.$root && this.closefn(viewerId);
},
viewer_rotateY(canvas_flip_horizontal) {
if (canvas_flip_horizontal) {
return '180deg'
} else {
return '0deg'
}
}
},
computed: {
Expand Down
22 changes: 0 additions & 22 deletions jdaviz/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
'SliceToolStateMessage',
'TableClickMessage', 'LinkUpdatedMessage', 'ExitBatchLoadMessage',
'AstrowidgetMarkersChangedMessage', 'MarkersPluginUpdate',
'CanvasRotationChangedMessage',
'GlobalDisplayUnitChanged', 'ChangeRefDataMessage',
'PluginTableAddedMessage', 'PluginTableModifiedMessage',
'PluginPlotAddedMessage', 'PluginPlotModifiedMessage',
Expand Down Expand Up @@ -393,27 +392,6 @@ def __init__(self, table_length, *args, **kwargs):
self.table_length = table_length


class CanvasRotationChangedMessage(Message):
'''Message generated by canvas rotation plugin'''
def __init__(self, viewer_id, angle, flip_horizontal, *args, **kwargs):
super().__init__(*args, **kwargs)
self._viewer_id = viewer_id
self._angle = angle
self._flip_horizontal = flip_horizontal

@property
def viewer_id(self):
return self._viewer_id

@property
def angle(self):
return self._angle

@property
def flip_horizontal(self):
return self._flip_horizontal


class GlobalDisplayUnitChanged(Message):
'''Message generated when the (x or y axis) unit of the spectrum viewer is
changed, which is used app-wide to inform display units that depend on the
Expand Down
11 changes: 0 additions & 11 deletions jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@ def plugins(self):
for item in self.app.state.tray_items if item['is_relevant']}

# handle renamed plugins during deprecation
if 'Orientation' in plugins:
# renamed in 3.9
plugins['Links Control'] = plugins['Orientation']._obj.user_api
plugins['Links Control']._deprecation_msg = 'in the future, the formerly named \"Links Control\" plugin will only be available by its new name: \"Orientation\".' # noqa
if 'Canvas Rotation' in plugins:
# removed in 3.9
plugins['Canvas Rotation']._deprecation_msg = 'this functionality will be removed in favor of the implementation for rotation in the \"Orientation\" plugin.' # noqa
if 'Export' in plugins:
# renamed in 3.9
plugins['Export Plot'] = plugins['Export']._obj.user_api
plugins['Export Plot']._deprecation_msg = 'in the future, the formerly named \"Export Plot\" plugin will only be available by its new name: \"Export\".' # noqa
if 'Image Profiles (XY)' in plugins:
# renamed in 4.0
plugins['Imviz Line Profiles (XY)'] = plugins['Image Profiles (XY)']._obj.user_api
Expand Down
2 changes: 1 addition & 1 deletion notebooks/concepts/cubeviz_ndarray_gif.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"metadata": {},
"outputs": [],
"source": [
"export_plg = cubeviz2.plugins[\"Export Plot\"]"
"export_plg = cubeviz2.plugins[\"Export\"]"
]
},
{
Expand Down

0 comments on commit be9180b

Please sign in to comment.