Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The crosshair button is disabled (invisible) in 3D plots, which include surface plot, wireframe plot and mesh plot.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions qt/applications/workbench/workbench/plotting/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down