From 744ba2e72f70838585a8799121d8148db1d9f6ed Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 28 Nov 2014 16:13:30 +0000 Subject: [PATCH] Update the axis title when plotting distribution Refs #10639 --- Code/Mantid/MantidPlot/src/Graph.cpp | 21 +++++++++++++++++++++ Code/Mantid/MantidPlot/src/Graph.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/MantidPlot/src/Graph.cpp b/Code/Mantid/MantidPlot/src/Graph.cpp index bb236388c8b4..1fd6d245be99 100644 --- a/Code/Mantid/MantidPlot/src/Graph.cpp +++ b/Code/Mantid/MantidPlot/src/Graph.cpp @@ -58,7 +58,9 @@ #include "ApplicationWindow.h" #include "plot2D/ScaleEngine.h" +#include "MantidAPI/AnalysisDataService.h" #include "Mantid/MantidMatrixCurve.h" +#include "MantidQtAPI/PlotAxis.h" #include "MantidQtAPI/QwtWorkspaceSpectrumData.h" #include "Mantid/ErrorBarSettings.h" @@ -3813,6 +3815,22 @@ void Graph::addLegendItem() } } +QString Graph::yAxisTitleFromFirstCurve() +{ + // I really don't like this... + if(auto *firstCurve = dynamic_cast(curve(0))) + { + using namespace Mantid::API; + QString wsName = firstCurve->workspaceName(); + auto ws = AnalysisDataService::Instance().retrieveWS(wsName.toStdString()); + return MantidQt::API::PlotAxis(m_isDistribution, *ws).title(); + } + else + { + return axisTitle(0); + } +} + void Graph::contextMenuEvent(QContextMenuEvent *e) { if (selectedMarker>=0) { @@ -5993,6 +6011,7 @@ void Graph::noNormalization() m_isDistribution = false; updateDataCurves(); d_plot->updateAxes(); + setYAxisTitle(yAxisTitleFromFirstCurve()); notifyChanges(); } @@ -6006,6 +6025,8 @@ void Graph::binWidthNormalization() m_isDistribution = true; updateDataCurves(); d_plot->updateAxes(); + setYAxisTitle(yAxisTitleFromFirstCurve()); + notifyChanges(); } diff --git a/Code/Mantid/MantidPlot/src/Graph.h b/Code/Mantid/MantidPlot/src/Graph.h index 17bb639d5ef7..7432936146af 100644 --- a/Code/Mantid/MantidPlot/src/Graph.h +++ b/Code/Mantid/MantidPlot/src/Graph.h @@ -826,7 +826,9 @@ private slots: void niceLogScales(QwtPlot::Axis axis); void deselectCurves(); void addLegendItem(); - + + QString yAxisTitleFromFirstCurve(); + Plot *d_plot; QwtPlotZoomer *d_zoomer[2]; TitlePicker *titlePicker;