Commit ab842940 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #26726 made ALFView presenter and model clearer

parent 396c488b
......@@ -59,7 +59,7 @@ int ALFView_model::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> ALFView_model::isDataValid() {
std::map<std::string, bool> ALFView_model::isDataValid() {
Mantid::API::MatrixWorkspace_sptr ws =
Mantid::API::AnalysisDataService::Instance()
.retrieveWS<Mantid::API::MatrixWorkspace>(tmpName);
......@@ -75,8 +75,11 @@ std::pair<bool, bool> ALFView_model::isDataValid() {
if (unit == "dSpacing") {
isItDSpace = true;
}
std::map<std::string, bool> result = {
{"IsValidInstrument", isItALF},
{"IsItDSpace", isItDSpace}};
return std::make_pair(isItALF, isItDSpace);
return result;
}
/*
......
......@@ -6,6 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_
#include <map>
#include <string>
namespace MantidQt {
......@@ -15,7 +16,7 @@ class ALFView_model{
public:
void loadEmptyInstrument();
int loadData(const std::string &name);
std::pair<bool, bool> isDataValid();
std::map<std::string, bool> isDataValid();
void transformData();
void rename();
void remove();
......
......@@ -37,7 +37,7 @@ void ALFView_presenter::initLayout() {
void ALFView_presenter::loadAndAnalysis(const std::string &run) {
int runNumber = m_model->loadData(run);
auto bools = m_model->isDataValid();
if (bools.first) {
if (bools["IsValidInstrument"]) {
m_model->rename();
m_currentRun = runNumber;
} else {
......@@ -47,7 +47,7 @@ void ALFView_presenter::loadAndAnalysis(const std::string &run) {
if (m_view->getRunNumber() != m_currentRun) {
m_view->setRunQuietly(QString::number(m_currentRun));
}
if (bools.first && !bools.second) {
if (bools["IsValidInstrument"] && !bools["IsItDSpace"]) {
m_model->transformData();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment