14#include <boost/algorithm/string/join.hpp>
15#include <boost/algorithm/string/regex.hpp>
16#include <boost/lexical_cast.hpp>
22QString replacePerWithNegativeIndice(
const std::string &label,
const bool &plotAsDistribution,
24 std::vector<std::string> splitVec;
28 boost::split_regex(splitVec, label, boost::regex(
" per "));
29 if (splitVec.size() > 1) {
30 newLabel = QString::fromStdString(splitVec[0]);
31 splitVec.erase(splitVec.begin());
32 std::string unitString = boost::algorithm::join(splitVec,
" ");
33 newLabel +=
" (" + QString::fromStdString(unitString);
34 if (plotAsDistribution && xLabel !=
"") {
37 newLabel +=
")" + negativeOnePower;
39 newLabel = QString::fromStdString(label);
40 if (plotAsDistribution && xLabel !=
"") {
57 throw std::invalid_argument(
"PlotAxis() - Unknown axis index: '" + boost::lexical_cast<std::string>(
index) +
"'");
102 if (!unitLbl.utf8().empty()) {
104 }
else if (!unitLbl.ascii().empty()) {
105 m_title +=
" (" + QString::fromStdString(unitLbl.ascii()) +
")";
117 std::string yLabel =
workspace.YUnitLabel();
118 if (yLabel.empty()) {
121 if (!
workspace.isDistribution() && plottingDistribution) {
122 const auto xLabel =
workspace.getAxis(0)->unit()->label();
123 m_title = replacePerWithNegativeIndice(yLabel,
true, xLabel);
125 m_title = replacePerWithNegativeIndice(yLabel,
false);
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
PlotAxis()=delete
Disable default constructor.
void titleFromDimension(const Mantid::Geometry::IMDDimension &dim)
Creates a title suitable for an axis attached to the given dimension.
void titleFromIndex(const Mantid::API::IMDWorkspace &workspace, const size_t index)
Creates a title suitable for an axis attached to the given index.
QString title() const
Create a new axis title.
void titleFromYData(const Mantid::API::MatrixWorkspace &workspace, const bool plottingDistribution)
Creates a title suitable for the Y data values.
Basic MD Workspace Abstract Class.
Base MatrixWorkspace Abstract Class.
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
virtual std::string getName() const =0
virtual const Kernel::UnitLabel getUnits() const =0
A base-class for the a class that is able to return unit labels in different representations.
QString toQStringInternal(const wchar_t *str)
Internal version of QString::fromStdWString.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...