diff --git a/docs/cubeviz/displaycubes.rst b/docs/cubeviz/displaycubes.rst index bca8745d8a..7a3ebb01a7 100644 --- a/docs/cubeviz/displaycubes.rst +++ b/docs/cubeviz/displaycubes.rst @@ -111,6 +111,11 @@ You can also use the subset modes that are explained in the :ref:`Spatial Regions ` section above in the same way you would with the other subset selection tools. +Note that moving the cursor outside of the image viewer or deactivating the spectrum-at-spaxel tool +will revert the spectrum viewer zoom limits from the zoomed-in preview view to the limits set prior +to using the tool. Thus it may be necessary to reset the zoom to see any single-spaxel subset spectra +created using the tool. + .. _cubeviz-display-settings: Display Settings diff --git a/jdaviz/configs/cubeviz/plugins/tools.py b/jdaviz/configs/cubeviz/plugins/tools.py index 07a4f5ee5e..a540e3c7f2 100644 --- a/jdaviz/configs/cubeviz/plugins/tools.py +++ b/jdaviz/configs/cubeviz/plugins/tools.py @@ -89,9 +89,17 @@ class SpectrumPerSpaxel(SinglePixelRegion): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._spectrum_viewer = None + self._previous_bounds = None self._mark = None self._data = None + def _reset_spectrum_viewer_bounds(self): + sv_state = self._spectrum_viewer.state + sv_state.x_min = self._previous_bounds[0] + sv_state.x_max = self._previous_bounds[1] + sv_state.y_min = self._previous_bounds[2] + sv_state.y_max = self._previous_bounds[3] + def activate(self): self.viewer.add_event_callback(self.on_mouse_move, events=['mousemove', 'mouseleave']) if self._spectrum_viewer is None: @@ -99,15 +107,20 @@ def activate(self): if self._mark is None: self._mark = PluginLine(self._spectrum_viewer, visible=False) self._spectrum_viewer.figure.marks = self._spectrum_viewer.figure.marks + [self._mark,] + # Store these so we can revert to previous user-set zoom after preview view + sv_state = self._spectrum_viewer.state + self._previous_bounds = [sv_state.x_min, sv_state.x_max, sv_state.y_min, sv_state.y_max] super().activate() def deactivate(self): self.viewer.remove_event_callback(self.on_mouse_move) + self._reset_spectrum_viewer_bounds() super().deactivate() def on_mouse_move(self, data): if data['event'] == 'mouseleave': self._mark.visible = False + self._reset_spectrum_viewer_bounds() return x = int(np.round(data['domain']['x']))