Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
ed6dc073
Commit
ed6dc073
authored
9 years ago
by
Elliot Oram
Browse files
Options
Downloads
Patches
Plain Diff
Range bars added/removed as require for each fit
Refs #12669
parent
a415b468
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp
+47
-91
47 additions, 91 deletions
...Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp
with
47 additions
and
91 deletions
Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp
+
47
−
91
View file @
ed6dc073
...
@@ -475,42 +475,30 @@ std::string createParName(size_t index, size_t subIndex,
...
@@ -475,42 +475,30 @@ std::string createParName(size_t index, size_t subIndex,
*
*
* Composite
* Composite
* |
* |
* +-
-
LinearBackground
* +- LinearBackground
* +-
-
Convolution
* +- Convolution
* |
* |
* +-
-
Resolution
* +- Resolution
* +-
-
Model (AT LEAST one delta function or one/two lorentzians.)
* +- Model (AT LEAST one delta function or one/two lorentzians.)
* |
* |
* +-- DeltaFunction (yes/no)
* +- DeltaFunction(yes/no)
* +-- ProductFunction
* +- ProductFunction
* |
* |
* +-- Lorentzian 1
* +- Lorentzian 1(yes/no)
*(yes/no)
* +- Temperature Correction(yes/no)
* +-- Temperature
* +- ProductFunction
*Correction
* |
*(yes/no)
* +- Lorentzian 2(yes/no)
* +-- ProductFunction
* +- Temperature Correction(yes/no)
* |
* +- ProductFunction
* +-- Lorentzian 2
* |
*(yes/no)
* +- InelasticDiffSphere(yes/no)
* +-- Temperature
* +- Temperature Correction(yes/no)
*Correction
* +- ProductFunction
*(yes/no)
* |
* +-- ProductFunction
* +-
* |
*InelasticDiffRotDiscreteCircle(yes/no)
* +-- InelasticDiffSphere
* +- Temperature Correction(yes/no)
*(yes/no)
* +-- Temperature
*Correction
*(yes/no)
* +-- ProductFunction
* |
* +--
*InelasticDiffRotDiscreteCircle
*(yes/no)
* +-- Temperature
*Correction
*(yes/no)
*
*
* @param tieCentres :: whether to tie centres of the two lorentzians.
* @param tieCentres :: whether to tie centres of the two lorentzians.
*
*
...
@@ -530,9 +518,8 @@ CompositeFunction_sptr ConvFit::createFunction(bool tieCentres) {
...
@@ -530,9 +518,8 @@ CompositeFunction_sptr ConvFit::createFunction(bool tieCentres) {
func
=
FunctionFactory
::
Instance
().
createFunction
(
"LinearBackground"
);
func
=
FunctionFactory
::
Instance
().
createFunction
(
"LinearBackground"
);
comp
->
addFunction
(
func
);
comp
->
addFunction
(
func
);
const
int
bgType
=
// 0 = Fixed Flat, 1 = Fit Flat, 2 = Fit all
m_uiForm
.
cbBackground
const
int
bgType
=
m_uiForm
.
cbBackground
->
currentIndex
();
->
currentIndex
();
// 0 = Fixed Flat, 1 = Fit Flat, 2 = Fit all
if
(
bgType
==
0
||
!
m_properties
[
"BGA0"
]
->
subProperties
().
isEmpty
())
{
if
(
bgType
==
0
||
!
m_properties
[
"BGA0"
]
->
subProperties
().
isEmpty
())
{
comp
->
tie
(
"f0.A0"
,
m_properties
[
"BGA0"
]
->
valueText
().
toStdString
());
comp
->
tie
(
"f0.A0"
,
m_properties
[
"BGA0"
]
->
valueText
().
toStdString
());
...
@@ -668,8 +655,7 @@ CompositeFunction_sptr ConvFit::createFunction(bool tieCentres) {
...
@@ -668,8 +655,7 @@ CompositeFunction_sptr ConvFit::createFunction(bool tieCentres) {
subIndex
=
product
->
addFunction
(
func
);
subIndex
=
product
->
addFunction
(
func
);
index
=
model
->
addFunction
(
product
);
index
=
model
->
addFunction
(
product
);
prefix2
=
createParName
(
index
,
subIndex
);
prefix2
=
createParName
(
index
,
subIndex
);
populateFunction
(
func
,
model
,
m_properties
[
"FitFunction1"
],
populateFunction
(
func
,
model
,
m_properties
[
"FitFunction1"
],
prefix2
,
false
);
prefix2
,
false
);
}
}
conv
->
addFunction
(
model
);
conv
->
addFunction
(
model
);
...
@@ -799,7 +785,6 @@ QtProperty *ConvFit::createLorentzian(const QString &name) {
...
@@ -799,7 +785,6 @@ QtProperty *ConvFit::createLorentzian(const QString &name) {
return
lorentzGroup
;
return
lorentzGroup
;
}
}
/**
/**
* Populates the properties of a function with given values
* Populates the properties of a function with given values
* @param func The function currently being added to the composite
* @param func The function currently being added to the composite
...
@@ -928,6 +913,19 @@ QString ConvFit::minimizerString(QString outputName) const {
...
@@ -928,6 +913,19 @@ QString ConvFit::minimizerString(QString outputName) const {
* @param index A reference to the Fit Type (0-4)
* @param index A reference to the Fit Type (0-4)
*/
*/
void
ConvFit
::
typeSelection
(
int
index
)
{
void
ConvFit
::
typeSelection
(
int
index
)
{
auto
hwhmRangeSelector
=
m_uiForm
.
ppPlot
->
getRangeSelector
(
"ConvFitHWHM"
);
if
(
index
==
0
){
hwhmRangeSelector
->
setVisible
(
false
);
}
else
if
(
index
<
3
){
hwhmRangeSelector
->
setVisible
(
true
);
}
else
{
hwhmRangeSelector
->
setVisible
(
false
);
m_uiForm
.
ckPlotGuess
->
setChecked
(
false
);
m_blnManager
->
setValue
(
m_properties
[
"UseDeltaFunc"
],
false
);
}
// Disable Plot Guess and Use Delta Function for DiffSphere and
// DiffRotDiscreteCircle
m_uiForm
.
ckPlotGuess
->
setEnabled
(
index
<
3
);
m_uiForm
.
ckPlotGuess
->
setEnabled
(
index
<
3
);
m_properties
[
"UseDeltaFunc"
]
->
setEnabled
(
index
<
3
);
m_properties
[
"UseDeltaFunc"
]
->
setEnabled
(
index
<
3
);
}
}
...
@@ -1203,9 +1201,9 @@ void ConvFit::singleFitComplete(bool error) {
...
@@ -1203,9 +1201,9 @@ void ConvFit::singleFitComplete(bool error) {
for
(
auto
it
=
params
.
begin
();
it
!=
params
.
end
();
++
it
)
{
for
(
auto
it
=
params
.
begin
();
it
!=
params
.
end
();
++
it
)
{
QString
functionParam
=
functionName
+
"."
+
*
it
;
QString
functionParam
=
functionName
+
"."
+
*
it
;
std
::
string
fp
=
functionParam
.
toStdString
();
std
::
string
fp
=
functionParam
.
toStdString
();
QString
paramValue
=
pref
+
*
it
;
QString
paramValue
=
pref
+
*
it
;
std
::
string
pv
=
paramValue
.
toStdString
();
std
::
string
pv
=
paramValue
.
toStdString
();
m_dblManager
->
setValue
(
m_properties
[
functionParam
],
parameters
[
paramValue
]);
m_dblManager
->
setValue
(
m_properties
[
functionParam
],
parameters
[
paramValue
]);
}
}
funcIndex
++
;
funcIndex
++
;
...
@@ -1224,49 +1222,6 @@ void ConvFit::singleFitComplete(bool error) {
...
@@ -1224,49 +1222,6 @@ void ConvFit::singleFitComplete(bool error) {
parameters
[
paramValue
]);
parameters
[
paramValue
]);
}
}
}
}
/*
if (fitTypeIndex == 3) {
// DiffSphere
QString pref = prefBase;
if (usingCompositeFunc) {
pref += "f" + QString::number(funcIndex) + ".f" +
QString::number(subIndex) + ".";
} else {
pref += "f" + QString::number(subIndex) + ".";
}
m_dblManager->setValue(m_properties["Diffusion Sphere.Intensity"],
parameters[pref + "Intensity"]);
m_dblManager->setValue(m_properties["Diffusion Sphere.Radius"],
parameters[pref + "Radius"]);
m_dblManager->setValue(m_properties["Diffusion Sphere.Diffusion"],
parameters[pref + "Diffusion"]);
m_dblManager->setValue(m_properties["Diffusion Sphere.Shift"],
parameters[pref + "Shift"]);
}
if (fitTypeIndex == 4) {
// DiffSphere
QString pref = prefBase;
if (usingCompositeFunc) {
pref += "f" + QString::number(funcIndex) + ".f" +
QString::number(subIndex) + ".";
} else {
pref += "f" + QString::number(subIndex) + ".";
}
m_dblManager->setValue(m_properties["Diffusion Circle.Intensity"],
parameters[pref + "Intensity"]);
m_dblManager->setValue(m_properties["Diffusion Circle.Radius"],
parameters[pref + "Radius"]);
m_dblManager->setValue(m_properties["Diffusion Circle.Decay"],
parameters[pref + "Decay"]);
m_dblManager->setValue(m_properties["Diffusion Circle.Shift"],
parameters[pref + "Shift"]);
}
*/
m_pythonExportWsName
=
""
;
m_pythonExportWsName
=
""
;
}
}
...
@@ -1455,7 +1410,8 @@ void ConvFit::showTieCheckbox(QString fitType) {
...
@@ -1455,7 +1410,8 @@ void ConvFit::showTieCheckbox(QString fitType) {
*/
*/
QStringList
ConvFit
::
getFunctionParameters
(
QString
functionName
)
{
QStringList
ConvFit
::
getFunctionParameters
(
QString
functionName
)
{
QStringList
parameters
;
QStringList
parameters
;
if
(
functionName
.
compare
(
"Two Lorentzians"
)
==
0
)
{
int
fitFunctionIndex
=
m_uiForm
.
cbFitType
->
currentIndex
();
if
(
fitFunctionIndex
==
2
)
{
functionName
=
"Lorentzian"
;
functionName
=
"Lorentzian"
;
IFunction_sptr
func
=
IFunction_sptr
func
=
FunctionFactory
::
Instance
().
createFunction
(
functionName
.
toStdString
());
FunctionFactory
::
Instance
().
createFunction
(
functionName
.
toStdString
());
...
@@ -1464,11 +1420,11 @@ QStringList ConvFit::getFunctionParameters(QString functionName) {
...
@@ -1464,11 +1420,11 @@ QStringList ConvFit::getFunctionParameters(QString functionName) {
parameters
<<
QString
::
fromStdString
(
func
->
parameterName
(
i
));
parameters
<<
QString
::
fromStdString
(
func
->
parameterName
(
i
));
}
}
}
}
if
(
function
Name
.
compare
(
"One Lorentzian"
)
==
0
)
{
if
(
f
itF
unction
Index
==
1
)
{
functionName
=
"Lorentzian"
;
functionName
=
"Lorentzian"
;
}
}
if
(
function
Name
.
compare
(
"Zero Lorentzians"
)
==
0
)
{
if
(
f
itF
unction
Index
==
0
)
{
parameters
.
append
(
"Zero"
);
parameters
.
append
(
"Zero"
);
}
else
{
}
else
{
IFunction_sptr
func
=
IFunction_sptr
func
=
...
@@ -1488,10 +1444,10 @@ QStringList ConvFit::getFunctionParameters(QString functionName) {
...
@@ -1488,10 +1444,10 @@ QStringList ConvFit::getFunctionParameters(QString functionName) {
*/
*/
void
ConvFit
::
fitFunctionSelected
(
const
QString
&
functionName
)
{
void
ConvFit
::
fitFunctionSelected
(
const
QString
&
functionName
)
{
removeTreeParams
();
removeTreeParams
();
int
fitFunctionIndex
=
m_uiForm
.
cbFitType
->
currentIndex
();
// Add new parameter elements
// Add new parameter elements
QStringList
parameters
=
getFunctionParameters
(
functionName
);
QStringList
parameters
=
getFunctionParameters
(
functionName
);
if
(
function
Name
.
compare
(
"Two Lorentzians"
)
==
0
)
{
if
(
f
itF
unction
Index
==
2
)
{
m_properties
[
"FitFunction1"
]
=
m_grpManager
->
addProperty
(
"Lorentzian 1"
);
m_properties
[
"FitFunction1"
]
=
m_grpManager
->
addProperty
(
"Lorentzian 1"
);
m_cfTree
->
addProperty
(
m_properties
[
"FitFunction1"
]);
m_cfTree
->
addProperty
(
m_properties
[
"FitFunction1"
]);
m_properties
[
"FitFunction2"
]
=
m_grpManager
->
addProperty
(
"Lorentzian 2"
);
m_properties
[
"FitFunction2"
]
=
m_grpManager
->
addProperty
(
"Lorentzian 2"
);
...
@@ -1503,7 +1459,7 @@ void ConvFit::fitFunctionSelected(const QString &functionName) {
...
@@ -1503,7 +1459,7 @@ void ConvFit::fitFunctionSelected(const QString &functionName) {
// No fit function parameters required for Zero
// No fit function parameters required for Zero
if
(
parameters
[
0
].
compare
(
"Zero"
)
!=
0
)
{
if
(
parameters
[
0
].
compare
(
"Zero"
)
!=
0
)
{
if
(
function
Name
.
compare
(
"Two Lorentzians"
)
==
0
)
{
if
(
f
itF
unction
Index
==
2
)
{
int
count
=
0
;
int
count
=
0
;
for
(
auto
it
=
parameters
.
begin
();
it
!=
parameters
.
end
();
++
it
)
{
for
(
auto
it
=
parameters
.
begin
();
it
!=
parameters
.
end
();
++
it
)
{
QString
name
=
"parameter_"
+
*
it
;
QString
name
=
"parameter_"
+
*
it
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment