Skip to content

Commit 93d1b45

Browse files
committed
WIP: POC on glue and glue-jupyter POC
[ci skip]
1 parent aa86ecb commit 93d1b45

File tree

9 files changed

+94
-2
lines changed

9 files changed

+94
-2
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Imviz
1616
- New "Catalog Search" plugin that uses a specified catalog (currently SDSS) to search for sources in an image
1717
and mark the sources found. [#1455]
1818

19+
- New Simple Image Rotation plugin to rotate the axes of images. [#1551]
20+
1921
Mosviz
2022
^^^^^^
2123
- NIRISS parser now sorts FITS files by header instead of file name. [#819]

docs/imviz/plugins.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ data label, the X and Y directions, and the zoom box.
9191
When you have multiple viewers created in Imviz, use the Viewer dropdown menu
9292
to change the active viewer that it tracks.
9393

94+
.. _rotate-image-simple:
95+
96+
Simple Image Rotation
97+
=====================
98+
99+
.. warning::
100+
101+
Distortion is ignored, so using this plugin on distorted data is
102+
not recommended.
103+
104+
.. note::
105+
106+
Zoom box in :ref:`imviz-compass` will not show when rotation mode is on.
107+
108+
This plugins rotates image(s) by the given angle.
109+
You can select viewer but that option only shows when applicable.
110+
You can enter the desired rotation angle in degrees clockwise.
111+
Click on the :guilabel:`ROTATE` button to finalize.
112+
94113
.. _line-profile-xy:
95114

96115
Line Profiles

docs/reference/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ Plugins
126126
.. automodapi:: jdaviz.configs.imviz.plugins.links_control.links_control
127127
:no-inheritance-diagram:
128128

129+
.. automodapi:: jdaviz.configs.imviz.plugins.rotate_image.rotate_image
130+
:no-inheritance-diagram:
131+
129132
.. automodapi:: jdaviz.configs.mosviz.plugins.row_lock.row_lock
130133
:no-inheritance-diagram:
131134

jdaviz/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ def _viewer_by_reference(self, reference):
11181118
11191119
Returns
11201120
-------
1121-
`~glue_jupyter.bqplot.common.BqplotBaseView`
1121+
viewer : `~glue_jupyter.bqplot.common.BqplotBaseView`
11221122
The viewer class instance.
11231123
"""
11241124
viewer_item = self._viewer_item_by_reference(reference)

jdaviz/configs/imviz/imviz.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ tray:
2323
- g-subset-plugin
2424
- imviz-links-control
2525
- imviz-compass
26+
- imviz-rotate-image
2627
- imviz-line-profile-xy
2728
- imviz-aper-phot-simple
2829
- imviz-catalogs

jdaviz/configs/imviz/plugins/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .coords_info import * # noqa
66
from .links_control import * # noqa
77
from .compass import * # noqa
8+
from .rotate_image import * # noqa
89
from .aper_phot_simple import * # noqa
910
from .line_profile_xy import * # noqa
10-
from .catalogs import * # noqa
11+
from .catalogs import * # noqa
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .rotate_image import * # noqa
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from matplotlib.transforms import Affine2D
2+
from traitlets import Any
3+
4+
from jdaviz.core.registries import tray_registry
5+
from jdaviz.core.template_mixin import TemplateMixin, ViewerSelectMixin
6+
7+
8+
@tray_registry('imviz-rotate-image', label="Simple Image Rotation")
9+
class RotateImageSimple(TemplateMixin, ViewerSelectMixin):
10+
template_file = __file__, "rotate_image.vue"
11+
12+
angle = Any(0).tag(sync=True)
13+
14+
def __init__(self, *args, **kwargs):
15+
super().__init__(*args, **kwargs)
16+
self._theta = 0 # degrees, clockwise
17+
18+
def vue_rotate_image(self, *args, **kwargs):
19+
# We only grab the value here to avoid constantly updating as
20+
# user is still entering or updating the value.
21+
try:
22+
self._theta = float(self.angle)
23+
except Exception:
24+
return
25+
26+
viewer = self.app._viewer_by_id(self.viewer_selected)
27+
28+
# TODO: Is this really clockwise? Does it take negative angle?
29+
# Rotate selected viewer canvas. This changes zoom too.
30+
affine_transform = Affine2D().rotate_deg(self._theta)
31+
viewer.state.affine_matrix = affine_transform
32+
33+
# TODO: Does the zoom box behave? If not, we need to disable it.
34+
# Update Compass plugin.
35+
viewer.on_limits_change()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<j-tray-plugin>
3+
<v-row>
4+
<j-docs-link :link="'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#simple-image-rotation'">Rotate image.</j-docs-link>
5+
</v-row>
6+
7+
<plugin-viewer-select
8+
:items="viewer_items"
9+
:selected.sync="viewer_selected"
10+
label="Viewer"
11+
hint="Select viewer."
12+
/>
13+
14+
<v-row>
15+
<v-col>
16+
<v-text-field
17+
v-model="angle"
18+
type="number"
19+
label="Angle"
20+
hint="Rotation angle in degrees clockwise"
21+
></v-text-field>
22+
</v-col>
23+
</v-row>
24+
25+
<v-row justify="end">
26+
<v-btn color="primary" text @click="rotate_image">Rotate</v-btn>
27+
</v-row>
28+
29+
</j-tray-plugin>
30+
</template>

0 commit comments

Comments
 (0)