From 8173c342d8083cd4c60c6632f81bd0c9edd60317 Mon Sep 17 00:00:00 2001
From: Michael Wedel <michael.wedel@psi.ch>
Date: Fri, 27 Mar 2015 10:17:00 +0100
Subject: [PATCH] Refs #9992. Extract interface of PawleyFunction into API

This is currently required so the function can be used in the SINQ module. When the POLDI algorithms are in CurveFitting/Algorithms, this interface can be deleted again.
---
 Code/Mantid/Framework/API/CMakeLists.txt      |  8 +-
 .../API/inc/MantidAPI/IPawleyFunction.h       | 80 +++++++++++++++++++
 .../Framework/API/src/IPawleyFunction.cpp     |  9 +++
 .../inc/MantidCurveFitting/PawleyFunction.h   |  4 +-
 .../CurveFitting/src/PawleyFunction.cpp       |  2 +-
 5 files changed, 97 insertions(+), 6 deletions(-)
 create mode 100644 Code/Mantid/Framework/API/inc/MantidAPI/IPawleyFunction.h
 create mode 100644 Code/Mantid/Framework/API/src/IPawleyFunction.cpp

diff --git a/Code/Mantid/Framework/API/CMakeLists.txt b/Code/Mantid/Framework/API/CMakeLists.txt
index 1380797cf91..4520823c482 100644
--- a/Code/Mantid/Framework/API/CMakeLists.txt
+++ b/Code/Mantid/Framework/API/CMakeLists.txt
@@ -40,7 +40,7 @@ set ( SRC_FILES
 	src/FunctionDomain1D.cpp
 	src/FunctionDomainMD.cpp
 	src/FunctionFactory.cpp
-        src/FunctionParameterDecorator.cpp
+	src/FunctionParameterDecorator.cpp
 	src/FunctionProperty.cpp
 	src/FunctionValues.cpp
 	src/GridDomain.cpp
@@ -61,6 +61,7 @@ set ( SRC_FILES
 	src/IMDHistoWorkspace.cpp
 	src/IMDIterator.cpp
 	src/IMDWorkspace.cpp
+	src/IPawleyFunction.cpp
 	src/IPeak.cpp
 	src/IPeakFunction.cpp
 	src/IPeaksWorkspace.cpp
@@ -184,7 +185,7 @@ set ( INC_FILES
 	inc/MantidAPI/FunctionDomain1D.h
 	inc/MantidAPI/FunctionDomainMD.h
 	inc/MantidAPI/FunctionFactory.h
-        inc/MantidAPI/FunctionParameterDecorator.h
+	inc/MantidAPI/FunctionParameterDecorator.h
 	inc/MantidAPI/FunctionProperty.h
 	inc/MantidAPI/FunctionValues.h
 	inc/MantidAPI/GridDomain.h
@@ -217,6 +218,7 @@ set ( INC_FILES
 	inc/MantidAPI/IMDNode.h
 	inc/MantidAPI/IMDWorkspace.h
 	inc/MantidAPI/IMaskWorkspace.h
+	inc/MantidAPI/IPawleyFunction.h
 	inc/MantidAPI/IPeak.h
 	inc/MantidAPI/IPeakFunction.h
 	inc/MantidAPI/IPeaksWorkspace.h
@@ -325,8 +327,8 @@ set ( TEST_FILES
 	FuncMinimizerFactoryTest.h
 	FunctionAttributeTest.h
 	FunctionDomainTest.h
-        FunctionParameterDecoratorTest.h
 	FunctionFactoryTest.h
+	FunctionParameterDecoratorTest.h
 	FunctionPropertyTest.h
 	FunctionTest.h
 	FunctionValuesTest.h
diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IPawleyFunction.h b/Code/Mantid/Framework/API/inc/MantidAPI/IPawleyFunction.h
new file mode 100644
index 00000000000..f560667902f
--- /dev/null
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/IPawleyFunction.h
@@ -0,0 +1,80 @@
+#ifndef MANTID_API_IPAWLEYFUNCTION_H_
+#define MANTID_API_IPAWLEYFUNCTION_H_
+
+#include "MantidAPI/DllConfig.h"
+#include "MantidAPI/FunctionParameterDecorator.h"
+#include "MantidAPI/IPeakFunction.h"
+
+namespace Mantid {
+namespace API {
+
+/** IPawleyFunction
+
+  This abstract class defines the interface of a PawleyFunction. An
+  implementation can be found in CurveFitting/PawleyFunction. This interface
+  exists so that the function can be used in modules outside CurveFitting.
+
+    @author Michael Wedel, Paul Scherrer Institut - SINQ
+    @date 11/03/2015
+
+  Copyright © 2015 PSI-NXMM
+
+  This file is part of Mantid.
+
+  Mantid is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  Mantid is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  File change history is stored at: <https://github.com/mantidproject/mantid>
+  Code Documentation is available at: <http://doxygen.mantidproject.org>
+*/
+class MANTID_API_DLL IPawleyFunction : public FunctionParameterDecorator {
+public:
+  IPawleyFunction();
+  /// Virtual destructor.
+  virtual ~IPawleyFunction() {}
+
+  /// A string that names the crystal system.
+  virtual void setCrystalSystem(const std::string &crystalSystem) = 0;
+
+  /// Sets the name of the profile function used for the reflections.
+  virtual void setProfileFunction(const std::string &profileFunction) = 0;
+
+  /// Set the function parameters according to the supplied unit cell.
+  virtual void setUnitCell(const std::string &unitCellString) = 0;
+
+  /// Assign several peaks with the same fwhm/height parameters.
+  virtual void setPeaks(const std::vector<Kernel::V3D> &hkls, double fwhm,
+                        double height) = 0;
+
+  /// Removes all peaks from the function.
+  virtual void clearPeaks() = 0;
+
+  /// Add a peak with the given parameters.
+  virtual void addPeak(const Kernel::V3D &hkl, double fwhm, double height) = 0;
+
+  /// Returns the number of peaks in the function
+  virtual size_t getPeakCount() const = 0;
+
+  /// Returns the profile function stored for the i-th peak.
+  virtual IPeakFunction_sptr getPeakFunction(size_t i) const = 0;
+
+  /// Returns the Miller indices stored for the i-th peak.
+  virtual Kernel::V3D getPeakHKL(size_t i) const = 0;
+};
+
+typedef boost::shared_ptr<IPawleyFunction> IPawleyFunction_sptr;
+
+} // namespace API
+} // namespace Mantid
+
+#endif /* MANTID_API_IPAWLEYFUNCTION_H_ */
diff --git a/Code/Mantid/Framework/API/src/IPawleyFunction.cpp b/Code/Mantid/Framework/API/src/IPawleyFunction.cpp
new file mode 100644
index 00000000000..caeae3cf971
--- /dev/null
+++ b/Code/Mantid/Framework/API/src/IPawleyFunction.cpp
@@ -0,0 +1,9 @@
+#include "MantidAPI/IPawleyFunction.h"
+
+namespace Mantid {
+namespace API {
+/// Default constructor
+IPawleyFunction::IPawleyFunction() : FunctionParameterDecorator() {}
+
+} // namespace API
+} // namespace Mantid
diff --git a/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PawleyFunction.h b/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PawleyFunction.h
index cb0e9fb7aca..441ea1ff7b0 100644
--- a/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PawleyFunction.h
+++ b/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PawleyFunction.h
@@ -3,7 +3,7 @@
 
 #include "MantidKernel/System.h"
 #include "MantidAPI/CompositeFunction.h"
-#include "MantidAPI/FunctionParameterDecorator.h"
+#include "MantidAPI/IPawleyFunction.h"
 #include "MantidAPI/MatrixWorkspace.h"
 #include "MantidAPI/IPeakFunction.h"
 #include "MantidAPI/ParamFunction.h"
@@ -106,7 +106,7 @@ typedef boost::shared_ptr<PawleyParameterFunction> PawleyParameterFunction_sptr;
   File change history is stored at: <https://github.com/mantidproject/mantid>
   Code Documentation is available at: <http://doxygen.mantidproject.org>
 */
-class DLLExport PawleyFunction : public API::FunctionParameterDecorator {
+class DLLExport PawleyFunction : public API::IPawleyFunction {
 public:
   PawleyFunction();
   virtual ~PawleyFunction() {}
diff --git a/Code/Mantid/Framework/CurveFitting/src/PawleyFunction.cpp b/Code/Mantid/Framework/CurveFitting/src/PawleyFunction.cpp
index 58f59765777..b54db9de6e7 100644
--- a/Code/Mantid/Framework/CurveFitting/src/PawleyFunction.cpp
+++ b/Code/Mantid/Framework/CurveFitting/src/PawleyFunction.cpp
@@ -267,7 +267,7 @@ DECLARE_FUNCTION(PawleyFunction)
 
 /// Constructor
 PawleyFunction::PawleyFunction()
-    : FunctionParameterDecorator(), m_compositeFunction(),
+    : IPawleyFunction(), m_compositeFunction(),
       m_pawleyParameterFunction(), m_peakProfileComposite(), m_hkls(),
       m_dUnit(), m_wsUnit() {}
 
-- 
GitLab