Skip to content

Commit fdab918

Browse files
committed
Use rotation attribute like astrofrog said.
Looks like angle is clockwise again, not counter-clockwise.
1 parent 481c578 commit fdab918

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

docs/imviz/plugins.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ Simple Image Rotation
113113

114114
This plugins rotates image(s) by the given angle.
115115
You can select viewer but that option only shows when applicable.
116-
You can enter the desired rotation angle in degrees counter-clockwise.
116+
You can enter the desired rotation angle in degrees clockwise.
117+
This angle is absolute, i.e., relative to original image orientation, not the current rotation.
117118
Click on the :guilabel:`ROTATE` button to finalize.
118119

119120
.. _line-profile-xy:

jdaviz/configs/imviz/plugins/rotate_image/rotate_image.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from matplotlib.transforms import Affine2D
1+
import math
2+
23
from traitlets import Any
34

45
from jdaviz.core.registries import tray_registry
@@ -13,7 +14,7 @@ class RotateImageSimple(TemplateMixin, ViewerSelectMixin):
1314

1415
def __init__(self, *args, **kwargs):
1516
super().__init__(*args, **kwargs)
16-
self._theta = 0 # degrees, counter-clockwise
17+
self._theta = 0 # degrees, clockwise
1718

1819
def vue_rotate_image(self, *args, **kwargs):
1920
# We only grab the value here to avoid constantly updating as
@@ -26,12 +27,9 @@ def vue_rotate_image(self, *args, **kwargs):
2627
viewer = self.app._viewer_by_id(self.viewer_selected)
2728

2829
# Rotate selected viewer canvas.
29-
# TODO: This changes zoom too? astrofrog will fix translation issue?
30-
y_hub = (viewer.scales['y'].min + viewers.scales['y'].max) / 2
31-
x_hub = (viewer.scales['x'].min + viewer.scales['x'].max) / 2
32-
affine_transform = Affine2D().rotate_deg_around(y_hub, x_hub, self._theta)
33-
viewer.state.affine_matrix = affine_transform
30+
# TODO: Translation still a bit broken if zoomed in.
31+
viewer.state.rotation = math.radians(self._theta)
3432

35-
# TODO: Does the zoom box behave? If not, we need to disable it.
33+
# TODO: Zoom box in Compass still broken, how to fix? If not, we need to disable it.
3634
# Update Compass plugin.
3735
viewer.on_limits_change()

jdaviz/configs/imviz/plugins/rotate_image/rotate_image.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
v-model="angle"
1818
type="number"
1919
label="Angle"
20-
hint="Rotation angle in degrees counter-clockwise"
20+
hint="Rotation angle in degrees clockwise"
2121
></v-text-field>
2222
</v-col>
2323
</v-row>

0 commit comments

Comments
 (0)