Skip to content
Snippets Groups Projects
Unverified Commit 8c5bfe82 authored by Gagik Vardanyan's avatar Gagik Vardanyan Committed by GitHub
Browse files

Merge pull request #27738 from mantidproject/27731_disable_polt_options_for_single_bin

Disable the plotting context menu options if a matrix ws has 1 bin
parents 0d5ab0c9 75205f31
No related branches found
No related tags found
No related merge requests found
......@@ -203,13 +203,17 @@ class WorkspaceWidget(PluginWidget):
CreateDetectorTable(InputWorkspace=ws)
def _action_double_click_workspace(self, name):
ws = self._ads.retrieve(name)
try:
# if this is a table workspace (or peaks workspace),
# then it can't be plotted automatically, so the data is shown instead
TableWorkspaceDisplay.supports(self._ads.retrieve(name))
TableWorkspaceDisplay.supports(ws)
self._do_show_data([name])
except ValueError:
plot_from_names([name], errors=False, overplot=False, show_colorfill_btn=True)
if ws.blocksize() > 1:
plot_from_names([name], errors=False, overplot=False, show_colorfill_btn=True)
else:
self._do_show_data([name])
def refresh_workspaces(self):
self.workspacewidget.refreshWorkspaces()
......@@ -107,6 +107,25 @@ void WorkspaceTreeWidgetSimple::popupContextMenu() {
plotSubMenu->addAction(m_overplotSpectrum);
plotSubMenu->addAction(m_plotSpectrumWithErrs);
plotSubMenu->addAction(m_overplotSpectrumWithErrs);
// Don't plot 1D spectra if only one X value
bool multipleBins = false;
try {
multipleBins = (matrixWS->blocksize() > 1);
} catch (...) {
const size_t numHist = matrixWS->getNumberHistograms();
for (size_t i = 0; i < numHist; ++i) {
if (matrixWS->y(i).size() > 1) {
multipleBins = true;
break;
}
}
}
// disable the actions created so far if only one bin
for (auto action : plotSubMenu->actions()) {
action->setEnabled(multipleBins);
}
plotSubMenu->addSeparator();
plotSubMenu->addAction(m_plotColorfill);
menu->addMenu(plotSubMenu);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment