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
fa9f36d5
Commit
fa9f36d5
authored
Sep 19, 2019
by
Anthony Lim
Browse files
refs #26726 abstracted model from ALFView
parent
4a5a6821
Changes
6
Hide whitespace changes
Inline
Side-by-side
qt/scientific_interfaces/Direct/ALFView.cpp
View file @
fa9f36d5
...
...
@@ -30,8 +30,8 @@ Mantid::Kernel::Logger g_log("ALFView");
ALFView
::
ALFView
(
QWidget
*
parent
)
:
UserSubWindow
(
parent
),
m_view
(
nullptr
),
m_presenter
(
nullptr
)
{
m_view
=
new
ALFView_view
(
this
);
//
m_model = new ALFView_model();
m_presenter
=
new
ALFView_presenter
(
m_view
);
m_model
=
new
ALFView_model
();
m_presenter
=
new
ALFView_presenter
(
m_view
,
m_model
);
}
void
ALFView
::
initLayout
()
{
...
...
qt/scientific_interfaces/Direct/ALFView.h
View file @
fa9f36d5
...
...
@@ -34,7 +34,7 @@ protected:
private:
ALFView_view
*
m_view
;
//
ALFView_model *m_model;
ALFView_model
*
m_model
;
ALFView_presenter
*
m_presenter
;
};
}
// customInterfaces
...
...
qt/scientific_interfaces/Direct/ALFView_model.cpp
View file @
fa9f36d5
...
...
@@ -26,9 +26,9 @@ const std::string wsName = "ALFData";
namespace
MantidQt
{
namespace
CustomInterfaces
{
namespace
Direct
{
void
loadEmptyInstrument
()
{
void
ALFView_model
::
loadEmptyInstrument
()
{
Mantid
::
API
::
IAlgorithm_sptr
alg
=
Mantid
::
API
::
AlgorithmManager
::
Instance
().
create
(
"LoadEmptyInstrument"
);
alg
->
initialize
();
...
...
@@ -42,7 +42,7 @@ void loadEmptyInstrument() {
* @param name:: string name for ALF data
* @return int:: the run number
*/
int
loadData
(
const
std
::
string
&
name
)
{
int
ALFView_model
::
loadData
(
const
std
::
string
&
name
)
{
Mantid
::
API
::
IAlgorithm_sptr
alg
=
Mantid
::
API
::
AlgorithmManager
::
Instance
().
create
(
"Load"
);
alg
->
initialize
();
...
...
@@ -59,7 +59,7 @@ int loadData(const std::string &name) {
* Loads data, normalise to current and then converts to d spacing
* @return pair<bool,bool>:: If the instrument is ALF, if it is d-spacing
*/
std
::
pair
<
bool
,
bool
>
isDataValid
()
{
std
::
pair
<
bool
,
bool
>
ALFView_model
::
isDataValid
()
{
Mantid
::
API
::
MatrixWorkspace_sptr
ws
=
Mantid
::
API
::
AnalysisDataService
::
Instance
()
.
retrieveWS
<
Mantid
::
API
::
MatrixWorkspace
>
(
tmpName
);
...
...
@@ -83,7 +83,7 @@ return std::make_pair(isItALF, isItDSpace);
* Transforms ALF data; normalise to current and then converts to d spacing
* If already d-space does nothing.
*/
void
transformData
()
{
void
ALFView_model
::
transformData
()
{
Mantid
::
API
::
IAlgorithm_sptr
normAlg
=
Mantid
::
API
::
AlgorithmManager
::
Instance
().
create
(
"NormaliseByCurrent"
);
normAlg
->
initialize
();
...
...
@@ -100,12 +100,14 @@ void transformData() {
dSpacingAlg
->
execute
();
}
void
rename
()
{
void
ALFView_model
::
rename
()
{
Mantid
::
API
::
AnalysisDataService
::
Instance
().
rename
(
tmpName
,
wsName
);
}
void
remove
()
{
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
tmpName
);
}
void
ALFView_model
::
remove
()
{
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
tmpName
);
}
int
currentRun
()
{
int
ALFView_model
::
currentRun
()
{
try
{
Mantid
::
API
::
MatrixWorkspace_sptr
ws
=
...
...
@@ -117,6 +119,5 @@ int currentRun() {
}
}
}
// namespace Direct
}
// namespace CustomInterfaces
}
// namespace MantidQt
qt/scientific_interfaces/Direct/ALFView_model.h
View file @
fa9f36d5
...
...
@@ -10,17 +10,18 @@
namespace
MantidQt
{
namespace
CustomInterfaces
{
namespace
Direct
{
void
loadEmptyInstrument
();
class
ALFView_model
{
public:
void
loadEmptyInstrument
();
int
loadData
(
const
std
::
string
&
name
);
std
::
pair
<
bool
,
bool
>
isDataValid
();
std
::
pair
<
bool
,
bool
>
isDataValid
();
void
transformData
();
void
rename
();
void
remove
();
int
currentRun
();
}
// namespace
Direct
}
// namespace
CustomInterfaces
}
;
// namespace
CustomInterfaces
}
// namespace
MantidQt
}
// namespace MantidQt
#endif
/* MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_ */
qt/scientific_interfaces/Direct/ALFView_presenter.cpp
View file @
fa9f36d5
...
...
@@ -13,9 +13,9 @@
namespace
MantidQt
{
namespace
CustomInterfaces
{
ALFView_presenter
::
ALFView_presenter
(
ALFView_view
*
view
)
:
m_view
(
view
),
m_currentRun
(
0
)
{
Direct
::
loadEmptyInstrument
();
ALFView_presenter
::
ALFView_presenter
(
ALFView_view
*
view
,
ALFView_model
*
model
)
:
m_view
(
view
),
m_model
(
model
),
m_currentRun
(
0
)
{
m_model
->
loadEmptyInstrument
();
}
void
ALFView_presenter
::
initLayout
()
{
...
...
@@ -25,27 +25,26 @@ void ALFView_presenter::initLayout() {
}
void
ALFView_presenter
::
loadAndAnalysis
(
const
std
::
string
&
run
)
{
int
runNumber
=
Direct
::
loadData
(
run
);
auto
bools
=
Direct
::
isDataValid
();
int
runNumber
=
m_model
->
loadData
(
run
);
auto
bools
=
m_model
->
isDataValid
();
if
(
bools
.
first
)
{
Direct
::
rename
();
m_model
->
rename
();
m_currentRun
=
runNumber
;
}
else
{
Direct
::
remove
();
m_model
->
remove
();
}
// if the displayed run number is out of sinc
int
das
=
m_view
->
getRunNumber
();
if
(
m_view
->
getRunNumber
()
!=
m_currentRun
)
{
m_view
->
setRunQuietly
(
QString
::
number
(
m_currentRun
));
}
if
(
bools
.
first
&&
!
bools
.
second
)
{
Direct
::
transformData
();
m_model
->
transformData
();
}
}
void
ALFView_presenter
::
loadRunNumber
()
{
int
newRun
=
m_view
->
getRunNumber
();
const
int
currentRunInADS
=
Direct
::
currentRun
();
const
int
currentRunInADS
=
m_model
->
currentRun
();
if
(
currentRunInADS
==
newRun
)
{
...
...
@@ -68,7 +67,7 @@ void ALFView_presenter::loadRunNumber() {
}
void
ALFView_presenter
::
loadBrowsedFile
(
const
std
::
string
fileName
)
{
Direct
::
loadData
(
fileName
);
m_model
->
loadData
(
fileName
);
loadAndAnalysis
(
fileName
);
}
...
...
qt/scientific_interfaces/Direct/ALFView_presenter.h
View file @
fa9f36d5
...
...
@@ -20,7 +20,7 @@ namespace MantidQt {
Q_OBJECT
public:
ALFView_presenter
(
ALFView_view
*
view
);
ALFView_presenter
(
ALFView_view
*
view
,
ALFView_model
*
model
);
~
ALFView_presenter
(){};
void
initLayout
();
...
...
@@ -31,7 +31,7 @@ private slots:
private:
void
loadAndAnalysis
(
const
std
::
string
&
run
);
ALFView_view
*
m_view
;
//
ALFView_model *m_model;
ALFView_model
*
m_model
;
int
m_currentRun
;
};
}
// customInterfaces
...
...
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