diff --git a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp index 7a395feddd2a..f25cb1567fad 100644 --- a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp +++ b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp @@ -1211,10 +1211,15 @@ namespace Mantid { } /// the name of the dimennlsion as can be displayed along the axis - virtual std::string getName() const {return m_axis.unit()->caption();} + virtual std::string getName() const + { + const auto & unit = m_axis.unit(); + if (unit && unit->unitID() != "Empty" ) return unit->caption(); + else return m_axis.title(); + } /// @return the units of the dimension as a string - virtual std::string getUnits() const {return m_axis.unit()->label();} + virtual const Kernel::UnitLabel getUnits() const { return m_axis.unit()->label(); } /// short name which identify the dimension among other dimension. A dimension can be usually find by its ID and various /// various method exist to manipulate set of dimensions by their names. @@ -1267,10 +1272,16 @@ namespace Mantid virtual ~MWXDimension(){}; /// the name of the dimennlsion as can be displayed along the axis - virtual std::string getName() const {return m_ws->getAxis(0)->unit()->caption();} + virtual std::string getName() const + { + const auto *axis = m_ws->getAxis(0); + const auto & unit = axis->unit(); + if (unit && unit->unitID() != "Empty" ) return unit->caption(); + else return axis->title(); + } /// @return the units of the dimension as a string - virtual std::string getUnits() const {return m_ws->getAxis(0)->unit()->label();} + virtual const Kernel::UnitLabel getUnits() const {return m_ws->getAxis(0)->unit()->label();} /// short name which identify the dimension among other dimension. A dimension can be usually find by its ID and various /// various method exist to manipulate set of dimensions by their names. diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/IMDDimension.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/IMDDimension.h index 532fa6905669..2e7b45272a65 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/IMDDimension.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/IMDDimension.h @@ -10,6 +10,14 @@ namespace Mantid { + namespace Kernel + { + //--------------------------------------------------------------------------- + // Forward declarations + //--------------------------------------------------------------------------- + class UnitLabel; + } + namespace Geometry { /** The class discribes one dimension of multidimensional dataset representing an ortogonal dimension and linear axis. @@ -50,7 +58,7 @@ namespace Mantid virtual std::string getName() const = 0; /// @return the units of the dimension as a string - virtual std::string getUnits() const = 0; + virtual const Kernel::UnitLabel getUnits() const = 0; /// short name which identify the dimension among other dimensin. A dimension can be usually find by its ID and various /// various method exist to manipulate set of dimensions by their names. diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h index f195c006f0db..ed8130a96f60 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h @@ -4,6 +4,7 @@ #include "MantidGeometry/DllConfig.h" #include "MantidKernel/Exception.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidKernel/UnitLabel.h" #include "MantidKernel/VMD.h" namespace Mantid @@ -26,12 +27,12 @@ namespace Geometry /** Constructor for simple MDHistoDimension * @param name :: full name of the axis * @param ID :: identifier string - * @param units :: string giving the units of this dimension + * @param units :: A plain-text string giving the units of this dimension * @param min :: minimum extent * @param max :: maximum extent * @param numBins :: number of bins (evenly spaced) */ - MDHistoDimension(std::string name, std::string ID, std::string units, coord_t min, coord_t max, size_t numBins) + MDHistoDimension(std::string name, std::string ID, const Kernel::UnitLabel & units, coord_t min, coord_t max, size_t numBins) : m_name(name), m_dimensionId(ID), m_units(units), m_min(min), m_max(max), m_numBins(numBins), m_binWidth((max-min)/static_cast(numBins)) @@ -65,7 +66,7 @@ namespace Geometry } /// Return the units of the dimension as a string - virtual std::string getUnits() const + virtual const Kernel::UnitLabel getUnits() const { return m_units; } @@ -137,7 +138,7 @@ namespace Geometry std::string m_dimensionId; /// Dimension units - std::string m_units; + Kernel::UnitLabel m_units; /// Extent of dimension coord_t m_min; diff --git a/Code/Mantid/Framework/Geometry/test/IMDDimensionFactoryTest.h b/Code/Mantid/Framework/Geometry/test/IMDDimensionFactoryTest.h index c64146dd8e23..ad589730437e 100644 --- a/Code/Mantid/Framework/Geometry/test/IMDDimensionFactoryTest.h +++ b/Code/Mantid/Framework/Geometry/test/IMDDimensionFactoryTest.h @@ -3,6 +3,7 @@ #include #include "MantidGeometry/MDGeometry/IMDDimensionFactory.h" +#include "MantidKernel/UnitLabel.h" #include #include #include @@ -54,7 +55,7 @@ class IMDDimensionFactoryTest: public CxxTest::TestSuite void testCorrectGeneration() { IMDDimension_const_sptr dimension = createDimension(constructDimensionWithUnitsXMLString()); - TS_ASSERT_EQUALS("Cubits", dimension->getUnits()); + TS_ASSERT_EQUALS("Cubits", dimension->getUnits().ascii()); TS_ASSERT_EQUALS("Qz", dimension->getName()); TS_ASSERT_EQUALS("qz", dimension->getDimensionId()); TS_ASSERT_EQUALS(-3, dimension->getMinimum()); @@ -65,7 +66,7 @@ class IMDDimensionFactoryTest: public CxxTest::TestSuite void testCorrectGenerationWithoutUnits() { IMDDimension_const_sptr dimension = createDimension(constructDimensionWithoutUnitsXMLString()); - TS_ASSERT_EQUALS("None", dimension->getUnits()); + TS_ASSERT_EQUALS("None", dimension->getUnits().ascii()); TS_ASSERT_EQUALS("Qz", dimension->getName()); TS_ASSERT_EQUALS("qz", dimension->getDimensionId()); TS_ASSERT_EQUALS(-3, dimension->getMinimum()); @@ -87,7 +88,7 @@ class IMDDimensionFactoryTest: public CxxTest::TestSuite void testOverrideMethod() { IMDDimension_const_sptr dimension = createDimension(constructDimensionWithUnitsXMLString(),10,-9.0,8.5); - TS_ASSERT_EQUALS("Cubits", dimension->getUnits()); + TS_ASSERT_EQUALS("Cubits", dimension->getUnits().ascii()); TS_ASSERT_EQUALS("Qz", dimension->getName()); TS_ASSERT_EQUALS("qz", dimension->getDimensionId()); TS_ASSERT_EQUALS(-9.0, dimension->getMinimum()); diff --git a/Code/Mantid/Framework/Geometry/test/MDGeometryXMLBuilderTest.h b/Code/Mantid/Framework/Geometry/test/MDGeometryXMLBuilderTest.h index 7b40c2e0cb98..a9ec79530af6 100644 --- a/Code/Mantid/Framework/Geometry/test/MDGeometryXMLBuilderTest.h +++ b/Code/Mantid/Framework/Geometry/test/MDGeometryXMLBuilderTest.h @@ -8,6 +8,8 @@ #include "MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidKernel/UnitLabel.h" + #include #include #include @@ -36,7 +38,7 @@ class MDGeometryXMLBuilderTest : public CxxTest::TestSuite MOCK_CONST_METHOD0(getName, std::string()); MOCK_CONST_METHOD0(getUnits, - std::string()); + const Mantid::Kernel::UnitLabel()); MOCK_CONST_METHOD0(getDimensionId, std::string()); MOCK_CONST_METHOD0(getMaximum, diff --git a/Code/Mantid/Framework/Geometry/test/MDHistoDimensionBuilderTest.h b/Code/Mantid/Framework/Geometry/test/MDHistoDimensionBuilderTest.h index dad65d19a5ef..8dee24ffdb64 100644 --- a/Code/Mantid/Framework/Geometry/test/MDHistoDimensionBuilderTest.h +++ b/Code/Mantid/Framework/Geometry/test/MDHistoDimensionBuilderTest.h @@ -26,7 +26,7 @@ class MDHistoDimensionBuilderTest : public CxxTest::TestSuite TS_ASSERT_EQUALS("testDimName", product->getName()); TS_ASSERT_EQUALS("testDimId", product->getDimensionId()); - TS_ASSERT_EQUALS("A^-1", product->getUnits()); + TS_ASSERT_EQUALS("A^-1", product->getUnits().ascii()); TS_ASSERT_EQUALS(0, product->getMinimum()); TS_ASSERT_EQUALS(2, product->getMaximum()); TS_ASSERT_EQUALS(1, product->getNBins()); @@ -47,7 +47,7 @@ class MDHistoDimensionBuilderTest : public CxxTest::TestSuite TS_ASSERT_THROWS_NOTHING(product = builder.create()); TS_ASSERT_EQUALS("testDimName", product->getName()); TS_ASSERT_EQUALS("testDimId", product->getDimensionId()); - TS_ASSERT_EQUALS("A^-1", product->getUnits()); + TS_ASSERT_EQUALS("A^-1", product->getUnits().ascii()); TS_ASSERT_EQUALS(0, product->getMinimum()); TS_ASSERT_EQUALS(2, product->getMaximum()); TS_ASSERT_EQUALS(1, product->getNBins()); @@ -211,4 +211,4 @@ class MDHistoDimensionBuilderTest : public CxxTest::TestSuite }; -#endif \ No newline at end of file +#endif diff --git a/Code/Mantid/Framework/Kernel/src/Strings.cpp b/Code/Mantid/Framework/Kernel/src/Strings.cpp index 296dab773928..73f1287862be 100644 --- a/Code/Mantid/Framework/Kernel/src/Strings.cpp +++ b/Code/Mantid/Framework/Kernel/src/Strings.cpp @@ -1,5 +1,6 @@ #include "MantidKernel/Strings.h" #include "MantidKernel/Exception.h" +#include "MantidKernel/UnitLabel.h" #include #include @@ -777,6 +778,12 @@ namespace Mantid return toString(std::vector(value.begin(), value.end())); } + template<> + std::string toString(const UnitLabel &value) + { + return value; + } + //------------------------------------------------------------------------------------------------ /** * Write out the three vectors into a file of type dc 9 diff --git a/Code/Mantid/Framework/MDAlgorithms/test/CreateMDHistoWorkspaceTest.h b/Code/Mantid/Framework/MDAlgorithms/test/CreateMDHistoWorkspaceTest.h index e678d35b22a8..40b42e6b7e07 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/CreateMDHistoWorkspaceTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/CreateMDHistoWorkspaceTest.h @@ -111,7 +111,7 @@ class CreateMDHistoWorkspaceTest : public CxxTest::TestSuite TS_ASSERT_EQUALS("A", dim1->getName()); TS_ASSERT_EQUALS("A", dim1->getDimensionId()); - TS_ASSERT_EQUALS("U", dim1->getUnits()); + TS_ASSERT_EQUALS("U", dim1->getUnits().ascii()); TS_ASSERT_EQUALS(1, dim1->getMaximum()); TS_ASSERT_EQUALS(-1, dim1->getMinimum()); TS_ASSERT_EQUALS(5, dim1->getNBins()); @@ -177,4 +177,4 @@ class CreateMDHistoWorkspaceTest : public CxxTest::TestSuite }; -#endif /* MANTID_MDEVENTS_CREATEMDHISTOWORKSPACETEST_H_ */ \ No newline at end of file +#endif /* MANTID_MDEVENTS_CREATEMDHISTOWORKSPACETEST_H_ */ diff --git a/Code/Mantid/Framework/MDAlgorithms/test/LoadSQWTest.h b/Code/Mantid/Framework/MDAlgorithms/test/LoadSQWTest.h index 115574b6294c..e40d4e7aef49 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/LoadSQWTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/LoadSQWTest.h @@ -142,10 +142,10 @@ class LoadSQWTest : public CxxTest::TestSuite TS_ASSERT_EQUALS("en", d->getDimensionId()); //Check Units - TS_ASSERT_EQUALS("A^-1", a->getUnits()); - TS_ASSERT_EQUALS("A^-1", b->getUnits()); - TS_ASSERT_EQUALS("A^-1", c->getUnits()); - TS_ASSERT_EQUALS("mEv", d->getUnits()); + TS_ASSERT_EQUALS("A^-1", a->getUnits().ascii()); + TS_ASSERT_EQUALS("A^-1", b->getUnits().ascii()); + TS_ASSERT_EQUALS("A^-1", c->getUnits().ascii()); + TS_ASSERT_EQUALS("mEv", d->getUnits().ascii()); //Check Nbins TS_ASSERT_EQUALS(3, a->getNBins()); diff --git a/Code/Mantid/Framework/MDEvents/src/QueryMDWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/QueryMDWorkspace.cpp index 991057b9849c..5c8f4d724387 100644 --- a/Code/Mantid/Framework/MDEvents/src/QueryMDWorkspace.cpp +++ b/Code/Mantid/Framework/MDEvents/src/QueryMDWorkspace.cpp @@ -231,7 +231,7 @@ namespace MDEvents for(size_t index = 0; index < ndims; ++index) { Mantid::Geometry::IMDDimension_const_sptr dim = input->getDimension(index); - std::string dimInUnit = dim->getName()+"/"+dim->getUnits(); + std::string dimInUnit = dim->getName()+"/"+dim->getUnits().ascii(); output->addColumn("double",dimInUnit); //Magic numbers required to configure the X axis. output->getColumn(dimInUnit)->setPlotType(1); diff --git a/Code/Mantid/Framework/MDEvents/test/ImportMDEventWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/ImportMDEventWorkspaceTest.h index b0dd28dbc16c..9656a9f6cd91 100644 --- a/Code/Mantid/Framework/MDEvents/test/ImportMDEventWorkspaceTest.h +++ b/Code/Mantid/Framework/MDEvents/test/ImportMDEventWorkspaceTest.h @@ -251,13 +251,13 @@ void do_check_throws_invalid_alg_upon_execution(const MDFileObject& infile) TS_ASSERT_EQUALS("a", dim1->getName()); TS_ASSERT_EQUALS("A", dim1->getDimensionId()); - TS_ASSERT_EQUALS("U", dim1->getUnits()); + TS_ASSERT_EQUALS("U", dim1->getUnits().ascii()); TS_ASSERT_EQUALS(-1, dim1->getMinimum()); TS_ASSERT_EQUALS(2, dim1->getMaximum()); TS_ASSERT_EQUALS("b", dim2->getName()); TS_ASSERT_EQUALS("B", dim2->getDimensionId()); - TS_ASSERT_EQUALS("U", dim2->getUnits()); + TS_ASSERT_EQUALS("U", dim2->getUnits().ascii()); TS_ASSERT_EQUALS(-2, dim2->getMinimum()); TS_ASSERT_EQUALS(3, dim2->getMaximum()); } diff --git a/Code/Mantid/Framework/MDEvents/test/ImportMDHistoWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/ImportMDHistoWorkspaceTest.h index 7b78d4e2ae71..76c55f517523 100644 --- a/Code/Mantid/Framework/MDEvents/test/ImportMDHistoWorkspaceTest.h +++ b/Code/Mantid/Framework/MDEvents/test/ImportMDHistoWorkspaceTest.h @@ -231,14 +231,14 @@ class ImportMDHistoWorkspaceTest : public CxxTest::TestSuite TS_ASSERT_EQUALS("A", dim1->getName()); TS_ASSERT_EQUALS("A", dim1->getDimensionId()); - TS_ASSERT_EQUALS("U1", dim1->getUnits()); + TS_ASSERT_EQUALS("U1", dim1->getUnits().ascii()); TS_ASSERT_EQUALS(1, dim1->getMaximum()); TS_ASSERT_EQUALS(-1, dim1->getMinimum()); TS_ASSERT_EQUALS(2, dim1->getNBins()); TS_ASSERT_EQUALS("B", dim2->getName()); TS_ASSERT_EQUALS("B", dim2->getDimensionId()); - TS_ASSERT_EQUALS("U2", dim2->getUnits()); + TS_ASSERT_EQUALS("U2", dim2->getUnits().ascii()); TS_ASSERT_EQUALS(1, dim2->getMaximum()); TS_ASSERT_EQUALS(-1, dim2->getMinimum()); TS_ASSERT_EQUALS(2, dim2->getNBins()); @@ -289,4 +289,4 @@ class ImportMDHistoWorkspaceTest : public CxxTest::TestSuite }; -#endif /* MANTID_MDEVENTS_IMPORTMDHISTOWORKSPACETEST_H_ */ \ No newline at end of file +#endif /* MANTID_MDEVENTS_IMPORTMDHISTOWORKSPACETEST_H_ */ diff --git a/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/IMDDimension.cpp b/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/IMDDimension.cpp index 3cebcfa77d5d..344412f4b38f 100644 --- a/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/IMDDimension.cpp +++ b/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/IMDDimension.cpp @@ -1,4 +1,5 @@ #include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidKernel/UnitLabel.h" #include #include diff --git a/Code/Mantid/MantidQt/API/src/MantidQwtIMDWorkspaceData.cpp b/Code/Mantid/MantidQt/API/src/MantidQwtIMDWorkspaceData.cpp index 8c1bd7791120..9ab24cfaaadd 100644 --- a/Code/Mantid/MantidQt/API/src/MantidQwtIMDWorkspaceData.cpp +++ b/Code/Mantid/MantidQt/API/src/MantidQwtIMDWorkspaceData.cpp @@ -453,7 +453,7 @@ QString MantidQwtIMDWorkspaceData::getXAxisLabel() const { // One of the dimensions of the original IMDDimension_const_sptr dim = m_originalWorkspace.lock()->getDimension(m_currentPlotAxis); - xLabel = QString::fromStdString(dim->getName() + " (" + dim->getUnits() + ")"); + xLabel = QString::fromStdString(dim->getName()) + " (" + QString::fromStdWString(dim->getUnits().utf8()) + ")"; } else { diff --git a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h index f21dd3d260b8..44f577c34670 100644 --- a/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h +++ b/Code/Mantid/MantidQt/SliceViewer/inc/MantidQtSliceViewer/SliceViewer.h @@ -177,7 +177,7 @@ public slots: void updateDisplay(bool resetAxes = false); void updateDimensionSliceWidgets(); - void resetAxis(int axis, Mantid::Geometry::IMDDimension_const_sptr dim); + void resetAxis(int axis, const Mantid::Geometry::IMDDimension_const_sptr & dim); QwtDoubleInterval getRange(Mantid::API::IMDIterator * it); QwtDoubleInterval getRange(std::vector iterators); diff --git a/Code/Mantid/MantidQt/SliceViewer/src/DimensionSliceWidget.cpp b/Code/Mantid/MantidQt/SliceViewer/src/DimensionSliceWidget.cpp index 4745d5d46136..7d2892969e78 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/DimensionSliceWidget.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/DimensionSliceWidget.cpp @@ -1,4 +1,5 @@ #include "MantidQtSliceViewer/DimensionSliceWidget.h" +#include "MantidKernel/UnitLabel.h" #include #include #include @@ -175,7 +176,7 @@ void DimensionSliceWidget::setMinMax(double min, double max) { if (!m_dim) return; ui.lblName->setText(QString::fromStdString(m_dim->getName()) ); - ui.lblUnits->setText(QString::fromStdString(m_dim->getUnits()) ); + ui.lblUnits->setText(QString::fromStdWString(m_dim->getUnits().utf8()) ); ui.horizontalSlider->setRange(min, max, m_dim->getBinWidth()); diff --git a/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp b/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp index bc44e1a4c3bf..07f4cfe693fa 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp @@ -74,6 +74,7 @@ #include "MantidAPI/AlgorithmManager.h" #include "MantidQtAPI/AlgorithmRunner.h" #include "MantidQtAPI/FileDialogHandler.h" +#include "MantidQtAPI/PlotAxis.h" using namespace Mantid; @@ -1192,10 +1193,10 @@ void SliceViewer::setXYCenter(double x, double y) * @param axis :: int for X or Y * @param dim :: dimension to show */ -void SliceViewer::resetAxis(int axis, Mantid::Geometry::IMDDimension_const_sptr dim) +void SliceViewer::resetAxis(int axis, const IMDDimension_const_sptr &dim) { m_plot->setAxisScale( axis, dim->getMinimum(), dim->getMaximum()); - m_plot->setAxisTitle( axis, QString::fromStdString(dim->getName() + " (" + dim->getUnits() + ")") ); + m_plot->setAxisTitle( axis, API::PlotAxis(*dim).title()); } //------------------------------------------------------------------------------------ @@ -2073,7 +2074,7 @@ void SliceViewer::rebinParamsChanged() // Set the BasisVector property... VMD basis(m_ws->getNumDims()); basis[d] = 1.0; - std::string prop = dim->getName() +"," + dim->getUnits() + "," + std::string prop = dim->getName() +"," + dim->getUnits().ascii() + "," + basis.toString(","); alg->setPropertyValue("BasisVector" + Strings::toString(d), prop); } diff --git a/Code/Mantid/MantidQt/SliceViewer/src/XYLimitsDialog.cpp b/Code/Mantid/MantidQt/SliceViewer/src/XYLimitsDialog.cpp index e0cb7d5a1802..9b53b5ad0659 100644 --- a/Code/Mantid/MantidQt/SliceViewer/src/XYLimitsDialog.cpp +++ b/Code/Mantid/MantidQt/SliceViewer/src/XYLimitsDialog.cpp @@ -1,4 +1,5 @@ #include "../inc/MantidQtSliceViewer/XYLimitsDialog.h" +#include "MantidKernel/UnitLabel.h" #include XYLimitsDialog::XYLimitsDialog(QWidget *parent) @@ -26,7 +27,7 @@ XYLimitsDialog::~XYLimitsDialog() void XYLimitsDialog::setXDim(Mantid::Geometry::IMDDimension_const_sptr dim) { ui.lblXName->setText( QString::fromStdString(dim->getName()) ); - ui.lblXUnits->setText( QString::fromStdString(dim->getUnits()) ); + ui.lblXUnits->setText( QString::fromStdWString(dim->getUnits().utf8()) ); } /** Set the labels for the Y dimensions @@ -34,7 +35,7 @@ void XYLimitsDialog::setXDim(Mantid::Geometry::IMDDimension_const_sptr dim) void XYLimitsDialog::setYDim(Mantid::Geometry::IMDDimension_const_sptr dim) { ui.lblYName->setText( QString::fromStdString(dim->getName()) ); - ui.lblYUnits->setText( QString::fromStdString(dim->getUnits()) ); + ui.lblYUnits->setText( QString::fromStdWString(dim->getUnits().utf8()) ); } //------------------------------------------------------------------------------------------ diff --git a/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h b/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h index 9c9bcb5b0fc4..d7ddc461ce05 100644 --- a/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h +++ b/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h @@ -11,6 +11,7 @@ #include "MantidQtSliceViewer/ZoomablePeaksView.h" #include "MantidQtSliceViewer/UpdateableOnDemand.h" #include "MantidAPI/IPeak.h" +#include "MantidKernel/UnitLabel.h" #include #include #include @@ -268,7 +269,7 @@ class MockPeakTransformFactory : public PeakTransformFactory MOCK_CONST_METHOD0(getName, std::string()); MOCK_CONST_METHOD0(getUnits, - std::string()); + const Mantid::Kernel::UnitLabel()); MOCK_CONST_METHOD0(getDimensionId, std::string()); MOCK_CONST_METHOD0(getMaximum, diff --git a/Code/Mantid/Vates/VatesAPI/src/Common.cpp b/Code/Mantid/Vates/VatesAPI/src/Common.cpp index 698610bea2c8..5e02d039a6f7 100644 --- a/Code/Mantid/Vates/VatesAPI/src/Common.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/Common.cpp @@ -1,5 +1,6 @@ #include "MantidVatesAPI/Common.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidKernel/UnitLabel.h" #include #include diff --git a/Code/Mantid/Vates/VatesAPI/src/MDEWLoadingPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/MDEWLoadingPresenter.cpp index b1e68d10c77c..a53babad7b30 100644 --- a/Code/Mantid/Vates/VatesAPI/src/MDEWLoadingPresenter.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/MDEWLoadingPresenter.cpp @@ -229,7 +229,7 @@ namespace Mantid { throw std::runtime_error("Have not yet run ::extractMetaData!"); } - return tDimension->getName() + " (" + tDimension->getUnits() + ")"; + return tDimension->getName() + " (" + tDimension->getUnits().ascii() + ")"; } } } diff --git a/Code/Mantid/Vates/VatesAPI/src/MDHWLoadingPresenter.cpp b/Code/Mantid/Vates/VatesAPI/src/MDHWLoadingPresenter.cpp index d816bd391361..07cb4bd2a61d 100644 --- a/Code/Mantid/Vates/VatesAPI/src/MDHWLoadingPresenter.cpp +++ b/Code/Mantid/Vates/VatesAPI/src/MDHWLoadingPresenter.cpp @@ -234,7 +234,7 @@ namespace Mantid { throw std::runtime_error("Have not yet run ::extractMetaData!"); } - return tDimension->getName() + " (" + tDimension->getUnits() + ")"; + return tDimension->getName() + " (" + tDimension->getUnits().ascii() + ")"; } } } diff --git a/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h b/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h index 4c7aff2fc687..0c47cf98ad3a 100644 --- a/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/DimensionPresenterTest.h @@ -6,6 +6,7 @@ #include "MantidVatesAPI/GeometryPresenter.h" #include "MantidVatesAPI/DimensionView.h" #include "MantidGeometry/MDGeometry/MDTypes.h" +#include "MantidKernel/UnitLabel.h" #include "gtest/gtest.h" #include "gmock/gmock.h" @@ -57,7 +58,7 @@ class DimensionPresenterTest: public CxxTest::TestSuite MOCK_CONST_METHOD0(getName, std::string()); MOCK_CONST_METHOD0(getUnits, - std::string()); + const Mantid::Kernel::UnitLabel()); MOCK_CONST_METHOD0(getDimensionId, std::string()); MOCK_CONST_METHOD0(getMaximum, diff --git a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h index 42339484e630..0e68c9966ad4 100644 --- a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h +++ b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h @@ -10,6 +10,7 @@ #include "MantidGeometry/MDGeometry/MDHistoDimension.h" #include "MantidGeometry/MDGeometry/MDTypes.h" #include "MantidGeometry/MDGeometry/MDImplicitFunction.h" +#include "MantidKernel/UnitLabel.h" #include "MantidMDEvents/MDHistoWorkspace.h" #include "MantidVatesAPI/MDLoadingView.h" #include "MantidVatesAPI/Clipper.h" @@ -54,7 +55,7 @@ class FakeIMDDimension: public Mantid::Geometry::IMDDimension public: FakeIMDDimension(std::string id, unsigned int nbins=10) : m_id(id), m_nbins(nbins) {} std::string getName() const {throw std::runtime_error("Not implemented");} - std::string getUnits() const {throw std::runtime_error("Not implemented");} + const Mantid::Kernel::UnitLabel getUnits() const {throw std::runtime_error("Not implemented");} std::string getDimensionId() const {return m_id;} coord_t getMaximum() const {return 10;} coord_t getMinimum() const {return 0;};