-
Notifications
You must be signed in to change notification settings - Fork 10
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
enable clone viewer for image/TPF viewer #101
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d3d5b73
enable clone viewer tool in image viewer
kecnry 01a8f7b
include cube viewer in viewer creator
kecnry 7fc4d9d
generalize clone viewer logic to work for multliple viewer types
kecnry 48c311c
remove cube from viewer creator when no cube data remaining
kecnry 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,28 +35,34 @@ def _get_clone_viewer_reference(self): | |
return name | ||
|
||
def clone_viewer(self): | ||
name = self._get_clone_viewer_reference() | ||
name = self.jdaviz_helper._get_clone_viewer_reference(self.reference) | ||
|
||
self.jdaviz_app._on_new_viewer(NewViewerMessage(self.__class__, | ||
data=None, | ||
sender=self.jdaviz_app), | ||
vid=name, name=name) | ||
|
||
this_viewer_item = self.jdaviz_app._get_viewer_item(self.reference) | ||
this_state = self.state.as_dict() | ||
for data in self.jdaviz_app.data_collection: | ||
data_id = self.jdaviz_app._data_id_from_label(data.label) | ||
visible = this_viewer_item['selected_data_items'].get(data_id, 'hidden') | ||
self.jdaviz_app.set_data_visibility(name, data.label, visible == 'visible') | ||
for data_id, visible in this_viewer_item['selected_data_items'].items(): | ||
data_label = data_label = self.jdaviz_app._get_data_item_by_id(data_id)['name'] | ||
self.jdaviz_app.set_data_visibility(name, data_label, visible == 'visible') | ||
# TODO: don't revert color when adding same data to a new viewer | ||
# (same happens when creating a phase-viewer from ephemeris plugin) | ||
|
||
new_viewer = self.jdaviz_helper.viewers[name]._obj | ||
for k, v in this_state.items(): | ||
new_viewer = self.jdaviz_app.get_viewer(name) | ||
if hasattr(self, 'ephemeris_component'): | ||
new_viewer._ephemeris_component = self._ephemeris_component | ||
for k, v in self.state.as_dict().items(): | ||
if k in ('layers',): | ||
continue | ||
setattr(new_viewer.state, k, v) | ||
|
||
for this_layer_state, new_layer_state in zip(self.state.layers, new_viewer.state.layers): | ||
for k, v in this_layer_state.as_dict().items(): | ||
if k in ('layer',): | ||
continue | ||
setattr(new_layer_state, k, v) | ||
|
||
return new_viewer.user_api | ||
|
||
|
||
|
@@ -253,33 +259,6 @@ def apply_roi(self, roi, use_current=False): | |
|
||
super().apply_roi(roi, use_current=use_current) | ||
|
||
def clone_viewer(self): | ||
name = self.jdaviz_helper._get_clone_viewer_reference(self.reference) | ||
|
||
self.jdaviz_app._on_new_viewer(NewViewerMessage(self.__class__, | ||
data=None, | ||
sender=self.jdaviz_app), | ||
vid=name, name=name) | ||
|
||
this_viewer_item = self.jdaviz_app._get_viewer_item(self.reference) | ||
this_state = self.state.as_dict() | ||
for data in self.jdaviz_app.data_collection: | ||
data_id = self.jdaviz_app._data_id_from_label(data.label) | ||
visible = this_viewer_item['selected_data_items'].get(data_id, 'hidden') | ||
self.jdaviz_app.set_data_visibility(name, data.label, visible == 'visible') | ||
# TODO: don't revert color when adding same data to a new viewer | ||
# (same happens when creating a phase-viewer from ephemeris plugin) | ||
|
||
new_viewer = self.jdaviz_app.get_viewer(name) | ||
if hasattr(self, 'ephemeris_component'): | ||
new_viewer._ephemeris_component = self._ephemeris_component | ||
for k, v in this_state.items(): | ||
if k in ('layers',): | ||
continue | ||
setattr(new_viewer.state, k, v) | ||
|
||
return new_viewer.user_api | ||
|
||
Comment on lines
-256
to
-282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was duplicated logic that was somehow introduced when refactoring to use the mixin for clone viewer support |
||
|
||
@viewer_registry("lcviz-phase-viewer", label="flux-vs-phase") | ||
class PhaseScatterView(TimeScatterView): | ||
|
@@ -320,7 +299,7 @@ class CubeView(CloneViewerMixin, CubevizImageView, WithSliceSelection): | |
['jdaviz:boxzoom'], | ||
['jdaviz:panzoom'], | ||
['bqplot:rectangle'], | ||
['jdaviz:sidebar_plot', 'jdaviz:sidebar_export'] | ||
['lcviz:viewer_clone', 'jdaviz:sidebar_plot', 'jdaviz:sidebar_export'] | ||
] | ||
# TODO: can we vary this default_class based on Kepler vs TESS, etc? | ||
# see https://github.com/spacetelescope/lcviz/pull/81#discussion_r1469721009 | ||
|
@@ -337,8 +316,8 @@ def __init__(self, *args, **kwargs): | |
# Hide axes by default | ||
self.state.show_axes = False | ||
|
||
# TODO: refactor upstream so lcviz can inherit cubeviewer methods/setup with jdaviz-specific | ||
# logic: | ||
# TODO: refactor upstream so lcviz can inherit cubeviewer methods/setup without | ||
# jdaviz-specific logic: | ||
# * _default_spectrum_viewer_reference_name | ||
# * _default_flux_viewer_reference_name | ||
# * _default_uncert_viewer_reference_name | ||
|
Oops, something went wrong.
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.
right now this enables creating an "image" viewer if there is any cube-like data in the app. In the future, we may want to change this to allow image-like data, but that is not yet supported at the parser level.