Skip to content

Commit

Permalink
Expose canvas rotation in new plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Jun 21, 2022
1 parent 6bcf17f commit 924bced
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Cubeviz
Imviz
^^^^^

- New Simple Image Rotation plugin to rotate the axes of images. [#1384]

Mosviz
^^^^^^

Expand Down
3 changes: 3 additions & 0 deletions docs/reference/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Plugins
.. automodapi:: jdaviz.configs.imviz.plugins.links_control.links_control
:no-inheritance-diagram:

.. automodapi:: jdaviz.configs.imviz.plugins.rotate_image.rotate_image
:no-inheritance-diagram:

.. automodapi:: jdaviz.configs.mosviz.plugins.row_lock.row_lock
:no-inheritance-diagram:

Expand Down
2 changes: 1 addition & 1 deletion jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ def _viewer_by_reference(self, reference):
Returns
-------
`~glue_jupyter.bqplot.common.BqplotBaseView`
viewer : `~glue_jupyter.bqplot.common.BqplotBaseView`
The viewer class instance.
"""
viewer_item = self._viewer_item_by_reference(reference)
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/imviz/imviz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tray:
- imviz-compass
- imviz-line-profile-xy
- imviz-aper-phot-simple
- imviz-rotate-image
- g-export-plot
viewer_area:
- container: col
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/imviz/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from .compass import * # noqa
from .aper_phot_simple import * # noqa
from .line_profile_xy import * # noqa
from .rotate_image import * # noqa
1 change: 1 addition & 0 deletions jdaviz/configs/imviz/plugins/rotate_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .rotate_image import * # noqa
26 changes: 26 additions & 0 deletions jdaviz/configs/imviz/plugins/rotate_image/rotate_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from traitlets import Any

from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import TemplateMixin, ViewerSelectMixin


@tray_registry('imviz-rotate-image', label="Simple Image Rotation")
class RotateImageSimple(TemplateMixin, ViewerSelectMixin):
template_file = __file__, "rotate_image.vue"

angle = Any(0).tag(sync=True)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._theta = 0 # degrees, clockwise

def vue_rotate_image(self, *args, **kwargs):
# We only grab the value here to avoid constantly updating as
# user is still entering or updating the value.
try:
self._theta = float(self.angle)
except Exception:
return

# Rotate selected viewer canvas
self.app._viewer_item_by_id(self.viewer_selected)['rotation'] = self._theta
30 changes: 30 additions & 0 deletions jdaviz/configs/imviz/plugins/rotate_image/rotate_image.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<j-tray-plugin>
<v-row>
<j-docs-link :link="'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#simple-image-rotation'">Rotate image.</j-docs-link>
</v-row>

<plugin-viewer-select
:items="viewer_items"
:selected.sync="viewer_selected"
label="Viewer"
hint="Select viewer."
/>

<v-row>
<v-col>
<v-text-field
v-model="angle"
type="number"
label="Angle"
hint="Rotation angle in degrees clockwise"
></v-text-field>
</v-col>
</v-row>

<v-row justify="end">
<v-btn color="primary" text @click="rotate_image">Rotate</v-btn>
</v-row>

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

0 comments on commit 924bced

Please sign in to comment.