From 3d461b67d531574fb2b608393aebfa987122b2b1 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 8 Nov 2023 13:36:18 -0500 Subject: [PATCH] only include stretch tool in stretch histogram (#2556) --- CHANGES.rst | 2 +- .../default/plugins/plot_options/plot_options.py | 5 +---- jdaviz/core/template_mixin.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f8c7210d9b..45fa5aecbe 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,7 +7,7 @@ New Features - Plots in plugins now include basic zoom/pan tools for Plot Options, Imviz Line Profiles, and Imviz's aperture photometry. [#2498] -- Histogram plot in Plot Options now includes tool to set stretch vmin and vmax. [#2513] +- Histogram plot in Plot Options now includes tool to set stretch vmin and vmax. [#2513, #2556] - The Plot Options plugin now include a 'spline' stretch feature. [#2525] diff --git a/jdaviz/configs/default/plugins/plot_options/plot_options.py b/jdaviz/configs/default/plugins/plot_options/plot_options.py index 7d2fb92dab..fc2191a843 100644 --- a/jdaviz/configs/default/plugins/plot_options/plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/plot_options.py @@ -18,7 +18,6 @@ from glue_jupyter.bqplot.image.state import BqplotImageLayerState from glue_jupyter.common.toolbar_vuetify import read_icon -from jdaviz.components.toolbar_nested import NestedJupyterToolbar from jdaviz.core.registries import tray_registry from jdaviz.core.template_mixin import (PluginTemplateMixin, ViewerSelect, LayerSelect, PlotOptionsSyncState, Plot, @@ -465,9 +464,7 @@ def state_attr_for_line_visible(state): self.stretch_histogram = Plot(self, viewer_type='histogram') # Add the stretch bounds tool to the default Plot viewer. self.stretch_histogram.tools_nested.append(["jdaviz:stretch_bounds"]) - self.stretch_histogram.toolbar = NestedJupyterToolbar(self.stretch_histogram.viewer, - self.stretch_histogram.tools_nested, - ["jdaviz:stretch_bounds"]) + self.stretch_histogram._initialize_toolbar(["jdaviz:stretch_bounds"]) # NOTE: this is a current workaround so the histogram viewer doesn't crash when replacing # data. Note also that passing x=[0] fails on SOME machines, so we'll pass [0, 1] instead diff --git a/jdaviz/core/template_mixin.py b/jdaviz/core/template_mixin.py index 0ebc5e67af..e36d2d1951 100644 --- a/jdaviz/core/template_mixin.py +++ b/jdaviz/core/template_mixin.py @@ -3273,11 +3273,6 @@ class Plot(PluginSubcomponent): figure = Any().tag(sync=True, **widget_serialization) toolbar = Any().tag(sync=True, **widget_serialization) - tools_nested = [ - ['jdaviz:homezoom', 'jdaviz:prevzoom'], - ['jdaviz:boxzoom', 'jdaviz:xrangezoom', 'jdaviz:yrangezoom'], - ['jdaviz:panzoom', 'jdaviz:panzoom_x', 'jdaviz:panzoom_y'], - ] def __init__(self, plugin, viewer_type='scatter', app=None, *args, **kwargs): super().__init__(plugin, 'Plot', *args, **kwargs) @@ -3299,7 +3294,15 @@ def __init__(self, plugin, viewer_type='scatter', app=None, *args, **kwargs): self.figure.title_style = {'font-size': '12px'} self.figure.fig_margin = {'top': 60, 'bottom': 60, 'left': 60, 'right': 10} - self.toolbar = NestedJupyterToolbar(self.viewer, self.tools_nested, []) + self.tools_nested = [ + ['jdaviz:homezoom', 'jdaviz:prevzoom'], + ['jdaviz:boxzoom', 'jdaviz:xrangezoom', 'jdaviz:yrangezoom'], + ['jdaviz:panzoom', 'jdaviz:panzoom_x', 'jdaviz:panzoom_y'], + ] + self._initialize_toolbar() + + def _initialize_toolbar(self, default_tool_priority=[]): + self.toolbar = NestedJupyterToolbar(self.viewer, self.tools_nested, default_tool_priority) @property def app(self):