Skip to content

Commit

Permalink
Moved some common function to interface. Refs #7653.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Aug 14, 2013
1 parent 4e3ab2e commit 79e4916
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MANTID_API_DLL IPowderDiffPeakFunction : public virtual API::ParamFunction
/// Get peak's centre
virtual double centre() const;
/// Get peak's intensity
virtual double height() const = 0;
virtual double height() const;
/// Get peakl's FWHM
virtual double fwhm()const;
/// Set peak's height
Expand Down Expand Up @@ -151,6 +151,9 @@ class MANTID_API_DLL IPowderDiffPeakFunction : public virtual API::ParamFunction
int mL;
bool mHKLSet;

size_t LATTICEINDEX;
size_t HEIGHTINDEX;

private:
/// Peak intensity
double m_intensity;
Expand Down
24 changes: 22 additions & 2 deletions Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace API
//----------------------------------------------------------------------------------------------
/** Constructor. Sets peak radius to the value of curvefitting.peakRadius property
*/
IPowderDiffPeakFunction::IPowderDiffPeakFunction()
IPowderDiffPeakFunction::IPowderDiffPeakFunction() : LATTICEINDEX(9999), HEIGHTINDEX(9999)
{
// Set peak's radius from configuration
int peakRadius;
Expand Down Expand Up @@ -100,13 +100,33 @@ namespace API

//----------------------------------------------------------------------------------------------
/** Set peak height (intensity indeed)
*/
void IPowderDiffPeakFunction::setHeight(const double h)
{
m_intensity = h;
return;
}
*/

//----------------------------------------------------------------------------------------------
/** Set peak height
*/
void IPowderDiffPeakFunction::setHeight(const double h)
{
setParameter(HEIGHTINDEX, h);

return;
}

//----------------------------------------------------------------------------------------------
/** Get peak's height
*/
double IPowderDiffPeakFunction::height() const
{
double height = this->getParameter(HEIGHTINDEX);
return height;
}

//----------------------------------------------------------------------------------------------
/** Get peak's FWHM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ namespace CurveFitting
virtual void setParameter(const std::string& name, const double& value, bool explicitlySe=true);

/// Set peak's height
virtual void setHeight(const double h);
// virtual void setHeight(const double h);
/// Get peak's height
virtual double height()const;
// virtual double height()const;

using IFunction1D::function;
virtual void function(std::vector<double>& out, const std::vector<double>& xValues) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ where
*WIKI*/

#include "MantidCurveFitting/ThermalNeutronBk2BkExpConvPVoigt.h"
// #include "MantidAPI/Algorithm.h"
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/ParamFunction.h"
#include "MantidKernel/EmptyValues.h"
Expand Down Expand Up @@ -193,6 +192,9 @@ namespace CurveFitting
// Lattice parameter (23)
declareParameter("LatticeConstant", 10.0, "lattice constant for the sample");

LATTICEINDEX = 23;
HEIGHTINDEX = 0;

// Unit cell
m_unitCellSize = 10.0;

Expand Down Expand Up @@ -335,7 +337,7 @@ namespace CurveFitting
double gam1 = getParameter(21);
double gam2 = getParameter(22);

double latticeconstant = getParameter(23);
double latticeconstant = getParameter(LATTICEINDEX);

double dh, tof_h, eta, alpha, beta, H, sigma2, gamma, N;

Expand Down Expand Up @@ -554,23 +556,23 @@ namespace CurveFitting
*/

/** Set peak height
*/
void ThermalNeutronBk2BkExpConvPVoigt::setHeight(const double h)
{
setParameter(0, h);
setParameter(HEIGHTINDEX, h);
return;
}
*/


/** Get peak's height
*/
double ThermalNeutronBk2BkExpConvPVoigt::height() const
{
double height = this->getParameter(0);
double height = this->getParameter(HEIGHTINDEX);
return height;
}

*/

/** Get peak's FWHM
Expand Down Expand Up @@ -673,7 +675,7 @@ namespace CurveFitting
*/
void ThermalNeutronBk2BkExpConvPVoigt::setParameter(size_t i, const double& value, bool explicitlySet)
{
if (i == 23)
if (i == LATTICEINDEX)
{
// Lattice parameter
if (fabs(m_unitCellSize-value) > 1.0E-8)
Expand Down Expand Up @@ -707,7 +709,7 @@ namespace CurveFitting
{
// If change in value is non-trivial
m_cellParamValueChanged = true;
ParamFunction::setParameter(23, value, explicitlySet);
ParamFunction::setParameter(LATTICEINDEX, value, explicitlySet);
m_hasNewParameterValue = true;
m_unitCellSize = value;
}
Expand Down

0 comments on commit 79e4916

Please sign in to comment.