Skip to content
Snippets Groups Projects
Commit 57bc998d authored by Anton Piccardo-Selg's avatar Anton Piccardo-Selg
Browse files

Refs #13872 md frame factory with horace style

parent 29bee706
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
#include "MantidKernel/MDUnit.h"
#include "MantidKernel/UnitLabelTypes.h"
#include "MantidGeometry/MDGeometry/MDFrame.h"
#include <boost/regex.hpp>
namespace Mantid {
namespace Geometry {
......@@ -58,9 +58,13 @@ bool HKLFrameFactory::canInterpret(const MDFrameArgument &argument) const {
auto unitFactoryChain = Kernel::makeMDUnitFactoryChain();
auto mdUnit = unitFactoryChain->create(argument.unitString);
// We expect units to be RLU or A^-1
const bool compatibleUnit =
(mdUnit->getUnitLabel() == Units::Symbol::InverseAngstrom ||
mdUnit->getUnitLabel() == Units::Symbol::RLU);
auto isInverseAngstrom =
mdUnit->getUnitLabel() == Units::Symbol::InverseAngstrom;
auto isRLU = mdUnit->getUnitLabel() == Units::Symbol::RLU;
boost::regex pattern("in.*A.*\\^-1");
auto isHoraceStyle =
boost::regex_match(mdUnit->getUnitLabel().ascii(), pattern);
const bool compatibleUnit = isInverseAngstrom || isRLU || isHoraceStyle;
// Check both the frame name and the unit name
return argument.frameString == HKL::HKLName && compatibleUnit;
}
......
......@@ -104,6 +104,10 @@ public:
TSM_ASSERT("Should offer to produce HKL products",
factory.canInterpret(
MDFrameArgument(HKL::HKLName, Units::Symbol::RLU)));
TSM_ASSERT(
"Should offer to produce HKL products",
factory.canInterpret(MDFrameArgument(HKL::HKLName, "in 1.684 A^-1")));
}
void test_HKLFrameFactory_create_inverse_angstroms() {
......
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