diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h b/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h index 65e39c1bba5269497d3ef3d4e3a2a16996383e68..442f9cca369e8f7df91539101b7a753562659d07 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h @@ -3,6 +3,7 @@ #include "MantidAPI/DllConfig.h" #include "MantidGeometry/Instrument.h" +#include "MantidGeometry/Crystal/PeakShape.h" #include "MantidKernel/Matrix.h" #include "MantidKernel/V3D.h" #include "MantidKernel/PhysicalConstants.h" @@ -84,6 +85,8 @@ public: virtual Mantid::Kernel::V3D getDetPos() const = 0; virtual double getL1() const = 0; virtual double getL2() const = 0; + + virtual const Mantid::Geometry::PeakShape& getPeakShape() = 0; }; } // namespace Mantid diff --git a/Code/Mantid/Framework/API/test/MockObjects.h b/Code/Mantid/Framework/API/test/MockObjects.h index ed5d1d698e8c673a459badaa938f140795fb0520..63509d04079ee22e7284c9f14f6a813a5b9c3681 100644 --- a/Code/Mantid/Framework/API/test/MockObjects.h +++ b/Code/Mantid/Framework/API/test/MockObjects.h @@ -10,7 +10,7 @@ #include "MantidAPI/PeakTransform.h" #include "MantidAPI/PeakTransformFactory.h" -#include "MantidAPI/IPeaksWorkspace.h" +#include "MantidAPI/PeaksWorkspace.h" #include "MantidAPI/IPeak.h" #include <boost/regex.hpp> #include <gmock/gmock.h> @@ -156,6 +156,7 @@ namespace Mantid::Kernel::V3D()); MOCK_CONST_METHOD0(getDetectorPositionNoCheck, Mantid::Kernel::V3D()); + MOCK_METHOD0(getPeakShape, const Mantid::Geometry::PeakShape&()); }; diff --git a/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp b/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp index e483f4795f0e34cb60003fde1e06db48a03a7f08..b3403dbee16e637a4cae399e3f61bfd8c63dc185 100644 --- a/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp +++ b/Code/Mantid/Framework/DataObjects/src/PeakShapeSpherical.cpp @@ -51,7 +51,7 @@ PeakShapeSpherical::PeakShapeSpherical(const double &peakRadius, PeakShapeSpherical::~PeakShapeSpherical() {} /** - * @brief Copy constructor + * @brief Copy constructor from other PeakShapeSpherical * @param other : source of the copy */ PeakShapeSpherical::PeakShapeSpherical(const PeakShapeSpherical &other) diff --git a/Code/Mantid/Framework/DataObjects/test/PeakShapeEllipsoidTest.h b/Code/Mantid/Framework/DataObjects/test/PeakShapeEllipsoidTest.h index fd54e13854a6f96b4d1ab579745c36e1ad6adaa1..d22daf414d8127ec3d03dd9fe1ecd9f85801d4f5 100644 --- a/Code/Mantid/Framework/DataObjects/test/PeakShapeEllipsoidTest.h +++ b/Code/Mantid/Framework/DataObjects/test/PeakShapeEllipsoidTest.h @@ -11,6 +11,7 @@ #include <jsoncpp/json/json.h> using Mantid::DataObjects::PeakShapeEllipsoid; +using Mantid::Kernel::SpecialCoordinateSystem; using namespace Mantid; using namespace Mantid::Kernel; using namespace boost::assign; diff --git a/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp b/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp index 504427e5f5e320e6161d885bee3fd28b3d48c875..c5d3eec3e73f29116abd353fdb58a65770c3efe7 100644 --- a/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp +++ b/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp @@ -5,6 +5,13 @@ using Mantid::API::IPeak; using namespace boost::python; +namespace { +Mantid::Geometry::PeakShape_sptr getPeakShape(IPeak& peak) { + // Use clone to make a copy of the PeakShape. + return Mantid::Geometry::PeakShape_sptr(peak.getPeakShape().clone()); +} +} + void export_IPeak() { register_ptr_to_python<IPeak*>(); @@ -53,6 +60,7 @@ void export_IPeak() .def("getDetPos", &IPeak::getDetPos, "Return the detector position vector") .def("getL1", &IPeak::getL1, "Return the L1 flight path length (source to sample), in meters. ") .def("getL2", &IPeak::getL2, "Return the L2 flight path length (sample to detector), in meters.") + .def("getPeakShape", getPeakShape, "Get the peak shape") ; } diff --git a/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/PeakShape.cpp b/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/PeakShape.cpp index f9f1bff388c7ab6d1da14c155c30f6ea2850070d..d73179460a2c683dc74921c6311d9b907a601755 100644 --- a/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/PeakShape.cpp +++ b/Code/Mantid/Framework/PythonInterface/mantid/geometry/src/Exports/PeakShape.cpp @@ -8,7 +8,7 @@ using namespace boost::python; void export_PeakShape() { - register_ptr_to_python<PeakShape*>(); + register_ptr_to_python<Mantid::Geometry::PeakShape_sptr>(); class_<PeakShape, boost::noncopyable>("PeakShape", no_init) .def("toJSON", &PeakShape::toJSON, "Serialize object to JSON") diff --git a/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/CMakeLists.txt b/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/CMakeLists.txt index 437a33a1fbf24c09081cf50c929f5b3a06bc4ffc..cdcd57e2751c0a7fc04ab7825cf2bf17033e5ff1 100644 --- a/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/CMakeLists.txt +++ b/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/CMakeLists.txt @@ -11,6 +11,7 @@ set ( TEST_PY_FILES RectangularDetectorTest.py ReferenceFrameTest.py UnitCellTest.py + PeakShapeTest.py PointGroupTest.py SpaceGroupTest.py SymmetryOperationTest.py diff --git a/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py b/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py new file mode 100644 index 0000000000000000000000000000000000000000..ac730339b63440c92815e15c3a083f5cfc9e983e --- /dev/null +++ b/Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py @@ -0,0 +1,17 @@ +import unittest +from mantid.simpleapi import CreatePeaksWorkspace, CreateSampleWorkspace +from mantid.geometry import PeakShape + +class PeakShapeTest(unittest.TestCase): + + def test_basic_access(self): + sampleWs = CreateSampleWorkspace() + ws = CreatePeaksWorkspace(InstrumentWorkspace=sampleWs,NumberOfPeaks=1) + peak = ws.getPeak(0) + peak_shape = peak.getPeakShape() + self.assertTrue(isinstance(peak_shape, PeakShape)) + self.assertEquals(peak_shape.shapeName(), "none") + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h b/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h index 5180a02fca33f74c58b0be44b8617fb12eee8375..da6b3e1a4c57fe2ace5fd2af5c15f8edf92b630b 100644 --- a/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h +++ b/Code/Mantid/MantidQt/SliceViewer/test/MockObjects.h @@ -253,7 +253,8 @@ class MockPeakTransformFactory : public PeakTransformFactory Mantid::Kernel::V3D()); MOCK_CONST_METHOD0(getDetectorPositionNoCheck, Mantid::Kernel::V3D()); - }; + MOCK_METHOD0(getPeakShape, const Mantid::Geometry::PeakShape&()); +}; /*------------------------------------------------------------ Mock MDGeometry