diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h index bf34c77e49f10af27c8143cea0cbb35ab8963a1b..45fc5fe114141970169f6cac1913c23d0c0f9b53 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h @@ -3,6 +3,7 @@ #include "MantidKernel/System.h" #include "MantidNexus/NexusClasses.h" +#include "MantidKernel/V3D.h" namespace Mantid { namespace DataHandling { @@ -54,6 +55,8 @@ public: std::string& parent_class, int indent); std::string dateTimeInIsoFormat(std::string); + void moveComponent(API::MatrixWorkspace_sptr ws, const std::string &componentName,const Kernel::V3D& newPos); + Kernel::V3D getComponentPosition(API::MatrixWorkspace_sptr ws, const std::string &componentName); }; } // namespace DataHandling diff --git a/Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp b/Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp index 7e487bd619779c8bd0b5ee4ddb76a7f3a3a31236..ec01bd6f85d931602876dcff7703d0e90ba9b82a 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp @@ -3,6 +3,7 @@ *WIKI*/ #include "MantidDataHandling/LoadHelper.h" +#include "MantidGeometry/Instrument/ComponentHelper.h" namespace Mantid { namespace DataHandling { @@ -322,5 +323,39 @@ std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) { } } + +void LoadHelper::moveComponent(API::MatrixWorkspace_sptr ws, const std::string &componentName,const V3D& newPos) { + + try { + + Geometry::Instrument_const_sptr instrument = ws->getInstrument(); + Geometry::IComponent_const_sptr component = instrument->getComponentByName(componentName); + + //g_log.debug() << tube->getName() << " : t = " << theta << " ==> t = " << newTheta << "\n"; + Geometry::ParameterMap& pmap = ws->instrumentParameters(); + Geometry::ComponentHelper::moveComponent(*component, pmap, newPos, Geometry::ComponentHelper::Absolute); + + } catch (Mantid::Kernel::Exception::NotFoundError&) { + throw std::runtime_error( + "Error when trying to move the " + componentName + " : NotFoundError"); + } catch (std::runtime_error &) { + throw std::runtime_error( + "Error when trying to move the " + componentName + " : runtime_error"); + } + +} + +V3D LoadHelper::getComponentPosition(API::MatrixWorkspace_sptr ws, const std::string &componentName) { + try { + Geometry::Instrument_const_sptr instrument = ws->getInstrument(); + Geometry::IComponent_const_sptr component = instrument->getComponentByName(componentName); + V3D pos = component->getPos(); + return pos; + } catch (Mantid::Kernel::Exception::NotFoundError&) { + throw std::runtime_error( + "Error when trying to move the " + componentName + " : NotFoundError"); + } +} + } // namespace DataHandling } // namespace Mantid