-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose canvas rotation in new plugin
- Loading branch information
Showing
8 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .rotate_image import * # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
30
jdaviz/configs/imviz/plugins/rotate_image/rotate_image.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |