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

refs #26904 rename ALFView_* to more sensible names

parent d13457cc
......@@ -5,7 +5,7 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "ALFView_model.h"
#include "ALFCustomInstrumentModel.h"
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"
......@@ -25,7 +25,7 @@ using namespace Mantid::API;
namespace MantidQt {
namespace CustomInterfaces {
ALFView_model::ALFView_model() : m_numberOfTubesInAverage(0) {
ALFCustomInstrumentModel::ALFCustomInstrumentModel() : m_numberOfTubesInAverage(0) {
m_tmpName = "ALF_tmp";
m_instrumentName = "ALF";
m_wsName = "ALFData";
......@@ -38,7 +38,7 @@ ALFView_model::ALFView_model() : m_numberOfTubesInAverage(0) {
* @param name:: string name for ALF data
* @return std::pair<int,std::string>:: the run number and status
*/
std::pair<int, std::string> ALFView_model::loadData(const std::string &name) {
std::pair<int, std::string> ALFCustomInstrumentModel::loadData(const std::string &name) {
auto alg = AlgorithmManager::Instance().create("Load");
alg->initialize();
alg->setProperty("Filename", name);
......@@ -67,7 +67,7 @@ std::pair<int, std::string> 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::map<std::string, bool> ALFView_model::isDataValid() {
std::map<std::string, bool> ALFCustomInstrumentModel::isDataValid() {
auto ws =
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(m_tmpName);
bool isItALF = false;
......@@ -88,7 +88,7 @@ std::map<std::string, bool> ALFView_model::isDataValid() {
* Transforms ALF data; normalise to current and then converts to d spacing
* If already d-space does nothing.
*/
void ALFView_model::transformData() {
void ALFCustomInstrumentModel::transformData() {
auto normAlg = AlgorithmManager::Instance().create("NormaliseByCurrent");
normAlg->initialize();
normAlg->setProperty("InputWorkspace", m_wsName);
......@@ -103,7 +103,7 @@ void ALFView_model::transformData() {
dSpacingAlg->execute();
}
void ALFView_model::storeSingleTube(const std::string &name) {
void ALFCustomInstrumentModel::storeSingleTube(const std::string &name) {
auto alg = AlgorithmManager::Instance().create("ScaleX");
alg->initialize();
alg->setProperty("InputWorkspace", CURVES);
......@@ -120,12 +120,12 @@ void ALFView_model::storeSingleTube(const std::string &name) {
AnalysisDataService::Instance().remove(CURVES);
}
std::string ALFView_model::WSName() {
std::string ALFCustomInstrumentModel::WSName() {
std::string name = m_instrumentName + std::to_string(getCurrentRun());
return EXTRACTEDWS + name;
}
void ALFView_model::averageTube() {
void ALFCustomInstrumentModel::averageTube() {
const std::string name = m_instrumentName + std::to_string(getCurrentRun());
const int oldTotalNumber = m_numberOfTubesInAverage;
// multiply up current average
......@@ -158,11 +158,11 @@ void ALFView_model::averageTube() {
m_numberOfTubesInAverage++;
}
bool ALFView_model::hasTubeBeenExtracted(const std::string &name) {
bool ALFCustomInstrumentModel::hasTubeBeenExtracted(const std::string &name) {
return AnalysisDataService::Instance().doesExist(EXTRACTEDWS + name);
}
bool ALFView_model::extractTubeConditon(std::map<std::string, bool> tabBools) {
bool ALFCustomInstrumentModel::extractTubeConditon(std::map<std::string, bool> tabBools) {
try {
bool ifCurve = (tabBools.find("plotStored")->second ||
......@@ -173,7 +173,7 @@ bool ALFView_model::extractTubeConditon(std::map<std::string, bool> tabBools) {
}
}
bool ALFView_model::averageTubeConditon(std::map<std::string, bool> tabBools) {
bool ALFCustomInstrumentModel::averageTubeConditon(std::map<std::string, bool> tabBools) {
try {
bool ifCurve = (tabBools.find("plotStored")->second ||
......@@ -186,12 +186,12 @@ bool ALFView_model::averageTubeConditon(std::map<std::string, bool> tabBools) {
return false;
}
}
void ALFView_model::extractSingleTube() {
void ALFCustomInstrumentModel::extractSingleTube() {
storeSingleTube(m_instrumentName + std::to_string(getCurrentRun()));
m_numberOfTubesInAverage = 1;
}
CompositeFunction_sptr ALFView_model::getDefaultFunction() {
CompositeFunction_sptr ALFCustomInstrumentModel::getDefaultFunction() {
CompositeFunction_sptr composite =
boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(
......
......@@ -17,11 +17,11 @@
namespace MantidQt {
namespace CustomInterfaces {
class ALFView_model : public MantidWidgets::BaseCustomInstrumentModel {
class ALFCustomInstrumentModel : public MantidWidgets::BaseCustomInstrumentModel {
public:
ALFView_model();
virtual ~ALFView_model(){};
ALFCustomInstrumentModel();
virtual ~ALFCustomInstrumentModel(){};
std::pair<int, std::string> loadData(const std::string &name) override;
std::map<std::string, bool> isDataValid();
void transformData();
......
......@@ -4,9 +4,9 @@
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "ALFView_presenter.h"
#include "ALFView_model.h"
#include "ALFView_view.h"
#include "ALFCustomInstrumentPresenter.h"
#include "ALFCustomInstrumentModel.h"
#include "ALFCustomInstrumentView.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPanePresenter.h"
#include "MantidAPI/FileFinder.h"
......@@ -16,7 +16,7 @@
namespace MantidQt {
namespace CustomInterfaces {
ALFView_presenter::ALFView_presenter(ALFView_view *view, ALFView_model *model,
ALFCustomInstrumentPresenter::ALFCustomInstrumentPresenter(ALFCustomInstrumentView *view, ALFCustomInstrumentModel *model,
MantidWidgets::PlotFitAnalysisPanePresenter *analysisPane)
: BaseCustomInstrumentPresenter(view, model, analysisPane->getView()),
m_view(view), m_model(model), m_analysisPane(analysisPane),
......@@ -24,18 +24,18 @@ ALFView_presenter::ALFView_presenter(ALFView_view *view, ALFView_model *model,
addInstrument();
}
void ALFView_presenter::addInstrument() {
void ALFCustomInstrumentPresenter::addInstrument() {
auto setUp = setupALFInstrument();
initLayout(&setUp);
}
void ALFView_presenter::setUpInstrumentAnalysisSplitter() {
void ALFCustomInstrumentPresenter::setUpInstrumentAnalysisSplitter() {
CompositeFunction_sptr composite = m_model->getDefaultFunction();
m_analysisPane->addFunction(composite);
m_view->setupAnalysisPane(m_analysisPane->getView());
}
void ALFView_presenter::loadSideEffects() { m_analysisPane->clearCurrentWS(); }
void ALFCustomInstrumentPresenter::loadSideEffects() { m_analysisPane->clearCurrentWS(); }
typedef std::pair<std::string,
std::vector<std::function<bool(std::map<std::string, bool>)>>>
......@@ -49,7 +49,7 @@ typedef std::vector<std::tuple<std::string, Observer *>>
instrumentObserverOptions> : a pair of the conditions and observers
*/
std::pair<instrumentSetUp, instrumentObserverOptions>
ALFView_presenter::setupALFInstrument() {
ALFCustomInstrumentPresenter::setupALFInstrument() {
m_extractSingleTubeObserver = new VoidObserver();
m_averageTubeObserver = new VoidObserver();
......@@ -62,10 +62,10 @@ ALFView_presenter::setupALFInstrument() {
// set up custom context menu conditions
std::function<bool(std::map<std::string, bool>)> extractConditionBinder =
std::bind(&ALFView_model::extractTubeConditon, m_model,
std::bind(&ALFCustomInstrumentModel::extractTubeConditon, m_model,
std::placeholders::_1);
std::function<bool(std::map<std::string, bool>)> averageTubeConditonBinder =
std::bind(&ALFView_model::averageTubeConditon, m_model,
std::bind(&ALFCustomInstrumentModel::averageTubeConditon, m_model,
std::placeholders::_1);
binders.emplace_back(extractConditionBinder);
......@@ -75,7 +75,7 @@ ALFView_presenter::setupALFInstrument() {
// set up single tube extract
std::function<void()> extractSingleTubeBinder =
std::bind(&ALFView_presenter::extractSingleTube, this); // binder for slot
std::bind(&ALFCustomInstrumentPresenter::extractSingleTube, this); // binder for slot
m_extractSingleTubeObserver->setSlot(
extractSingleTubeBinder); // add slot to observer
std::tuple<std::string, Observer *> tmp = std::make_tuple(
......@@ -84,7 +84,7 @@ ALFView_presenter::setupALFInstrument() {
// set up average tube
std::function<void()> averageTubeBinder =
std::bind(&ALFView_presenter::averageTube, this);
std::bind(&ALFCustomInstrumentPresenter::averageTube, this);
m_averageTubeObserver->setSlot(averageTubeBinder);
tmp = std::make_tuple("averageTube", m_averageTubeObserver);
customInstrumentOptions.emplace_back(tmp);
......@@ -92,13 +92,13 @@ ALFView_presenter::setupALFInstrument() {
return std::make_pair(setUpContextConditions, customInstrumentOptions);
}
void ALFView_presenter::extractSingleTube() {
void ALFCustomInstrumentPresenter::extractSingleTube() {
m_model->extractSingleTube();
const std::string WSName = m_model->WSName();
m_analysisPane->addSpectrum(WSName);
}
void ALFView_presenter::averageTube() {
void ALFCustomInstrumentPresenter::averageTube() {
m_model->averageTube();
const std::string WSName = m_model->WSName();
m_analysisPane->addSpectrum(WSName);
......
......@@ -10,8 +10,8 @@
#include "MantidQtWidgets/InstrumentView/BaseCustomInstrumentPresenter.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPanePresenter.h"
#include "ALFView_model.h"
#include "ALFView_view.h"
#include "ALFCustomInstrumentModel.h"
#include "ALFCustomInstrumentView.h"
#include "DllConfig.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
......@@ -20,14 +20,14 @@
namespace MantidQt {
namespace CustomInterfaces {
class MANTIDQT_DIRECT_DLL ALFView_presenter
class MANTIDQT_DIRECT_DLL ALFCustomInstrumentPresenter
: public MantidWidgets::BaseCustomInstrumentPresenter {
Q_OBJECT
public:
ALFView_presenter(ALFView_view *view, ALFView_model *model,
ALFCustomInstrumentPresenter(ALFCustomInstrumentView *view, ALFCustomInstrumentModel *model,
MantidWidgets::PlotFitAnalysisPanePresenter *analysisPane);
~ALFView_presenter() {
~ALFCustomInstrumentPresenter() {
delete m_extractSingleTubeObserver;
delete m_averageTubeObserver;
delete m_analysisPane;
......@@ -47,8 +47,8 @@ private:
void extractSingleTube();
void averageTube();
ALFView_view *m_view;
ALFView_model *m_model;
ALFCustomInstrumentView *m_view;
ALFCustomInstrumentModel *m_model;
MantidWidgets::PlotFitAnalysisPanePresenter *m_analysisPane;
VoidObserver *m_extractSingleTubeObserver;
VoidObserver *m_averageTubeObserver;
......
......@@ -4,7 +4,7 @@
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "ALFView_view.h"
#include "ALFCustomInstrumentView.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include <QMessageBox>
......@@ -15,7 +15,7 @@
namespace MantidQt {
namespace CustomInterfaces {
ALFView_view::ALFView_view(const std::string &instrument, QWidget *parent)
ALFCustomInstrumentView::ALFCustomInstrumentView(const std::string &instrument, QWidget *parent)
: MantidWidgets::BaseCustomInstrumentView(instrument, parent),
m_extractSingleTubeObservable(nullptr), m_averageTubeObservable(nullptr),
m_extractAction(nullptr), m_averageAction(nullptr),
......@@ -23,7 +23,7 @@ ALFView_view::ALFView_view(const std::string &instrument, QWidget *parent)
m_helpPage = "ALF View";
}
void ALFView_view::setUpInstrument(
void ALFCustomInstrumentView::setUpInstrument(
const std::string &fileName,
std::vector<std::function<bool(std::map<std::string, bool>)>> &binders) {
......@@ -52,27 +52,27 @@ void ALFView_view::setUpInstrument(
setInstrumentWidget(instrumentWidget);
}
void ALFView_view::extractSingleTube() {
void ALFCustomInstrumentView::extractSingleTube() {
MantidWidgets::InstrumentWidget *instrumentView = getInstrumentView();
instrumentView->getPickTab()->savePlotToWorkspace();
m_extractSingleTubeObservable->notify();
}
void ALFView_view::averageTube() {
void ALFCustomInstrumentView::averageTube() {
MantidWidgets::InstrumentWidget *instrumentView = getInstrumentView();
instrumentView->getPickTab()->savePlotToWorkspace();
m_averageTubeObservable->notify();
}
void ALFView_view::observeExtractSingleTube(Observer *listner) {
void ALFCustomInstrumentView::observeExtractSingleTube(Observer *listner) {
m_extractSingleTubeObservable->attach(listner);
}
void ALFView_view::observeAverageTube(Observer *listner) {
void ALFCustomInstrumentView::observeAverageTube(Observer *listner) {
m_averageTubeObservable->attach(listner);
}
void ALFView_view::addObserver(std::tuple<std::string, Observer *> &listener) {
void ALFCustomInstrumentView::addObserver(std::tuple<std::string, Observer *> &listener) {
if (std::get<0>(listener) == "singleTube") {
observeExtractSingleTube(std::get<1>(listener));
} else if (std::get<0>(listener) == "averageTube") {
......@@ -80,14 +80,14 @@ void ALFView_view::addObserver(std::tuple<std::string, Observer *> &listener) {
}
}
void ALFView_view::setupAnalysisPane(MantidWidgets::PlotFitAnalysisPaneView *analysis) {
void ALFCustomInstrumentView::setupAnalysisPane(MantidWidgets::PlotFitAnalysisPaneView *analysis) {
// keep a copy here so we can use a custom class
m_analysisPane = analysis;
// just adds it to the view
BaseCustomInstrumentView::setupInstrumentAnalysisSplitters(analysis);
}
void ALFView_view::addSpectrum(std::string wsName) {
void ALFCustomInstrumentView::addSpectrum(std::string wsName) {
m_analysisPane->addSpectrum(wsName);
}
......
......@@ -4,8 +4,8 @@
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFCustomInstrumentView_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFCustomInstrumentView_H_
#include "MantidQtWidgets/InstrumentView/BaseCustomInstrumentView.h"
#include "DllConfig.h"
......@@ -21,11 +21,11 @@
namespace MantidQt {
namespace CustomInterfaces {
class ALFView_view : public MantidWidgets::BaseCustomInstrumentView {
class ALFCustomInstrumentView : public MantidWidgets::BaseCustomInstrumentView {
Q_OBJECT
public:
explicit ALFView_view(const std::string &instrument,
explicit ALFCustomInstrumentView(const std::string &instrument,
QWidget *parent = nullptr);
void observeExtractSingleTube(Observer *listner);
void observeAverageTube(Observer *listner);
......@@ -53,4 +53,4 @@ private:
} // namespace CustomInterfaces
} // namespace MantidQt
#endif /* MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_ */
#endif /* MANTIDQT_CUSTOMINTERFACES_ALFCustomInstrumentView_H_ */
......@@ -5,8 +5,8 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "ALFView.h"
#include "ALFView_model.h"
#include "ALFView_presenter.h"
#include "ALFCustomInstrumentModel.h"
#include "ALFCustomInstrumentPresenter.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h"
#include "MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h"
......@@ -24,14 +24,14 @@ Mantid::Kernel::Logger g_log("ALFView");
ALFView::ALFView(QWidget *parent)
: UserSubWindow(parent), m_view(nullptr), m_presenter(nullptr),
m_analysisPane(nullptr) {
m_model = new ALFView_model();
m_view = new ALFView_view(m_model->getInstrument(), this);
m_model = new ALFCustomInstrumentModel();
m_view = new ALFCustomInstrumentView(m_model->getInstrument(), this);
auto analysisView = new MantidWidgets::PlotFitAnalysisPaneView(-15.0, 15.0, m_view);
auto analysisModel = new MantidWidgets::PlotFitAnalysisPaneModel();
m_analysisPane =
new MantidWidgets::PlotFitAnalysisPanePresenter(analysisView, analysisModel);
m_presenter = new ALFView_presenter(m_view, m_model, m_analysisPane);
m_presenter = new ALFCustomInstrumentPresenter(m_view, m_model, m_analysisPane);
}
void ALFView::initLayout() { this->setCentralWidget(m_view); }
......
......@@ -7,9 +7,9 @@
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEW_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEW_H_
#include "ALFView_model.h"
#include "ALFView_presenter.h"
#include "ALFView_view.h"
#include "ALFCustomInstrumentModel.h"
#include "ALFCustomInstrumentPresenter.h"
#include "ALFCustomInstrumentView.h"
#include "DllConfig.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
#include "MantidQtWidgets/Common/UserSubWindow.h"
......@@ -32,9 +32,9 @@ protected:
void initLayout() override;
private:
ALFView_view *m_view;
ALFView_model *m_model;
ALFView_presenter *m_presenter;
ALFCustomInstrumentView *m_view;
ALFCustomInstrumentModel *m_model;
ALFCustomInstrumentPresenter *m_presenter;
MantidWidgets::PlotFitAnalysisPanePresenter *m_analysisPane;
};
} // namespace CustomInterfaces
......
set(SRC_FILES
ALFView.cpp
ALFView_view.cpp
ALFView_presenter.cpp
ALFView_model.cpp)
ALFCustomInstrumentView.cpp
ALFCustomInstrumentPresenter.cpp
ALFCustomInstrumentModel.cpp)
set(MOC_FILES
ALFView.h
ALFView_view.h
ALFView_presenter.h)
ALFCustomInstrumentView.h
ALFCustomInstrumentPresenter.h)
set(INC_FILES
DllConfig.h)
......
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