diff --git a/docs/source/release/v6.13.0/Workbench/New_features/39242.rst b/docs/source/release/v6.13.0/Workbench/New_features/39242.rst index fc4026c2d532..311853800934 100644 --- a/docs/source/release/v6.13.0/Workbench/New_features/39242.rst +++ b/docs/source/release/v6.13.0/Workbench/New_features/39242.rst @@ -1 +1 @@ -- A crosshair toggle option has been added in mantidplots on the top right of the toolbar area. THe crosshair button is disabled (invisible) in titled plots. +- A crosshair toggle option has been added in mantidplots on the top right of the toolbar area. The crosshair button is disabled (invisible) in titled plots. diff --git a/docs/source/release/v6.13.0/Workbench/New_features/39286.rst b/docs/source/release/v6.13.0/Workbench/New_features/39286.rst new file mode 100644 index 000000000000..99ee6a82bb27 --- /dev/null +++ b/docs/source/release/v6.13.0/Workbench/New_features/39286.rst @@ -0,0 +1 @@ +- The crosshair button is disabled (invisible) in 3D plots, which include surface plot, wireframe plot and mesh plot. diff --git a/qt/applications/workbench/workbench/plotting/test/test_toolbar.py b/qt/applications/workbench/workbench/plotting/test/test_toolbar.py index 5bbae53c347b..fb506216bfb1 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_toolbar.py +++ b/qt/applications/workbench/workbench/plotting/test/test_toolbar.py @@ -20,7 +20,9 @@ from workbench.plotting.figuremanager import MantidFigureCanvas, FigureManagerWorkbench from workbench.plotting.toolbar import WorkbenchNavigationToolbar from mantid.plots.plotfunctions import plot -from mantid.simpleapi import CreateSampleWorkspace, CreateMDHistoWorkspace, Load +from mantid.simpleapi import CreateSampleWorkspace, CreateMDHistoWorkspace, Load, mtd, LoadSampleShape +from mpl_toolkits.mplot3d.art3d import Poly3DCollection +import mantid.simpleapi as msa @start_qapplication @@ -151,6 +153,45 @@ def test_button_enabled_for_contour_plots(self, mock_qappthread): self.assertTrue(self._is_crosshair_button_visible(fig)) self.assertFalse(self._is_crosshair_button_checked(fig)) + @patch("workbench.plotting.figuremanager.QAppThreadCall") + def test_button_hidden_for_3d_surface_plots(self, mock_qappthread): + mock_qappthread.return_value = mock_qappthread + data = Load("MUSR00015189.nxs") + data = mtd["data_1"] # Extract individual workspace from group + fig, ax = plt.subplots(subplot_kw={"projection": "mantid3d"}) + ax.plot_surface(data, cmap="viridis") + # crosshair button should be hidden + self.assertFalse(self._is_crosshair_button_visible(fig)) + self.assertFalse(self._is_crosshair_button_checked(fig)) + + @patch("workbench.plotting.figuremanager.QAppThreadCall") + def test_button_hidden_for_3d_wireframe_plots(self, mock_qappthread): + mock_qappthread.return_value = mock_qappthread + msa.config.setFacility("SNS") + data = Load("MAR11060.nxs") + fig, ax = plt.subplots(subplot_kw={"projection": "mantid3d"}) + ax.plot_wireframe(data) + # crosshair button should be hidden + self.assertFalse(self._is_crosshair_button_visible(fig)) + self.assertFalse(self._is_crosshair_button_checked(fig)) + + @patch("workbench.plotting.figuremanager.QAppThreadCall") + def test_button_hidden_for_3d_mesh_plots(self, mock_qappthread): + mock_qappthread.return_value = mock_qappthread + ws = CreateSampleWorkspace() + ws = LoadSampleShape(ws, "tube.stl") + sample = ws.sample() + shape = sample.getShape() + mesh = shape.getMesh() + mesh_polygon = Poly3DCollection(mesh, facecolors=["g"], edgecolors=["b"], alpha=0.5, linewidths=0.1) + fig, axes = plt.subplots(subplot_kw={"projection": "mantid3d"}) + axes.add_collection3d(mesh_polygon) + axes.set_mesh_axes_equal(mesh) + + # crosshair button should be hidden + self.assertFalse(self._is_crosshair_button_visible(fig)) + 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 diff --git a/qt/applications/workbench/workbench/plotting/toolbar.py b/qt/applications/workbench/workbench/plotting/toolbar.py index 2d3d5ad1d14a..f4ed4d1ad367 100644 --- a/qt/applications/workbench/workbench/plotting/toolbar.py +++ b/qt/applications/workbench/workbench/plotting/toolbar.py @@ -234,8 +234,10 @@ def set_buttons_visibility(self, fig): self.set_fit_enabled(False) self.set_superplot_enabled(False) - # disable crosshair in tiled plots but keep it enabled in color contour plot - if len(fig.get_axes()) > 1 and figure_type(fig) not in [FigureType.Contour]: + # disable crosshair in tiled plots, 3D plots but keep it enabled in color contour plot + if (len(fig.get_axes()) > 1 and figure_type(fig) not in [FigureType.Contour]) or ( + figure_type(fig) in [FigureType.Surface, FigureType.Wireframe, FigureType.Mesh] + ): self.set_crosshair_enabled(False) for ax in fig.get_axes():