Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
ac03705f
Commit
ac03705f
authored
Oct 04, 2019
by
Anthony Lim
Browse files
refs #26726 ALFView move stuff to model
parent
d09c1482
Changes
5
Hide whitespace changes
Inline
Side-by-side
qt/scientific_interfaces/Direct/ALFView.h
View file @
ac03705f
...
...
@@ -33,9 +33,6 @@ protected:
void
initLayout
()
override
;
private:
// std::unique_ptr<ALFView_view> m_view;
// std::unique_ptr<ALFView_model> m_model;
// std::unique_ptr<ALFView_presenter> m_presenter;
ALFView_view
*
m_view
;
ALFView_model
*
m_model
;
ALFView_presenter
*
m_presenter
;
...
...
qt/scientific_interfaces/Direct/ALFView_model.cpp
View file @
ac03705f
...
...
@@ -41,9 +41,9 @@ void ALFView_model::loadEmptyInstrument() {
* Loads data for use in ALFView
* Loads data, normalise to current and then converts to d spacing
* @param name:: string name for ALF data
* @return
int
:: the run number
* @return
std::pair<int,std::string>
:: the run number
and status
*/
int
ALFView_model
::
loadData
(
const
std
::
string
&
name
)
{
std
::
pair
<
int
,
std
::
string
>
ALFView_model
::
loadData
(
const
std
::
string
&
name
)
{
auto
alg
=
AlgorithmManager
::
Instance
().
create
(
"Load"
);
alg
->
initialize
();
alg
->
setProperty
(
"Filename"
,
name
);
...
...
@@ -51,7 +51,23 @@ int ALFView_model::loadData(const std::string &name) {
alg
->
execute
();
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
TMPNAME
);
return
ws
->
getRunNumber
();
int
runNumber
=
ws
->
getRunNumber
();
std
::
string
message
=
"success"
;
auto
bools
=
isDataValid
();
if
(
bools
[
"IsValidInstrument"
])
{
rename
();
}
else
{
// reset to the previous data
message
=
"Not the corrct instrument, expected "
+
INSTRUMENTNAME
;
remove
();
}
if
(
bools
[
"IsValidInstrument"
]
&&
!
bools
[
"IsItDSpace"
])
{
transformData
();
}
return
std
::
make_pair
(
runNumber
,
message
);
}
/*
* Checks loaded data is from ALF
...
...
@@ -61,7 +77,6 @@ int ALFView_model::loadData(const std::string &name) {
std
::
map
<
std
::
string
,
bool
>
ALFView_model
::
isDataValid
()
{
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
TMPNAME
);
bool
isItALF
=
false
;
bool
isItDSpace
=
false
;
...
...
@@ -73,10 +88,7 @@ std::map<std::string, bool> ALFView_model::isDataValid() {
if
(
unit
==
"dSpacing"
)
{
isItDSpace
=
true
;
}
std
::
map
<
std
::
string
,
bool
>
result
=
{{
"IsValidInstrument"
,
isItALF
},
{
"IsItDSpace"
,
isItDSpace
}};
return
result
;
return
{{
"IsValidInstrument"
,
isItALF
},
{
"IsItDSpace"
,
isItDSpace
}};
}
/*
...
...
qt/scientific_interfaces/Direct/ALFView_model.h
View file @
ac03705f
...
...
@@ -15,7 +15,7 @@ namespace CustomInterfaces {
class
ALFView_model
{
public:
void
loadEmptyInstrument
();
int
loadData
(
const
std
::
string
&
name
);
std
::
pair
<
int
,
std
::
string
>
loadData
(
const
std
::
string
&
name
);
std
::
map
<
std
::
string
,
bool
>
isDataValid
();
void
transformData
();
void
rename
();
...
...
qt/scientific_interfaces/Direct/ALFView_presenter.cpp
View file @
ac03705f
...
...
@@ -32,26 +32,17 @@ void ALFView_presenter::initLayout() {
void
ALFView_presenter
::
loadAndAnalysis
(
const
std
::
string
&
pathToRun
)
{
try
{
int
runNumber
=
m_model
->
loadData
(
pathToRun
);
auto
bools
=
m_model
->
isDataValid
();
if
(
bools
[
"IsValidInstrument"
])
{
m_model
->
rename
();
m_currentRun
=
runNumber
;
auto
loadedResult
=
m_model
->
loadData
(
pathToRun
);
if
(
loadedResult
.
second
==
"success"
)
{
m_currentRun
=
loadedResult
.
first
;
m_currentFile
=
pathToRun
;
}
else
{
// reset to the previous data
std
::
string
message
=
"Not the corrct instrument, expected "
+
m_model
->
getInstrument
();
m_view
->
warningBox
(
message
);
m_model
->
remove
();
m_view
->
warningBox
(
loadedResult
.
second
);
}
// make displayed run number be in sinc
m_view
->
setRunQuietly
(
std
::
to_string
(
m_currentRun
));
if
(
bools
[
"IsValidInstrument"
]
&&
!
bools
[
"IsItDSpace"
])
{
m_model
->
transformData
();
}
}
catch
(...)
{
m_view
->
setRunQuietly
(
std
::
to_string
(
m_currentRun
));
}
...
...
qt/scientific_interfaces/Direct/ALFView_presenter.h
View file @
ac03705f
...
...
@@ -23,7 +23,7 @@ class MANTIDQT_DIRECT_DLL ALFView_presenter : public QObject {
public:
ALFView_presenter
(
ALFView_view
*
view
,
ALFView_model
*
model
);
~
ALFView_presenter
()
{
};
~
ALFView_presenter
()
{
delete
m_loadRunObserver
;
};
void
initLayout
();
private
slots
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment