Newer
Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/ITableWorkspace_fwd.h"
#include "MantidQtWidgets/Common/IFunctionBrowser.h"
#include <boost/optional.hpp>
namespace Mantid {
namespace API {
class CompositeFunction;
class Workspace;
class ParameterTie;
namespace MantidQt {
namespace MantidWidgets {
class FunctionTreeView;
class FunctionMultiDomainPresenter;
using namespace Mantid::API;
* Class FitPropertyBrowser implements QtPropertyBrowser to display
* and control fitting function parameters and settings.
*/
class EXPORT_OPT_MANTIDQT_COMMON FunctionBrowser : public QWidget,
public IFunctionBrowser {
FunctionBrowser(
QWidget *parent = nullptr, bool multi = false,
const std::vector<std::string> &categories = std::vector<std::string>());
void setFunction(IFunction_sptr fun);
/// Return FunctionFactory function string
IFunction_sptr getFunction();
/// Check if a function is set
bool hasFunction() const;
/// Return a function with specified index
IFunction_sptr getFunctionByIndex(const QString &index);
/// Return index of the current function, if one is selected
boost::optional<QString> currentFunctionIndex();
/// Update the function parameter value
void setParameter(const QString ¶mName, double value);
/// Update the function parameter error
void setParameterError(const QString ¶mName, double error);
double getParameter(const QString ¶mName) const;
/// Update parameter values in the browser to match those of a function.
void updateParameters(const IFunction &fun) override;
/// Get a list of names of global parameters
QStringList getGlobalParameters() const;
void setGlobalParameters(const QStringList &globals);
/// Get a list of names of local parameters
QStringList getLocalParameters() const;
/// Get the number of datasets
int getNumberOfDatasets() const override;
/// Get the names of datasets
QStringList getDatasetNames() const override;
/// Get value of a local parameter
double getLocalParameterValue(const QString &parName, int i) const override;
void setLocalParameterValue(const QString &parName, int i,
double value) override;
/// Set value and error of a local parameter
void setLocalParameterValue(const QString &parName, int i, double value,
double error);
/// Get error of a local parameter
double getLocalParameterError(const QString &parName, int i) const;
/// Check if a local parameter is fixed
bool isLocalParameterFixed(const QString &parName, int i) const override;
void setLocalParameterFixed(const QString &parName, int i,
bool fixed) override;
/// Get the tie for a local parameter.
QString getLocalParameterTie(const QString &parName, int i) const override;
/// Set a tie for a local parameter.
void setLocalParameterTie(const QString &parName, int i,
QString tie) override;
/// Return the multidomain function if number of datasets is greater than 1
IFunction_sptr getGlobalFunction() override;
/// Update parameter values in the browser to match those of a function.
void updateMultiDatasetParameters(const IFunction &fun) override;
/// Update parameter values in the browser to match those in a table
/// workspace.
void updateMultiDatasetParameters(const ITableWorkspace ¶mTable) override;
/// Get the index of the current dataset.
int getCurrentDataset() const override;
/// Resize the browser's columns
void setColumnSizes(int s0, int s1, int s2 = -1);
/// Set error display on/off
void setErrorsEnabled(bool enabled) override;
/// Clear all errors
void clearErrors() override;
/// Set a parameter that is responsible for the background level
void setBackgroundA0(double value);
// hide the global options
void hideGlobalCheckbox();
// show the global options
void showGlobalCheckbox();
void parameterChanged(const QString &funcIndex, const QString ¶mName);
/// User selects a different function (or one of it's sub-properties)
void currentFunctionChanged();
/// In multi-dataset context a button value editor was clicked
void localParameterButtonClicked(const QString &parName);
void globalsChanged();
void constraintsChanged();
void tiesChanged();
public slots:
// Handling of multiple datasets
void setNumberOfDatasets(int n) override;
void setDatasetNames(const QStringList &names) override;
void resetLocalParameters();
void setCurrentDataset(int i) override;
void removeDatasets(const QList<int> &indices);
void addDatasets(const QStringList &names);
std::unique_ptr<FunctionMultiDomainPresenter> m_presenter;
public:
// Intended for testing only
FunctionTreeView *view() const;
} // namespace MantidWidgets
} // namespace MantidQt