Commit f8b01fec authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #9257. Move PeakTransform to Mantid API.

This allows the PeakTransform to be used in multiple projects. It is required in Crystal where Peak coordinates must also be properly selected and transformed according to an IMDWorkspace setup.
parent ebe894c0
......@@ -89,6 +89,11 @@ set ( SRC_FILES
src/ParamFunction.cpp
src/ParameterReference.cpp
src/ParameterTie.cpp
src/PeakTransform.cpp
src/PeakTransformHKL.cpp
src/PeakTransformQLab.cpp
src/PeakTransformQSample.cpp
src/PeakTransformSelector.cpp
src/Progress.cpp
src/PropertyManagerDataService.cpp
src/PropertyNexus.cpp
......@@ -145,6 +150,7 @@ set ( INC_FILES
inc/MantidAPI/CompositeDomain.h
inc/MantidAPI/CompositeDomainMD.h
inc/MantidAPI/CompositeFunction.h
inc/MantidAPI/ConcretePeakTransformFactory.h
inc/MantidAPI/ConstraintFactory.h
inc/MantidAPI/CoordTransform.h
inc/MantidAPI/CostFunctionFactory.h
......@@ -236,6 +242,12 @@ set ( INC_FILES
inc/MantidAPI/ParamFunction.h
inc/MantidAPI/ParameterReference.h
inc/MantidAPI/ParameterTie.h
inc/MantidAPI/PeakTransform.h
inc/MantidAPI/PeakTransformFactory.h
inc/MantidAPI/PeakTransformHKL.h
inc/MantidAPI/PeakTransformQLab.h
inc/MantidAPI/PeakTransformQSample.h
inc/MantidAPI/PeakTransformSelector.h
inc/MantidAPI/Progress.h
inc/MantidAPI/PropertyManagerDataService.h
inc/MantidAPI/PropertyNexus.h
......@@ -320,6 +332,10 @@ set ( TEST_FILES
ParamFunctionAttributeHolderTest.h
ParameterReferenceTest.h
ParameterTieTest.h
PeakTransformHKLTest.h
PeakTransformQLabTest.h
PeakTransformQSampleTest.h
PeakTransformSelectorTest.h
PropertyManagerDataServiceTest.h
PropertyNexusTest.h
RunTest.h
......
#ifndef MANTID_SLICEVIEWER_CONCRETEPEAKTRANSFORMFACTORY_H_
#define MANTID_SLICEVIEWER_CONCRETEPEAKTRANSFORMFACTORY_H_
#ifndef MANTID_API_CONCRETEPEAKTRANSFORMFACTORY_H_
#define MANTID_API_CONCRETEPEAKTRANSFORMFACTORY_H_
#include "MantidQtSliceViewer/PeakTransformFactory.h"
#include "MantidAPI/PeakTransformFactory.h"
#include <boost/make_shared.hpp>
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class ConcretePeakTransformFactory
......
#ifndef MANTID_SLICEVIEWER_PEAKTRANSFORM_H_
#define MANTID_SLICEVIEWER_PEAKTRANSFORM_H_
#ifndef MANTID_API_PEAKTRANSFORM_H_
#define MANTID_API_PEAKTRANSFORM_H_
#include "MantidKernel/V3D.h"
#include "MantidAPI/IPeak.h"
......@@ -7,9 +7,9 @@
#include <boost/shared_ptr.hpp>
#include "MantidAPI/SpecialCoordinateSystem.h"
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class PeakTransform
......@@ -70,4 +70,4 @@ namespace MantidQt
}
}
#endif /* MANTID_SLICEVIEWER_CONCRETEPEAKSPRESENTER_H_ */
#endif /* MANTID_API_CONCRETEPEAKSPRESENTER_H_ */
#ifndef MANTID_SLICEVIEWER_PEAKTRANSFORMFACTORY_H_
#define MANTID_SLICEVIEWER_PEAKTRANSFORMFACTORY_H_
#ifndef MANTID_API_PEAKTRANSFORMFACTORY_H_
#define MANTID_API_PEAKTRANSFORMFACTORY_H_
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidAPI/PeakTransform.h"
#include <boost/shared_ptr.hpp>
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class PeakTransformFactory
......@@ -25,4 +25,4 @@ namespace MantidQt
}
}
#endif
\ No newline at end of file
#endif
#ifndef MANTID_SLICEVIEWER_PEAKTRANSFORMHKL_H_
#define MANTID_SLICEVIEWER_PEAKTRANSFORMHKL_H_
#ifndef MANTID_API_PEAKTRANSFORMHKL_H_
#define MANTID_API_PEAKTRANSFORMHKL_H_
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/ConcretePeakTransformFactory.h"
#include "MantidAPI/PeakTransform.h"
#include "MantidAPI/ConcretePeakTransformFactory.h"
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class PeakTransformHKL
......@@ -45,4 +45,4 @@ namespace MantidQt
}
}
#endif /* MANTID_SLICEVIEWER_CONCRETEPEAKSPRESENTERHKL_H_ */
#endif /* MANTID_API_CONCRETEPEAKSPRESENTERHKL_H_ */
#ifndef MANTID_SLICEVIEWER_PeakTransformQLab_H_
#define MANTID_SLICEVIEWER_PeakTransformQLab_H_
#ifndef MANTID_API_PeakTransformQLab_H_
#define MANTID_API_PeakTransformQLab_H_
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/ConcretePeakTransformFactory.h"
#include "MantidAPI/PeakTransform.h"
#include "MantidAPI/ConcretePeakTransformFactory.h"
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class PeakTransformQLab
......@@ -45,4 +45,4 @@ namespace MantidQt
}
}
#endif /* MANTID_SLICEVIEWER_PeakTransformQLab_H_ */
#endif /* MANTID_API_PeakTransformQLab_H_ */
#ifndef MANTID_SLICEVIEWER_PEAKTRANSFORMQSAMPLE_H_
#define MANTID_SLICEVIEWER_PEAKTRANSFORMQSAMPLE_H_
#ifndef MANTID_API_PEAKTRANSFORMQSAMPLE_H_
#define MANTID_API_PEAKTRANSFORMQSAMPLE_H_
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/ConcretePeakTransformFactory.h"
#include "MantidAPI/PeakTransform.h"
#include "MantidAPI/ConcretePeakTransformFactory.h"
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class PeakTransformQSample
......@@ -46,4 +46,4 @@ namespace MantidQt
}
}
#endif /* MANTID_SLICEVIEWER_PEAKTRANSFORMQSAMPLE_H_ */
#endif /* MANTID_API_PEAKTRANSFORMQSAMPLE_H_ */
#ifndef MANTID_SLICEVIEWER_PEAKTRANSFORMSELECTOR_H_
#define MANTID_SLICEVIEWER_PEAKTRANSFORMSELECTOR_H_
#ifndef MANTID_API_PEAKTRANSFORMSELECTOR_H_
#define MANTID_API_PEAKTRANSFORMSELECTOR_H_
#include "MantidQtSliceViewer/PeakTransformFactory.h"
#include "MantidAPI/PeakTransformFactory.h"
#include <set>
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/**
@class PeakTransformSelector
......@@ -41,4 +41,4 @@ namespace MantidQt
}
}
#endif
\ No newline at end of file
#endif
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidAPI/PeakTransform.h"
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
PeakTransform::PeakTransform(const std::string& xPlotLabel, const std::string& yPlotLabel, const boost::regex& regexOne, const boost::regex& regexTwo, const boost::regex& regexThree) :
m_xPlotLabel(xPlotLabel),
......
#include "MantidQtSliceViewer/PeakTransformHKL.h"
#include "MantidAPI/PeakTransformHKL.h"
#include <boost/make_shared.hpp>
using boost::regex;
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
PeakTransformHKL::PeakTransformHKL() : PeakTransform("H", "K", regex("^(H.*)|(\\[H,0,0\\].*)$"), regex("^(K.*)|(\\[0,K,0\\].*)$"), regex("^(L.*)|(\\[0,0,L\\].*)$") )
......
#include "MantidQtSliceViewer/PeakTransformQLab.h"
#include "MantidAPI/PeakTransformQLab.h"
#include <boost/make_shared.hpp>
using boost::regex;
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
PeakTransformQLab::PeakTransformQLab() : PeakTransform("Q_lab_x", "Q_lab_y", regex("^Q_lab_x.*$"), regex("^Q_lab_y.*$"), regex("^Q_lab_z.*$") )
......
#include "MantidQtSliceViewer/PeakTransformQSample.h"
#include "MantidAPI/PeakTransformQSample.h"
#include <boost/make_shared.hpp>
using boost::regex;
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
PeakTransformQSample::PeakTransformQSample() : PeakTransform("Q_sample_x", "Q_sample_y", regex("^Q_sample_x.*$"), regex("^Q_sample_y.*$"), regex("^Q_sample_z.*$") )
......
#include "MantidQtSliceViewer/PeakTransformSelector.h"
#include "MantidAPI/PeakTransformSelector.h"
#include <stdexcept>
namespace MantidQt
namespace Mantid
{
namespace SliceViewer
namespace API
{
/// Constructor
PeakTransformSelector::PeakTransformSelector()
......
/*
* MockObjects.h
*
* Created on: Apr 8, 2014
* Author: spu92482
*/
#ifndef MANTIDAPITEST_MOCKOBJECTS_H_
#define MANTIDAPITEST_MOCKOBJECTS_H_
#include "MantidAPI/PeakTransform.h"
#include "MantidAPI/PeakTransformFactory.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidAPI/IPeak.h"
#include <boost/regex.hpp>
#include <gmock/gmock.h>
using namespace Mantid::API;
using namespace Mantid;
using boost::regex;
namespace
{
/*------------------------------------------------------------
Mock Peak Transform
------------------------------------------------------------*/
class MockPeakTransform: public PeakTransform
{
public:
MockPeakTransform() :
PeakTransform("H (Lattice)", "K (Lattice)", regex("^H.*$"), regex("^K.*$"), regex("^L.*$"))
{
}
~MockPeakTransform()
{
}
MOCK_CONST_METHOD0(clone, PeakTransform_sptr());
MOCK_CONST_METHOD1(transform, Mantid::Kernel::V3D(const Mantid::Kernel::V3D&));
MOCK_CONST_METHOD1(transformPeak, Mantid::Kernel::V3D(const Mantid::API::IPeak&));
MOCK_CONST_METHOD0(getFriendlyName, std::string());
MOCK_CONST_METHOD0(getCoordinateSystem, Mantid::API::SpecialCoordinateSystem());
};
/*------------------------------------------------------------
Mock Peak Transform Factory
------------------------------------------------------------*/
class MockPeakTransformFactory: public PeakTransformFactory
{
public:
MOCK_CONST_METHOD0(createDefaultTransform, PeakTransform_sptr());
MOCK_CONST_METHOD2(createTransform, PeakTransform_sptr(const std::string&, const std::string&));
};
/*------------------------------------------------------------
Mock IPeak
------------------------------------------------------------*/
class MockIPeak : public Mantid::API::IPeak
{
public:
MOCK_METHOD1(setInstrument,
void(Geometry::Instrument_const_sptr inst));
MOCK_CONST_METHOD0(getDetectorID,
int());
MOCK_METHOD1(setDetectorID,
void(int m_DetectorID));
MOCK_CONST_METHOD0(getDetector,
Geometry::IDetector_const_sptr());
MOCK_CONST_METHOD0(getInstrument,
Geometry::Instrument_const_sptr());
MOCK_CONST_METHOD0(getRunNumber,
int());
MOCK_METHOD1(setRunNumber,
void(int m_RunNumber));
MOCK_CONST_METHOD0(getMonitorCount,
double());
MOCK_METHOD1(setMonitorCount,
void(double m_MonitorCount));
MOCK_CONST_METHOD0(getH,
double());
MOCK_CONST_METHOD0(getK,
double());
MOCK_CONST_METHOD0(getL,
double());
MOCK_CONST_METHOD0(getHKL,
Mantid::Kernel::V3D());
MOCK_METHOD1(setH,
void(double m_H));
MOCK_METHOD1(setK,
void(double m_K));
MOCK_METHOD1(setL,
void(double m_L));
MOCK_METHOD3(setHKL,
void(double H, double K, double L));
MOCK_METHOD1(setHKL,
void(Mantid::Kernel::V3D HKL));
MOCK_CONST_METHOD0(getQLabFrame,
Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getQSampleFrame,
Mantid::Kernel::V3D());
MOCK_METHOD0(findDetector,
bool());
MOCK_METHOD2(setQSampleFrame,
void(Mantid::Kernel::V3D QSampleFrame, double detectorDistance));
MOCK_METHOD2(setQLabFrame,
void(Mantid::Kernel::V3D QLabFrame, double detectorDistance));
MOCK_METHOD1(setWavelength,
void(double wavelength));
MOCK_CONST_METHOD0(getWavelength,
double());
MOCK_CONST_METHOD0(getScattering,
double());
MOCK_CONST_METHOD0(getDSpacing,
double());
MOCK_CONST_METHOD0(getTOF,
double());
MOCK_CONST_METHOD0(getInitialEnergy,
double());
MOCK_CONST_METHOD0(getFinalEnergy,
double());
MOCK_METHOD1(setInitialEnergy,
void(double m_InitialEnergy));
MOCK_METHOD1(setFinalEnergy,
void(double m_FinalEnergy));
MOCK_CONST_METHOD0(getIntensity,
double());
MOCK_CONST_METHOD0(getSigmaIntensity,
double());
MOCK_METHOD1(setIntensity,
void(double m_Intensity));
MOCK_METHOD1(setSigmaIntensity,
void(double m_SigmaIntensity));
MOCK_CONST_METHOD0(getBinCount,
double());
MOCK_METHOD1(setBinCount,
void(double m_BinCount));
MOCK_CONST_METHOD0(getGoniometerMatrix,
Mantid::Kernel::Matrix<double>());
MOCK_METHOD1(setGoniometerMatrix,
void(Mantid::Kernel::Matrix<double> m_GoniometerMatrix));
MOCK_CONST_METHOD0(getBankName,
std::string());
MOCK_CONST_METHOD0(getRow,
int());
MOCK_CONST_METHOD0(getCol,
int());
MOCK_CONST_METHOD0(getDetPos,
Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getL1,
double());
MOCK_CONST_METHOD0(getL2,
double());
MOCK_CONST_METHOD0(getDetectorPosition,
Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getDetectorPositionNoCheck,
Mantid::Kernel::V3D());
};
}
#endif /* MANTIDAPITEST_MOCKOBJECTS_H_ */
......@@ -2,13 +2,11 @@
#define SLICE_VIEWER_PEAKTRANSFORMHKL_TEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidQtSliceViewer/PeakTransformHKL.h"
#include "MantidCrystal/PeaksInRegion.h"
#include "MantidAPI/PeakTransformHKL.h"
#include "MockObjects.h"
#include <boost/make_shared.hpp>
using namespace MantidQt::SliceViewer;
using namespace Mantid;
using namespace Mantid::API;
using Mantid::Kernel::V3D;
using namespace testing;
......@@ -271,10 +269,6 @@ void test_getFriendlyName()
TS_ASSERT_EQUALS("HKL", transform.getFriendlyName());
}
void test_friendlyname_against_PeaksInRegion()
{
TSM_ASSERT_EQUALS("These labels must be compatible", PeakTransformHKL::name(), Mantid::Crystal::PeaksInRegion::hklFrame());
}
void test_getCoordinateSystem()
{
......
#ifndef SLICE_VIEWER_PEAKTRANSFORMQLAB_TEST_H_
#define SLICE_VIEWER_PEAKTRANSFORMQLAB_TEST_H_
#ifndef MANTIDAPI_PEAKTRANSFORMQLAB_TEST_H_
#define MANTIDAPI_PEAKTRANSFORMQLAB_TEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidCrystal/PeaksInRegion.h"
#include "MantidQtSliceViewer/PeakTransformQLab.h"
#include "MantidAPI/PeakTransformQLab.h"
#include "MockObjects.h"
#include <boost/make_shared.hpp>
using namespace MantidQt::SliceViewer;
using namespace Mantid::API;
using namespace Mantid;
using Mantid::Kernel::V3D;
using namespace testing;
......@@ -211,12 +210,8 @@ void test_getCoordinateSystem()
TS_ASSERT_EQUALS(Mantid::API::QLab, transform.getCoordinateSystem())
}
void test_friendlyname_against_PeaksInRegion()
{
TSM_ASSERT_EQUALS("These labels must be compatible", PeakTransformQLab::name(), Mantid::Crystal::PeaksInRegion::qLabFrame());
}
};
#endif
//end SLICE_VIEWER_PEAKTRANSFORMQLAB_TEST_H_
//end MANTIDAPI_PEAKTRANSFORMQLAB_TEST_H_
#ifndef SLICE_VIEWER_PEAKTRANSFORMQSAMPLE_TEST_H_
#define SLICE_VIEWER_PEAKTRANSFORMQSAMPLE_TEST_H_
#ifndef MANTIDAPI_PEAKTRANSFORMQSAMPLE_TEST_H_
#define MANTIDAPI_PEAKTRANSFORMQSAMPLE_TEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidCrystal/PeaksInRegion.h"
#include "MantidQtSliceViewer/PeakTransformQSample.h"
#include "MantidAPI/PeakTransformQSample.h"
#include "MockObjects.h"
#include <boost/make_shared.hpp>
using namespace MantidQt::SliceViewer;
using namespace Mantid::API;
using namespace Mantid;
using Mantid::Kernel::V3D;
using namespace testing;
......@@ -211,13 +210,7 @@ void test_getCoordinateSystem()
TS_ASSERT_EQUALS(Mantid::API::QSample, transform.getCoordinateSystem())
}
void test_friendlyname_against_PeaksInRegion()
{
TSM_ASSERT_EQUALS("These labels must be compatible", PeakTransformQSample::name(), Mantid::Crystal::PeaksInRegion::qSampleFrame());
}
};
#endif
//end SLICE_VIEWER_PEAKTRANSFORMQSAMPLE_TEST_H_
//end MANTIDAPI_PEAKTRANSFORMQSAMPLE_TEST_H_
#ifndef SLICE_VIEWER_PEAKTRANSFORMSELECTOR_TEST_H_
#define SLICE_VIEWER_PEAKTRANSFORMSELECTOR_TEST_H_
#ifndef MANTIDAPI_PEAKTRANSFORMSELECTOR_TEST_H_
#define MANTIDAPI_PEAKTRANSFORMSELECTOR_TEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidQtSliceViewer/PeakTransform.h"
#include "MantidQtSliceViewer/PeakTransformSelector.h"
#include "MantidAPI/PeakTransform.h"
#include "MantidAPI/PeakTransformSelector.h"
#include "MockObjects.h"
using namespace MantidQt::SliceViewer;
using namespace Mantid::API;
using namespace Mantid;
using namespace testing;
using boost::regex;
......
......@@ -16,11 +16,6 @@ set ( SRC_FILES
src/PeakOverlayViewFactorySelector.cpp
src/PeakPalette.cpp
src/PeaksTableColumnsDialog.cpp
src/PeakTransform.cpp
src/PeakTransformHKL.cpp
src/PeakTransformQSample.cpp
src/PeakTransformQLab.cpp
src/PeakTransformSelector.cpp
src/PeaksViewer.cpp
src/PeaksWorkspaceWidget.cpp
src/PhysicalCrossPeak.cpp
......@@ -41,7 +36,6 @@ set ( INC_FILES
inc/MantidQtSliceViewer/ColorBarWidget.h
inc/MantidQtSliceViewer/CompositePeaksPresenter.h
inc/MantidQtSliceViewer/ConcretePeaksPresenter.h
inc/MantidQtSliceViewer/ConcretePeakTransformFactory.h
inc/MantidQtSliceViewer/CustomTools.h
inc/MantidQtSliceViewer/DimensionSliceWidget.h
inc/MantidQtSliceViewer/FirstExperimentInfoQuery.h
......@@ -61,12 +55,6 @@ set ( INC_FILES
inc/MantidQtSliceViewer/PeakPalette.h
inc/MantidQtSliceViewer/PeaksPresenter.h
inc/MantidQtSliceViewer/PeaksTableColumnsDialog.h
inc/MantidQtSliceViewer/PeakTransformHKL.h
inc/MantidQtSliceViewer/PeakTransformQSample.h
inc/MantidQtSliceViewer/PeakTransformQLab.h
inc/MantidQtSliceViewer/PeakTransform.h
inc/MantidQtSliceViewer/PeakTransformFactory.h
inc/MantidQtSliceViewer/PeakTransformSelector.h
inc/MantidQtSliceViewer/PeaksViewer.h
inc/MantidQtSliceViewer/PeaksViewerOverlayDialog.h
inc/MantidQtSliceViewer/PeaksWorkspaceWidget.h
......@@ -124,11 +112,6 @@ set ( TEST_FILES
test/ConcretePeaksPresenterTest.h
test/PeakBoundingBoxTest.h
test/PeakPaletteTest.h
test/PeakOverlayViewFactorySelectorTest.h
test/PeakTransformHKLTest.h
test/PeakTransformQSampleTest.h
test/PeakTransformQLabTest.h
test/PeakTransformSelectorTest.h
test/PhysicalCrossPeakTest.h
test/PhysicalSphericalPeakTest.h
test/NullPeaksPresenterTest.h
......
#ifndef MANTID_SLICEVIEWER_CONCRETEPEAKSPRESENTER_H_
#define MANTID_SLICEVIEWER_CONCRETEPEAKSPRESENTER_H_