Newer
Older
#include "MantidQtCustomInterfaces/Indirect/ConvFit.h"
#include "MantidQtCustomInterfaces/UserInputValidator.h"
#include "MantidQtMantidWidgets/RangeSelector.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/FunctionDomain1D.h"
#include "MantidAPI/FunctionFactory.h"
#include <QFileInfo>
#include <QMenu>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
namespace {
Mantid::Kernel::Logger g_log("ConvFit");
namespace MantidQt {
namespace CustomInterfaces {
namespace IDA {
ConvFit::ConvFit(QWidget *parent)
: IndirectDataAnalysisTab(parent), m_stringManager(NULL), m_cfTree(NULL),
m_fixedProps(), m_cfInputWS(), m_cfInputWSName(), m_confitResFileType() {
m_uiForm.setupUi(parent);
}
void ConvFit::setup() {
// Create Property Managers
m_stringManager = new QtStringPropertyManager();
// Initialise fitTypeStrings
m_fitStrings = QStringList() << ""
<< "1L"
<< "2L"
<< "IDS"
<< "IDC"
<< "EDS"
<< "EDC"
<< "SFT";
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Create TreeProperty Widget
m_cfTree = new QtTreePropertyBrowser();
m_uiForm.properties->addWidget(m_cfTree);
// add factories to managers
m_cfTree->setFactoryForManager(m_blnManager, m_blnEdFac);
m_cfTree->setFactoryForManager(m_dblManager, m_dblEdFac);
// Create Range Selectors
auto fitRangeSelector = m_uiForm.ppPlot->addRangeSelector("ConvFitRange");
auto backRangeSelector = m_uiForm.ppPlot->addRangeSelector(
"ConvFitBackRange", MantidWidgets::RangeSelector::YSINGLE);
auto hwhmRangeSelector = m_uiForm.ppPlot->addRangeSelector("ConvFitHWHM");
backRangeSelector->setColour(Qt::darkGreen);
backRangeSelector->setRange(0.0, 1.0);
hwhmRangeSelector->setColour(Qt::red);
// Populate Property Widget
// Option to convolve members
m_properties["Convolve"] = m_blnManager->addProperty("Convolve");
m_cfTree->addProperty(m_properties["Convolve"]);
m_blnManager->setValue(m_properties["Convolve"], true);
// Max iterations option
m_properties["MaxIterations"] = m_dblManager->addProperty("Max Iterations");
m_dblManager->setDecimals(m_properties["MaxIterations"], 0);
m_dblManager->setValue(m_properties["MaxIterations"], 500);
m_cfTree->addProperty(m_properties["MaxIterations"]);
// Fitting range
m_properties["FitRange"] = m_grpManager->addProperty("Fitting Range");
m_properties["StartX"] = m_dblManager->addProperty("StartX");
m_dblManager->setDecimals(m_properties["StartX"], NUM_DECIMALS);
m_properties["EndX"] = m_dblManager->addProperty("EndX");
m_dblManager->setDecimals(m_properties["EndX"], NUM_DECIMALS);
m_properties["FitRange"]->addSubProperty(m_properties["StartX"]);
m_properties["FitRange"]->addSubProperty(m_properties["EndX"]);
m_cfTree->addProperty(m_properties["FitRange"]);
// FABADA
m_properties["FABADA"] = m_grpManager->addProperty("Bayesian");
m_properties["UseFABADA"] = m_blnManager->addProperty("Use FABADA");
m_properties["FABADA"]->addSubProperty(m_properties["UseFABADA"]);
m_properties["OutputFABADAChain"] = m_blnManager->addProperty("Output Chain");
m_properties["FABADAChainLength"] = m_dblManager->addProperty("Chain Length");
m_dblManager->setDecimals(m_properties["FABADAChainLength"], 0);
m_dblManager->setValue(m_properties["FABADAChainLength"], 10000);
m_properties["FABADAConvergenceCriteria"] =
m_dblManager->addProperty("Convergence Criteria");
m_dblManager->setValue(m_properties["FABADAConvergenceCriteria"], 0.1);
m_properties["FABADAJumpAcceptanceRate"] =
m_dblManager->addProperty("Acceptance Rate");
m_dblManager->setValue(m_properties["FABADAJumpAcceptanceRate"], 0.25);
m_cfTree->addProperty(m_properties["FABADA"]);
// Background type
m_properties["LinearBackground"] = m_grpManager->addProperty("Background");
m_properties["BGA0"] = m_dblManager->addProperty("A0");
m_dblManager->setDecimals(m_properties["BGA0"], NUM_DECIMALS);
m_properties["BGA1"] = m_dblManager->addProperty("A1");
m_dblManager->setDecimals(m_properties["BGA1"], NUM_DECIMALS);
m_properties["LinearBackground"]->addSubProperty(m_properties["BGA0"]);
m_properties["LinearBackground"]->addSubProperty(m_properties["BGA1"]);
m_cfTree->addProperty(m_properties["LinearBackground"]);
// Delta Function
m_properties["DeltaFunction"] = m_grpManager->addProperty("Delta Function");
m_properties["UseDeltaFunc"] = m_blnManager->addProperty("Use");
m_properties["DeltaHeight"] = m_dblManager->addProperty("Height");
m_dblManager->setDecimals(m_properties["DeltaHeight"], NUM_DECIMALS);
m_properties["DeltaFunction"]->addSubProperty(m_properties["UseDeltaFunc"]);
m_cfTree->addProperty(m_properties["DeltaFunction"]);
// Fit functions
m_properties["Lorentzian1"] = createFitType("Lorentzian 1");
m_properties["Lorentzian2"] = createFitType("Lorentzian 2");
m_properties["DiffSphere"] = createFitType("DiffSphere");
m_properties["DiffRotDiscreteCircle"] =
createFitType("DiffRotDiscreteCircle");
m_properties["ElasticDiffSphere"] = createFitType("ElasticDiffSphere");
m_properties["ElasticDiffRotDiscreteCircle"] =
createFitType("ElasticDiffRotDiscreteCircle");
m_properties["InelasticDiffSphere"] = createFitType("InelasticDiffSphere");
m_properties["InelasticDiffRotDiscreteCircle"] =
createFitType("InelasticDiffRotDiscreteCircle");
m_properties["StretchedExpFT"] = createFitType("StretchedExpFT");
// Update fit parameters in browser when function is selected
connect(m_uiForm.cbFitType, SIGNAL(currentIndexChanged(QString)), this,
SLOT(fitFunctionSelected(const QString &)));
fitFunctionSelected(m_uiForm.cbFitType->currentText());
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
m_uiForm.leTempCorrection->setValidator(new QDoubleValidator(m_parentWidget));
// Connections
connect(fitRangeSelector, SIGNAL(minValueChanged(double)), this,
SLOT(minChanged(double)));
connect(fitRangeSelector, SIGNAL(maxValueChanged(double)), this,
SLOT(maxChanged(double)));
connect(backRangeSelector, SIGNAL(minValueChanged(double)), this,
SLOT(backgLevel(double)));
connect(hwhmRangeSelector, SIGNAL(minValueChanged(double)), this,
SLOT(hwhmChanged(double)));
connect(hwhmRangeSelector, SIGNAL(maxValueChanged(double)), this,
SLOT(hwhmChanged(double)));
connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this,
SLOT(updateRS(QtProperty *, double)));
connect(m_blnManager, SIGNAL(valueChanged(QtProperty *, bool)), this,
SLOT(checkBoxUpdate(QtProperty *, bool)));
connect(m_uiForm.ckTempCorrection, SIGNAL(toggled(bool)),
m_uiForm.leTempCorrection, SLOT(setEnabled(bool)));
// Update guess curve when certain things happen
connect(m_dblManager, SIGNAL(propertyChanged(QtProperty *)), this,
SLOT(plotGuess()));
connect(m_uiForm.cbFitType, SIGNAL(currentIndexChanged(int)), this,
SLOT(plotGuess()));
connect(m_uiForm.ckPlotGuess, SIGNAL(stateChanged(int)), this,
SLOT(plotGuess()));
// Have FWHM Range linked to Fit Start/End Range
connect(fitRangeSelector, SIGNAL(rangeChanged(double, double)),
hwhmRangeSelector, SLOT(setRange(double, double)));
hwhmRangeSelector->setRange(-1.0, 1.0);
hwhmUpdateRS(0.02);
typeSelection(m_uiForm.cbFitType->currentIndex());
bgTypeSelection(m_uiForm.cbBackground->currentIndex());
// Replot input automatically when file / spec no changes
connect(m_uiForm.spPlotSpectrum, SIGNAL(valueChanged(int)), this,
SLOT(updatePlot()));
connect(m_uiForm.dsSampleInput, SIGNAL(dataReady(const QString &)), this,
SLOT(newDataLoaded(const QString &)));
connect(m_uiForm.dsSampleInput, SIGNAL(dataReady(const QString &)), this,
SLOT(extendResolutionWorkspace()));
connect(m_uiForm.dsResInput, SIGNAL(dataReady(const QString &)), this,
SLOT(extendResolutionWorkspace()));
connect(m_uiForm.spSpectraMin, SIGNAL(valueChanged(int)), this,
SLOT(specMinChanged(int)));
connect(m_uiForm.spSpectraMax, SIGNAL(valueChanged(int)), this,
SLOT(specMaxChanged(int)));
connect(m_uiForm.cbFitType, SIGNAL(currentIndexChanged(int)), this,
SLOT(typeSelection(int)));
connect(m_uiForm.cbBackground, SIGNAL(currentIndexChanged(int)), this,
SLOT(bgTypeSelection(int)));
connect(m_uiForm.pbSingleFit, SIGNAL(clicked()), this, SLOT(singleFit()));
// Context menu
Loading
Loading full blame...