-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC: canvas rotation #1384
Closed
Closed
POC: canvas rotation #1384
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26e04ec
rotate the entire viewer widget
kecnry 6bcf17f
WIP: oversized canvas
kecnry 924bced
Expose canvas rotation in new plugin
pllim 9bb8aa4
WIP: Disable zoom limits when canvas rotated
pllim c0931d0
WIP: Investigation went nowhere.
pllim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,31 @@ | ||
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 | ||
|
||
viewer = self.app._viewer_by_id(self.viewer_selected) | ||
|
||
# Rotate selected viewer canvas. This changes zoom too. | ||
self.app._viewer_item_by_id(self.viewer_selected)['rotation'] = self._theta | ||
|
||
# Update Compass plugin. | ||
viewer.on_limits_change() |
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> |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rotate to 45 degrees and then rotate back, but the Compass zoom box starts acting weird (i.e., it is showing the zoom limits that is a little off from what I am looking at). Since Compass grabs the numbers straight of
viewer.state.x/y_min/max
attributes, something isn't sync-ing right after this operation but I don't know what. Is it the aspect ratio?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe the WCS distortion in the Imviz example notebook data is causing trouble.