From 2f24a20ebcf3b845ebfd0d2edf7f95fefba30ef3 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 12 Oct 2023 13:15:04 -0400 Subject: [PATCH] Plugin plots to viewers (#2498) * create separate app instance with glue-viewer * nested toolbar in plugin viewers * migrate implementation for scatter viewers (radial profile, line profiles) and histogram (stretch in plot options) * downsampling no longer necessary * lose logic to ensure vmin/max markers are within viewer range (might be confusing) * home button on histogram viewer is buggy * update tests * temporary workaround to segfault on some machines * bump glue-jupyter to ensure scatter lines support --- CHANGES.rst | 3 + jdaviz/app.vue | 19 +- jdaviz/components/plugin_plot.vue | 11 +- jdaviz/components/toolbar_nested.py | 11 +- jdaviz/components/toolbar_nested.vue | 6 +- .../plugins/plot_options/plot_options.py | 99 ++++------ .../plot_options/tests/test_plot_options.py | 35 ++-- .../aper_phot_simple/aper_phot_simple.py | 54 ++++-- .../line_profile_xy/line_profile_xy.py | 69 +++---- .../imviz/tests/test_line_profile_xy.py | 20 +- .../imviz/tests/test_simple_aper_phot.py | 2 +- jdaviz/core/template_mixin.py | 176 +++++++++++++++--- pyproject.toml | 2 +- 13 files changed, 324 insertions(+), 183 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 6196f6a6dd..1d7aca0c39 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ New Features ------------ +- Plots in plugins now include basic zoom/pan tools for Plot Options, + Imviz Line Profiles, and Imviz's aperture photometry. [#2498] + Cubeviz ^^^^^^^ diff --git a/jdaviz/app.vue b/jdaviz/app.vue index 5b08c49f28..1aeadbef48 100644 --- a/jdaviz/app.vue +++ b/jdaviz/app.vue @@ -360,7 +360,12 @@ a:active { text-decoration: none; } -.jdaviz-nested-toolbar { +.invert, .invert-if-dark.theme--dark { + filter: invert(1) saturate(1) brightness(100); + color: white; +} + +.jdaviz-nested-toolbar, .plugin-nested-toolbar { /* height of nested toolbar to match viewer toolbar height */ height: 42px; margin-right: 4px; @@ -371,12 +376,7 @@ a:active { filter: invert(1) saturate(1) brightness(100); } -.invert, .invert-if-dark.theme--dark { - filter: invert(1) saturate(1) brightness(100); - color: white; -} - -.jdaviz-nested-toolbar .v-btn { +.jdaviz-nested-toolbar .v-btn, .plugin-nested-toolbar .v-btn { height: 42px !important; border: none !important; min-width: 42px !important; @@ -394,6 +394,11 @@ a:active { background-color: #c75109 !important; } +.plugin-nested-toolbar .v-btn--active, .plugin-nested-toolbar .v-btn:focus { + /* semi-transparent active color (orange) */ + background-color: #c7510996 !important; +} + .v-divider.theme--dark { /* make the v-divider standout more */ border-color: hsla(0,0%,100%,.35) !important; diff --git a/jdaviz/components/plugin_plot.vue b/jdaviz/components/plugin_plot.vue index cdc9ac7ec7..f751c03f24 100644 --- a/jdaviz/components/plugin_plot.vue +++ b/jdaviz/components/plugin_plot.vue @@ -1,7 +1,9 @@ - diff --git a/jdaviz/components/toolbar_nested.py b/jdaviz/components/toolbar_nested.py index 67bdbec019..60ae60f0ad 100644 --- a/jdaviz/components/toolbar_nested.py +++ b/jdaviz/components/toolbar_nested.py @@ -65,10 +65,13 @@ def __init__(self, viewer, tools_nested, default_tool_priority=[]): self.default_tool_priority = default_tool_priority self._handle_default_tool() - for msg in (AddDataMessage, RemoveDataMessage, ViewerAddedMessage, ViewerRemovedMessage, - SpectralMarksChangedMessage): - self.viewer.hub.subscribe(self, msg, - handler=lambda _: self._update_tool_visibilities()) + # toolbars in the main app viewers need to respond to the data-collection, etc, + # but those in plugins do not + if hasattr(self.viewer, 'hub'): + for msg in (AddDataMessage, RemoveDataMessage, ViewerAddedMessage, ViewerRemovedMessage, + SpectralMarksChangedMessage): + self.viewer.hub.subscribe(self, msg, + handler=lambda _: self._update_tool_visibilities()) def _is_visible(self, tool_id): # tools can optionally implement self.is_visible(). If not NotImplementedError diff --git a/jdaviz/components/toolbar_nested.vue b/jdaviz/components/toolbar_nested.vue index ff06e7979f..d698ef5d84 100644 --- a/jdaviz/components/toolbar_nested.vue +++ b/jdaviz/components/toolbar_nested.vue @@ -4,8 +4,8 @@ {{ tooltip }}{{has_suboptions ? " [right-click for alt. tools]" : ""}} @@ -81,7 +81,7 @@ } -