Commit a1377b17 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Call setMatrixWorkspace for all 1d functions. Re #7572.

parent 49f0dc00
......@@ -66,6 +66,8 @@ public:
std::string asString()const;
/// Sets the workspace for each member function
void setWorkspace(boost::shared_ptr<const Workspace> ws);
/// Set matrix workspace
void setMatrixWorkspace(boost::shared_ptr<const API::MatrixWorkspace> workspace,size_t wi,double startX, double endX);
/// Function you want to fit to.
virtual void function(const FunctionDomain& domain, FunctionValues& values)const;
......
......@@ -162,6 +162,20 @@ void CompositeFunction::setWorkspace(boost::shared_ptr<const Workspace> ws)
}
}
/**
* @param workspace :: A workspace to fit to.
* @param wi :: An index of a spectrum to fit to.
* @param startX :: A start of the fitting region.
* @param endX :: An end of the fitting region.
*/
void CompositeFunction::setMatrixWorkspace(boost::shared_ptr<const MatrixWorkspace> workspace, size_t wi, double startX, double endX)
{
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
m_functions[ iFun ]->setMatrixWorkspace( workspace, wi, startX, endX );
}
}
/** Function you want to fit to.
* @param domain :: An instance of FunctionDomain with the function arguments.
* @param values :: A FunctionValues instance for storing the calculated values.
......
......@@ -441,15 +441,8 @@ namespace
{
throw std::runtime_error("Cannot initialize empty function.");
}
API::IFunctionMW* funMW = dynamic_cast<API::IFunctionMW*>(function.get());
if (funMW)
{
funMW->setMatrixWorkspace( m_matrixWorkspace, m_workspaceIndex, m_startX, m_endX);
}
else
{
function->setWorkspace(m_matrixWorkspace);
}
function->setWorkspace(m_matrixWorkspace);
function->setMatrixWorkspace( m_matrixWorkspace, m_workspaceIndex, m_startX, m_endX);
}
//--------------------------------------------------------------------------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment