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
6b06d7fa
Commit
6b06d7fa
authored
4 years ago
by
Robert Applin
Browse files
Options
Downloads
Patches
Plain Diff
Refs #30686. Improve x limit templating.
parent
e56f99af
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qt/widgets/common/inc/MantidQtWidgets/Common/FitScriptGeneratorPresenter.h
+8
-10
8 additions, 10 deletions
.../inc/MantidQtWidgets/Common/FitScriptGeneratorPresenter.h
qt/widgets/common/src/FitScriptGeneratorPresenter.cpp
+30
-31
30 additions, 31 deletions
qt/widgets/common/src/FitScriptGeneratorPresenter.cpp
with
38 additions
and
41 deletions
qt/widgets/common/inc/MantidQtWidgets/Common/FitScriptGeneratorPresenter.h
+
8
−
10
View file @
6b06d7fa
...
@@ -84,9 +84,9 @@ private:
...
@@ -84,9 +84,9 @@ private:
WorkspaceIndex
workspaceIndex
,
double
startX
,
double
endX
);
WorkspaceIndex
workspaceIndex
,
double
startX
,
double
endX
);
void
updateStartX
(
std
::
string
const
&
workspaceName
,
void
updateStartX
(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
FitDomainIndex
domainIndex
);
WorkspaceIndex
workspaceIndex
,
double
startX
);
void
updateEndX
(
std
::
string
const
&
workspaceName
,
void
updateEndX
(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
FitDomainIndex
domainIndex
);
WorkspaceIndex
workspaceIndex
,
double
endX
);
void
updateParameterValue
(
std
::
string
const
&
workspaceName
,
void
updateParameterValue
(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
WorkspaceIndex
workspaceIndex
,
...
@@ -110,14 +110,8 @@ private:
...
@@ -110,14 +110,8 @@ private:
void
updateFunctionInViewFromModel
(
FitDomainIndex
domainIndex
);
void
updateFunctionInViewFromModel
(
FitDomainIndex
domainIndex
);
template
<
void
(
FitScriptGeneratorPresenter
::*
func
)(
template
<
typename
GetX
,
typename
UpdateX
>
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
void
updateXLimitForDomain
(
GetX
&&
getX
,
UpdateX
&&
updateX
);
FitDomainIndex
domainIndex
)>
void
updateXLimitForDomainInModel
();
template
<
void
(
FitScriptGeneratorPresenter
::*
func
)(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
FitDomainIndex
domainIndex
)>
void
updateXLimitForDomainInModel
(
FitDomainIndex
domainIndex
);
template
<
void
(
IFitScriptGeneratorModel
::*
func
)(
template
<
void
(
IFitScriptGeneratorModel
::*
func
)(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
...
@@ -132,6 +126,10 @@ private:
...
@@ -132,6 +126,10 @@ private:
template
<
typename
Function
,
typename
...
Args
>
template
<
typename
Function
,
typename
...
Args
>
void
updateFunctionComponent
(
Function
&&
func
,
Args
...
arguments
);
void
updateFunctionComponent
(
Function
&&
func
,
Args
...
arguments
);
template
<
typename
Function
,
typename
...
Args
>
void
invokeFunctionForDomain
(
FitDomainIndex
domainIndex
,
Function
&&
func
,
Args
...
arguments
);
[[
nodiscard
]]
std
::
vector
<
FitDomainIndex
>
getRowIndices
()
const
;
[[
nodiscard
]]
std
::
vector
<
FitDomainIndex
>
getRowIndices
()
const
;
std
::
tuple
<
std
::
string
,
std
::
string
>
convertFunctionIndexOfParameterTie
(
std
::
tuple
<
std
::
string
,
std
::
string
>
convertFunctionIndexOfParameterTie
(
...
...
This diff is collapsed.
Click to expand it.
qt/widgets/common/src/FitScriptGeneratorPresenter.cpp
+
30
−
31
View file @
6b06d7fa
...
@@ -147,11 +147,13 @@ void FitScriptGeneratorPresenter::handleSelectionChanged() {
...
@@ -147,11 +147,13 @@ void FitScriptGeneratorPresenter::handleSelectionChanged() {
}
}
void
FitScriptGeneratorPresenter
::
handleStartXChanged
()
{
void
FitScriptGeneratorPresenter
::
handleStartXChanged
()
{
updateXLimitForDomainInModel
<&
FitScriptGeneratorPresenter
::
updateStartX
>
();
updateXLimitForDomain
(
&
IFitScriptGeneratorView
::
startX
,
&
FitScriptGeneratorPresenter
::
updateStartX
);
}
}
void
FitScriptGeneratorPresenter
::
handleEndXChanged
()
{
void
FitScriptGeneratorPresenter
::
handleEndXChanged
()
{
updateXLimitForDomainInModel
<&
FitScriptGeneratorPresenter
::
updateEndX
>
();
updateXLimitForDomain
(
&
IFitScriptGeneratorView
::
endX
,
&
FitScriptGeneratorPresenter
::
updateEndX
);
}
}
void
FitScriptGeneratorPresenter
::
handleFunctionRemoved
(
void
FitScriptGeneratorPresenter
::
handleFunctionRemoved
(
...
@@ -246,11 +248,12 @@ void FitScriptGeneratorPresenter::setWorkspaces(
...
@@ -246,11 +248,12 @@ void FitScriptGeneratorPresenter::setWorkspaces(
void
FitScriptGeneratorPresenter
::
addWorkspaces
(
void
FitScriptGeneratorPresenter
::
addWorkspaces
(
std
::
vector
<
MatrixWorkspace_const_sptr
>
const
&
workspaces
,
std
::
vector
<
MatrixWorkspace_const_sptr
>
const
&
workspaces
,
std
::
vector
<
WorkspaceIndex
>
const
&
workspaceIndices
)
{
std
::
vector
<
WorkspaceIndex
>
const
&
workspaceIndices
)
{
for
(
auto
const
&
workspace
:
workspaces
)
for
(
auto
const
&
workspace
:
workspaces
)
{
for
(
auto
const
&
workspaceIndex
:
workspaceIndices
)
{
for
(
auto
const
&
workspaceIndex
:
workspaceIndices
)
{
auto
const
xData
=
workspace
->
x
(
workspaceIndex
.
value
);
auto
const
xData
=
workspace
->
x
(
workspaceIndex
.
value
);
addWorkspace
(
workspace
,
workspaceIndex
,
xData
.
front
(),
xData
.
back
());
addWorkspace
(
workspace
,
workspaceIndex
,
xData
.
front
(),
xData
.
back
());
}
}
}
checkForWarningMessages
();
checkForWarningMessages
();
}
}
...
@@ -286,9 +289,8 @@ void FitScriptGeneratorPresenter::addWorkspace(std::string const &workspaceName,
...
@@ -286,9 +289,8 @@ void FitScriptGeneratorPresenter::addWorkspace(std::string const &workspaceName,
void
FitScriptGeneratorPresenter
::
updateStartX
(
std
::
string
const
&
workspaceName
,
void
FitScriptGeneratorPresenter
::
updateStartX
(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
WorkspaceIndex
workspaceIndex
,
FitDomainIndex
domainIndex
)
{
double
startX
)
{
if
(
!
m_model
->
updateStartX
(
workspaceName
,
workspaceIndex
,
if
(
!
m_model
->
updateStartX
(
workspaceName
,
workspaceIndex
,
startX
))
{
m_view
->
startX
(
domainIndex
)))
{
m_view
->
resetSelection
();
m_view
->
resetSelection
();
m_view
->
displayWarning
(
"The StartX provided must be within the x limits of "
m_view
->
displayWarning
(
"The StartX provided must be within the x limits of "
"its workspace, and less than the EndX."
);
"its workspace, and less than the EndX."
);
...
@@ -297,9 +299,8 @@ void FitScriptGeneratorPresenter::updateStartX(std::string const &workspaceName,
...
@@ -297,9 +299,8 @@ void FitScriptGeneratorPresenter::updateStartX(std::string const &workspaceName,
void
FitScriptGeneratorPresenter
::
updateEndX
(
std
::
string
const
&
workspaceName
,
void
FitScriptGeneratorPresenter
::
updateEndX
(
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
WorkspaceIndex
workspaceIndex
,
FitDomainIndex
domainIndex
)
{
double
endX
)
{
if
(
!
m_model
->
updateEndX
(
workspaceName
,
workspaceIndex
,
if
(
!
m_model
->
updateEndX
(
workspaceName
,
workspaceIndex
,
endX
))
{
m_view
->
endX
(
domainIndex
)))
{
m_view
->
resetSelection
();
m_view
->
resetSelection
();
m_view
->
displayWarning
(
"The EndX provided must be within the x limits of "
m_view
->
displayWarning
(
"The EndX provided must be within the x limits of "
"its workspace, and greater than the StartX."
);
"its workspace, and greater than the StartX."
);
...
@@ -360,23 +361,15 @@ void FitScriptGeneratorPresenter::updateFunctionInViewFromModel(
...
@@ -360,23 +361,15 @@ void FitScriptGeneratorPresenter::updateFunctionInViewFromModel(
setGlobalParameters
(
m_model
->
getGlobalParameters
());
setGlobalParameters
(
m_model
->
getGlobalParameters
());
}
}
template
<
void
(
FitScriptGeneratorPresenter
::*
func
)(
template
<
typename
GetX
,
typename
UpdateX
>
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
void
FitScriptGeneratorPresenter
::
updateXLimitForDomain
(
GetX
&&
getX
,
FitDomainIndex
domainIndex
)>
UpdateX
&&
updateX
)
{
void
FitScriptGeneratorPresenter
::
updateXLimitForDomainInModel
()
{
if
(
m_view
->
hasLoadedData
())
{
if
(
m_view
->
hasLoadedData
())
auto
const
domainIndex
=
m_view
->
currentRow
();
updateXLimitForDomainInModel
<
func
>
(
m_view
->
currentRow
());
auto
const
newValue
=
}
std
::
invoke
(
std
::
forward
<
GetX
>
(
getX
),
m_view
,
domainIndex
);
invokeFunctionForDomain
(
domainIndex
,
updateX
,
newValue
);
template
<
void
(
FitScriptGeneratorPresenter
::*
func
)(
}
std
::
string
const
&
workspaceName
,
WorkspaceIndex
workspaceIndex
,
FitDomainIndex
domainIndex
)>
void
FitScriptGeneratorPresenter
::
updateXLimitForDomainInModel
(
FitDomainIndex
domainIndex
)
{
auto
const
workspaceName
=
m_view
->
workspaceName
(
domainIndex
);
auto
const
workspaceIndex
=
m_view
->
workspaceIndex
(
domainIndex
);
(
this
->*
func
)(
workspaceName
,
workspaceIndex
,
domainIndex
);
}
}
template
<
void
(
IFitScriptGeneratorModel
::*
func
)(
template
<
void
(
IFitScriptGeneratorModel
::*
func
)(
...
@@ -409,14 +402,20 @@ template <typename Function, typename... Args>
...
@@ -409,14 +402,20 @@ template <typename Function, typename... Args>
void
FitScriptGeneratorPresenter
::
updateFunctionComponent
(
Function
&&
func
,
void
FitScriptGeneratorPresenter
::
updateFunctionComponent
(
Function
&&
func
,
Args
...
arguments
)
{
Args
...
arguments
)
{
for
(
auto
const
&
rowIndex
:
getRowIndices
())
{
for
(
auto
const
&
rowIndex
:
getRowIndices
())
{
auto
const
workspaceName
=
m_view
->
workspaceName
(
rowIndex
);
invokeFunctionForDomain
(
rowIndex
,
func
,
arguments
...);
auto
const
workspaceIndex
=
m_view
->
workspaceIndex
(
rowIndex
);
std
::
invoke
(
std
::
forward
<
Function
>
(
func
),
this
,
workspaceName
,
workspaceIndex
,
arguments
...);
}
}
}
}
template
<
typename
Function
,
typename
...
Args
>
void
FitScriptGeneratorPresenter
::
invokeFunctionForDomain
(
FitDomainIndex
domainIndex
,
Function
&&
func
,
Args
...
arguments
)
{
auto
const
workspaceName
=
m_view
->
workspaceName
(
domainIndex
);
auto
const
workspaceIndex
=
m_view
->
workspaceIndex
(
domainIndex
);
std
::
invoke
(
std
::
forward
<
Function
>
(
func
),
this
,
workspaceName
,
workspaceIndex
,
arguments
...);
}
std
::
vector
<
FitDomainIndex
>
FitScriptGeneratorPresenter
::
getRowIndices
()
const
{
std
::
vector
<
FitDomainIndex
>
FitScriptGeneratorPresenter
::
getRowIndices
()
const
{
return
m_view
->
applyFunctionChangesToAll
()
?
m_view
->
allRows
()
return
m_view
->
applyFunctionChangesToAll
()
?
m_view
->
allRows
()
:
m_view
->
selectedRows
();
:
m_view
->
selectedRows
();
...
...
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