Commit 83e98167 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Changed the design of the FitPropertyBrowser. re #1033

parent a6af537c
......@@ -122,7 +122,7 @@ public:
/* CompositeFunction own methods */
/// Add a function at the back of the internal function list
void addFunction(IFunction* f);
int addFunction(IFunction* f);
/// Returns the pointer to i-th function
IFunction* getFunction(int i)const;
/// Number of functions
......
......@@ -363,8 +363,9 @@ int CompositeFunction::activeIndex(int i)const
/** Add a function
* @param f A pointer to the added function
* @return The function index
*/
void CompositeFunction::addFunction(IFunction* f)
int CompositeFunction::addFunction(IFunction* f)
{
m_iFunction.insert(m_iFunction.end(),f->nParams(),m_functions.size());
m_iFunctionActive.insert(m_iFunctionActive.end(),f->nActive(),m_functions.size());
......@@ -384,6 +385,7 @@ void CompositeFunction::addFunction(IFunction* f)
m_nParams += f->nParams();
m_nActive += f->nActive();
}
return m_functions.size()-1;
}
/** Remove a function
......
......@@ -82,7 +82,7 @@ void RealFFT::exec()
int xOutSize = inWS->isHistogramData() ? yOutSize + 1 : yOutSize;
bool odd = ySize % 2 != 0;
outWS = WorkspaceFactory::Instance().create("Workspace2D",2,xOutSize,yOutSize);
outWS = WorkspaceFactory::Instance().create(inWS,2,xOutSize,yOutSize);
gsl_fft_real_workspace * workspace = gsl_fft_real_workspace_alloc(ySize);
boost::shared_array<double> data(new double[2*ySize]);
......@@ -111,6 +111,8 @@ void RealFFT::exec()
outWS->dataX(0)[yOutSize] = outWS->dataX(0)[yOutSize - 1] + df;
}
outWS->dataX(1) = outWS->dataX(0);
outWS->getAxis(1)->spectraNo(0)=inWS->getAxis(1)->spectraNo(spec);
outWS->getAxis(1)->spectraNo(1)=inWS->getAxis(1)->spectraNo(spec);
}
else // Backward
{
......@@ -125,7 +127,7 @@ void RealFFT::exec()
df = 1.0 / (dx * (yOutSize));
outWS = WorkspaceFactory::Instance().create("Workspace2D",1,xOutSize,yOutSize);
outWS = WorkspaceFactory::Instance().create(inWS,1,xOutSize,yOutSize);
gsl_fft_real_workspace * workspace = gsl_fft_real_workspace_alloc(yOutSize);
boost::shared_array<double> data(new double[yOutSize]);
......@@ -160,6 +162,7 @@ void RealFFT::exec()
outWS->dataY(0)[i] = data[i]/df;
}
if (outWS->isHistogramData()) outWS->dataX(0)[yOutSize] = outWS->dataX(0)[yOutSize - 1] + df;
outWS->getAxis(1)->spectraNo(0)=inWS->getAxis(1)->spectraNo(spec);
}
outWS->getAxis(0)->unit() = boost::shared_ptr<Kernel::Unit>(new LabelUnit());
......
......@@ -7,7 +7,7 @@
#include <QDockWidget>
#include <QMap>
/* Forward definitions */
/* Forward declarations */
class QtTreePropertyBrowser;
class QtGroupPropertyManager;
......@@ -17,6 +17,7 @@ class QtBoolPropertyManager;
class QtStringPropertyManager;
class QtEnumPropertyManager;
class QtProperty;
class QtBrowserItem;
class ApplicationWindow;
......@@ -58,31 +59,39 @@ public:
void setWidth(double value);
/// Get count
int count()const;
/// Set count
void setCount();
/// Get index
int index()const;
/// Set index
void setIndex(int i);
/// Creates Composite Function
void setComposite(bool on=true);
void setIndex(int i)const;
/// Is the current function a peak?
bool isPeak()const;
/// Get the i-th function
Mantid::API::IFunction* function(int i)const;
/// Get the current function
Mantid::API::IFunction* function()const{return function(index());}
/// Get the i-th function if it is a peak
Mantid::API::IPeakFunction* peakFunction(int i)const;
/// Get the current function if it is a peak
Mantid::API::IPeakFunction* peakFunction()const{return peakFunction(index());}
/// Select a function
void FitPropertyBrowser::selectFunction(int i)const;
/// Create a new function
void addFunction(const std::string& fnName);
/// Replace function
void replaceFunction(const std::string& fnName);
void replaceFunction(int i,const std::string& fnName);
/// Remove function
void removeFunction();
/// Set the current function
void setFunction(Mantid::API::IFunction* fun);
void removeFunction(int i);
/// Get Composite Function
boost::shared_ptr<Mantid::API::CompositeFunction> compositeFunction()const{return m_compositeFunction;}
/// Get the current function type
std::string functionType(int i)const;
std::string functionType()const{return functionType(index());}
/// Get the current function name
std::string functionName()const;
QString functionName(int i)const;
QString functionName()const{return functionName(index());}
/// Get the default function name
std::string defaultFunctionName()const;
std::string defaultFunctionType()const;
/// Get the input workspace name
std::string workspaceName()const;
......@@ -110,7 +119,7 @@ public:
void reinit();
signals:
void indexChanged(int i);
void indexChanged(int i)const;
void functionRemoved(int i);
void algorithmFinished(const QString&);
void workspaceIndexChanged(int i);
......@@ -128,29 +137,26 @@ private slots:
void fit();
void workspace_added(const QString &, Mantid::API::Workspace_sptr);
void workspace_removed(const QString &);
void currentItemChanged(QtBrowserItem*);
void popupMenu(const QPoint &);
/* Context menu slots */
void addFunction();
void deleteFunction();
private:
/// Is this function composite
bool isComposite()const;
/// Index of member function
int functionIndex()const;
/// Create CompositeFunction
void createCompositeFunction();
/// Remove CompositeFunction
void removeCompositeFunction();
/// Makes sure m_functionName property shows the right function name
void displayFunctionName();
/// Makes sure the parameters are displayed correctly
void displayParameters();
/// Makes sure the peak parameters (centre,height,width) are displayed correctly
void displayPeak();
/// Get and store available workspace names
void populateWorkspaceNames();
/// Get the registered function names
void populateFunctionNames();
/// Check if the workspace can be used in the fit
bool isWorkspaceValid(Mantid::API::Workspace_sptr)const;
/// Called when the fit is finished
void finishHandle(const Mantid::API::IAlgorithm* alg);
/// Find QtBrowserItem for a property prop among the chidren of
QtBrowserItem* findItem(QtBrowserItem* parent,QtProperty* prop)const;
QtTreePropertyBrowser* m_browser;
/// Property managers:
......@@ -161,18 +167,17 @@ private:
QtIntPropertyManager *m_intManager;
QtBoolPropertyManager *m_boolManager;
/// Properties:
QtProperty *m_functionGroup;
QtProperty *m_functionName;
QtProperty *m_peakGroup;
QtProperty *m_height;
QtProperty *m_centre;
QtProperty *m_width;
QtProperty *m_parametersGroup;
QMap<std::string,QtProperty*> m_parameters;
QtProperty *m_composite;
QtProperty *m_compositeGroup;
QtProperty *m_count;
QtProperty *m_index;
mutable int m_index;
/// The top level group
QtBrowserItem* m_fitGroup;
/// Group for functions
QtProperty* m_functionsGroup;
/// Group for input/output settings
QtProperty* m_settingsGroup;
/// Browser items for functions
QList<QtBrowserItem*> m_functionItems;
QtProperty *m_workspace;
QtProperty *m_workspaceIndex;
......@@ -186,7 +191,7 @@ private:
mutable QStringList m_workspaceNames;
/// A copy of the edited function
Mantid::API::IFunction* m_function;
//Mantid::API::IFunction* m_function;
boost::shared_ptr<Mantid::API::CompositeFunction> m_compositeFunction;
/// Default function name
......@@ -195,6 +200,9 @@ private:
/// Default width for added peaks
double m_default_width;
/// The current function index
int m_index_;
/// if true the output name will be guessed every time workspace name is changeed
bool m_guessOutputName;
......
......@@ -46,7 +46,6 @@ m_defaultPeakName("Gaussian")
}
}
}
fitBrowser()->setComposite();
fitBrowser()->setWorkspaceName(m_wsName);
fitBrowser()->setWorkspaceIndex(m_spec);
m_compositeFunction = fitBrowser()->compositeFunction();
......@@ -332,7 +331,7 @@ void PeakPickerTool::draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMa
void PeakPickerTool::addPeak(double c,double h)
{
std::string fnName = fitBrowser()->isPeak()?
fitBrowser()->functionName() : m_defaultPeakName;
fitBrowser()->defaultFunctionType() : m_defaultPeakName;
fitBrowser()->addFunction(fnName);
fitBrowser()->setCentre(c);
fitBrowser()->setHeight(h);
......
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