Skip to content

Commit

Permalink
Use rotation attribute like astrofrog said.
Browse files Browse the repository at this point in the history
Looks like angle is clockwise again, not counter-clockwise.
  • Loading branch information
pllim committed Aug 16, 2022
1 parent 481c578 commit fdab918
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ Simple Image Rotation

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

.. _line-profile-xy:
Expand Down
14 changes: 6 additions & 8 deletions jdaviz/configs/imviz/plugins/rotate_image/rotate_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from matplotlib.transforms import Affine2D
import math

from traitlets import Any

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

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

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

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

# TODO: Does the zoom box behave? If not, we need to disable it.
# TODO: Zoom box in Compass still broken, how to fix? If not, we need to disable it.
# Update Compass plugin.
viewer.on_limits_change()
2 changes: 1 addition & 1 deletion jdaviz/configs/imviz/plugins/rotate_image/rotate_image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
v-model="angle"
type="number"
label="Angle"
hint="Rotation angle in degrees counter-clockwise"
hint="Rotation angle in degrees clockwise"
></v-text-field>
</v-col>
</v-row>
Expand Down

0 comments on commit fdab918

Please sign in to comment.