From fbf1403fbed617c9cffc80934490de2797558571 Mon Sep 17 00:00:00 2001 From: Kyle Ma Date: Mon, 24 Feb 2025 10:41:57 -0500 Subject: [PATCH 1/4] Revert "added crosshair option similar to matplotlib" This reverts commit f7d9c30f1729aead046d2000580706b04c3d16b1. --- .../workbench/plotting/figuremanager.py | 40 ++----------------- .../workbench/workbench/plotting/toolbar.py | 9 ----- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/qt/applications/workbench/workbench/plotting/figuremanager.py b/qt/applications/workbench/workbench/plotting/figuremanager.py index f04c58b893f9..9ee04b7ef3a3 100644 --- a/qt/applications/workbench/workbench/plotting/figuremanager.py +++ b/qt/applications/workbench/workbench/plotting/figuremanager.py @@ -232,7 +232,6 @@ def __init__(self, canvas, num): self.toolbar.sig_waterfall_conversion.connect(self.update_toolbar_waterfall_plot) self.toolbar.sig_change_line_collection_colour_triggered.connect(self.change_line_collection_colour) self.toolbar.sig_hide_plot_triggered.connect(self.hide_plot) - self.toolbar.sig_crosshair_toggle_triggered.connect(self.crosshair_toggle) self.toolbar.setFloatable(False) tbs_height = self.toolbar.sizeHint().height() else: @@ -252,7 +251,9 @@ def __init__(self, canvas, num): self.window.addDockWidget(Qt.LeftDockWidgetArea, self.fit_browser) self.superplot = None + self.fit_browser.hide() + if matplotlib.is_interactive(): self.window.show() canvas.draw_idle() @@ -263,9 +264,11 @@ def notify_axes_change(fig): self.toolbar.update() canvas.figure.add_axobserver(notify_axes_change) + # Register canvas observers self._fig_interaction = FigureInteraction(self) self._ads_observer = FigureManagerADSObserver(self) + self.window.raise_() def full_screen_toggle(self): @@ -600,41 +603,6 @@ def _reverse_axis_lines(ax): line.remove() ax.add_line(line) - def crosshair_toggle(self, on): - cid = self.canvas.mpl_connect("motion_notify_event", self.crosshair) - if not on: - self.canvas.mpl_disconnect(cid) - - def crosshair(self, event): - axes = self.canvas.figure.gca() - - # create a crosshair made from horizontal and verticle lines. - self.horizontal_line = axes.axhline(color="r", lw=1.0, ls="-") - self.vertical_line = axes.axvline(color="r", lw=1.0, ls="-") - - def set_cross_hair_visible(visible): - need_redraw = self.horizontal_line.get_visible() != visible - self.horizontal_line.set_visible(visible) - self.vertical_line.set_visible(visible) - return need_redraw - - # if event is out-of-bound we update - if not event.inaxes: - need_redraw = set_cross_hair_visible(False) - if need_redraw: - axes.figure.canvas.draw() - - else: - set_cross_hair_visible(True) - x, y = event.xdata, event.ydata - self.horizontal_line.set_ydata([y]) - self.vertical_line.set_xdata([x]) - self.canvas.draw() - - # after update we remove - self.horizontal_line.remove() - self.vertical_line.remove() - # ----------------------------------------------------------------------------- # Figure control diff --git a/qt/applications/workbench/workbench/plotting/toolbar.py b/qt/applications/workbench/workbench/plotting/toolbar.py index 40114d079755..0e15905a7851 100644 --- a/qt/applications/workbench/workbench/plotting/toolbar.py +++ b/qt/applications/workbench/workbench/plotting/toolbar.py @@ -35,7 +35,6 @@ def _create_script_action(self, text, tooltip_text, mdi_icon, *args): class WorkbenchNavigationToolbar(MantidNavigationToolbar): sig_home_clicked = QtCore.Signal() sig_grid_toggle_triggered = QtCore.Signal(bool) - sig_crosshair_toggle_triggered = QtCore.Signal(bool) sig_active_triggered = QtCore.Signal() sig_hold_triggered = QtCore.Signal() sig_toggle_fit_triggered = QtCore.Signal() @@ -85,7 +84,6 @@ class WorkbenchNavigationToolbar(MantidNavigationToolbar): MantidNavigationTool("Fill Area", "Fill area under curves", "mdi.format-color-fill", "waterfall_fill_area", None), MantidStandardNavigationTools.SEPARATOR, MantidNavigationTool("Help", "Open plotting help documentation", "mdi.help", "launch_plot_help", None), - MantidNavigationTool("Crosshair", "Toggle crosshair", "mdi.plus", "toggle_crosshair", False), MantidNavigationTool("Hide", "Hide the plot", "mdi.eye", "hide_plot", None), ) @@ -96,13 +94,6 @@ def __init__(self, canvas, parent, coordinates=True): dpi_ratio = QtWidgets.QApplication.instance().desktop().physicalDpiX() / 100 self.setIconSize(QtCore.QSize(int(24 * dpi_ratio), int(24 * dpi_ratio))) - def toggle_crosshair(self, enable=None): - if enable is None: - enable = self._actions["toggle_crosshair"].isChecked() - else: - self._actions["toggle_crosshair"].setChecked(enable) - self.sig_crosshair_toggle_triggered.emit(enable) - def hide_plot(self): self.sig_hide_plot_triggered.emit() From b6bd2da2e74e421eb93f2fd5c4cdbe376bfc8dfa Mon Sep 17 00:00:00 2001 From: Kyle Ma Date: Mon, 24 Feb 2025 10:43:55 -0500 Subject: [PATCH 2/4] Revert "added tests and release documentation" This reverts commit 1b9820c0daf8ec786a60229f9c626b9104d7fcea. --- .../workbench/plotting/test/test_toolbar.py | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/qt/applications/workbench/workbench/plotting/test/test_toolbar.py b/qt/applications/workbench/workbench/plotting/test/test_toolbar.py index d29079837b53..be6768467040 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_toolbar.py +++ b/qt/applications/workbench/workbench/plotting/test/test_toolbar.py @@ -117,15 +117,6 @@ def test_button_checked_for_plot_with_grid(self, mock_qappthread): # Grid button should be ON because we enabled the grid. self.assertTrue(self._is_grid_button_checked(fig)) - @patch("workbench.plotting.figuremanager.QAppThreadCall") - def test_button_checked_for_plot_with_no_crosshair(self, mock_qappthread): - mock_qappthread.return_value = mock_qappthread - - fig, axes = plt.subplots(subplot_kw={"projection": "mantid"}) - axes.plot([-10, 10], [1, 2]) - # Grid button should be OFF because we have not enabled the crosshair. - self.assertFalse(self._is_crosshair_button_checked(fig)) - @patch("workbench.plotting.figuremanager.QAppThreadCall") def test_button_checked_for_plot_with_grid_using_kwargs(self, mock_qappthread): mock_qappthread.return_value = mock_qappthread @@ -275,19 +266,6 @@ def _is_button_enabled(cls, fig, button): fig_manager.toolbar.set_buttons_visibility(fig) return fig_manager.toolbar._actions[button].isEnabled() - @classmethod - def _is_crosshair_button_checked(cls, fig): - """ - Create the figure manager and check whether its toolbar is toggled on or off for the given figure. - We have to explicitly call set_button_visibility() here, which would otherwise be called within the show() - function. - """ - canvas = MantidFigureCanvas(fig) - fig_manager = FigureManagerWorkbench(canvas, 1) - # This is only called when show() is called on the figure manager, so we have to manually call it here. - fig_manager.toolbar.set_buttons_visibility(fig) - return fig_manager.toolbar._actions["toggle_crosshair"].isChecked() - if __name__ == "__main__": unittest.main() From 73466fb3dfb41fd259f3fae612b42df6245df88e Mon Sep 17 00:00:00 2001 From: Kyle Ma Date: Mon, 24 Feb 2025 11:19:38 -0500 Subject: [PATCH 3/4] remove crosshair in release note --- docs/source/release/v6.12.0/mantidworkbench.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/release/v6.12.0/mantidworkbench.rst b/docs/source/release/v6.12.0/mantidworkbench.rst index ad4875590664..c17c625094d9 100644 --- a/docs/source/release/v6.12.0/mantidworkbench.rst +++ b/docs/source/release/v6.12.0/mantidworkbench.rst @@ -9,8 +9,7 @@ New Features ------------ - ``mantidworkbench`` is now an additional entry point for launching the ``mantidworkbench`` Conda package. - ``workbench`` and ``mantidworkbench`` Conda entry points now launch workbench with ``jemalloc`` configured as the memory allocator on Linux. -- Surface and contour plots can now be generated more easily for multiple single-spectrum workspaces (via the `Plot Advanced` dialog when multiple single-spectrum workspaces are selected). -- A crosshair tool has been added to plot toolbars. +- Surface and contour plots can now be generated more easily for multiple single-spectrum workspaces (via the `Plot Advanced` dialog when multiple single-spectrum workspaces are select - Added an `Email mantid-help@mantidproject.org` action to the Help menu. - The settings dialog now has `Okay`, `Apply` and `Cancel` buttons. Settings are no longer immediately applied when parameters are changed. - MacOS compiler updated from version 16 to version 18, which should result in performance improvements. See https://releases.llvm.org for release notes. From d9e270e4d39fcc4c087c1a5d8f2396ecb01d3463 Mon Sep 17 00:00:00 2001 From: Kyle Ma Date: Mon, 24 Feb 2025 11:20:40 -0500 Subject: [PATCH 4/4] typo fix in release note --- docs/source/release/v6.12.0/mantidworkbench.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/release/v6.12.0/mantidworkbench.rst b/docs/source/release/v6.12.0/mantidworkbench.rst index c17c625094d9..e5140413a84d 100644 --- a/docs/source/release/v6.12.0/mantidworkbench.rst +++ b/docs/source/release/v6.12.0/mantidworkbench.rst @@ -9,7 +9,7 @@ New Features ------------ - ``mantidworkbench`` is now an additional entry point for launching the ``mantidworkbench`` Conda package. - ``workbench`` and ``mantidworkbench`` Conda entry points now launch workbench with ``jemalloc`` configured as the memory allocator on Linux. -- Surface and contour plots can now be generated more easily for multiple single-spectrum workspaces (via the `Plot Advanced` dialog when multiple single-spectrum workspaces are select +- Surface and contour plots can now be generated more easily for multiple single-spectrum workspaces (via the `Plot Advanced` dialog when multiple single-spectrum workspaces are selected). - Added an `Email mantid-help@mantidproject.org` action to the Help menu. - The settings dialog now has `Okay`, `Apply` and `Cancel` buttons. Settings are no longer immediately applied when parameters are changed. - MacOS compiler updated from version 16 to version 18, which should result in performance improvements. See https://releases.llvm.org for release notes.