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

refs #26544 clang for ALF view

parent e480ea0b
......@@ -6,8 +6,8 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "ALFView_model.h"
#include "ALFView_presenter.h"
#include "PlotFitAnalysisPaneView.h"
#include "PlotFitAnalysisPaneModel.h"
#include "PlotFitAnalysisPaneView.h"
#include "BaseInstrumentModel.h"
#include "BaseInstrumentView.h"
......@@ -36,13 +36,12 @@ ALFView::ALFView(QWidget *parent)
m_view = new ALFView_view(m_model->getInstrument(), this);
auto analysisView = new PlotFitAnalysisPaneView(-15.0, 15.0, m_view);
auto analysisModel = new PlotFitAnalysisPaneModel();
m_analysisPane = new PlotFitAnalysisPanePresenter(analysisView, analysisModel);
m_analysisPane =
new PlotFitAnalysisPanePresenter(analysisView, analysisModel);
m_presenter =
new ALFView_presenter(m_view, m_model, m_analysisPane);
m_presenter = new ALFView_presenter(m_view, m_model, m_analysisPane);
}
void ALFView::initLayout() { this->setCentralWidget(m_view); }
} // namespace CustomInterfaces
} // namespace MantidQt
......@@ -11,13 +11,12 @@
#include "ALFView_presenter.h"
#include "ALFView_view.h"
#include "DllConfig.h"
#include "MantidQtWidgets/Common/UserSubWindow.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
#include "MantidQtWidgets/Common/UserSubWindow.h"
#include "PlotFitAnalysisPanePresenter.h"
#include "PlotFitAnalysisPaneView.h"
namespace MantidQt {
namespace CustomInterfaces {
/** ALFView : Custom interface for looking at ALF data
......@@ -27,9 +26,7 @@ class MANTIDQT_DIRECT_DLL ALFView : public API::UserSubWindow {
public:
ALFView(QWidget *parent = nullptr);
~ALFView() {
delete m_presenter;
};
~ALFView() { delete m_presenter; };
static std::string name() { return "ALF View"; }
static QString categoryInfo() { return "Direct"; }
......@@ -41,8 +38,6 @@ private:
ALFView_model *m_model;
ALFView_presenter *m_presenter;
PlotFitAnalysisPanePresenter *m_analysisPane;
};
} // namespace CustomInterfaces
} // namespace MantidQt
......
......@@ -121,8 +121,7 @@ void ALFView_model::storeSingleTube(const std::string &name) {
AnalysisDataService::Instance().remove(CURVES);
}
std::string ALFView_model::WSName() {
const std::string name =
m_instrumentName + std::to_string(getCurrentRun());
const std::string name = m_instrumentName + std::to_string(getCurrentRun());
return EXTRACTEDWS + name;
}
......@@ -132,7 +131,7 @@ void ALFView_model::averageTube() {
// multiply up current average
auto ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
EXTRACTEDWS + name);
ws*=double(oldTotalNumber);
ws *= double(oldTotalNumber);
// get the data to add
storeSingleTube(name);
......@@ -163,8 +162,7 @@ bool ALFView_model::hasTubeBeenExtracted(const std::string &name) {
return AnalysisDataService::Instance().doesExist(EXTRACTEDWS + name);
}
bool ALFView_model::extractTubeConditon(
std::map<std::string, bool> tabBools) {
bool ALFView_model::extractTubeConditon(std::map<std::string, bool> tabBools) {
try {
bool ifCurve = (tabBools.find("plotStroed")->second ||
......@@ -175,8 +173,7 @@ bool ALFView_model::extractTubeConditon(
}
}
bool ALFView_model::averageTubeConditon(
std::map<std::string, bool> tabBools) {
bool ALFView_model::averageTubeConditon(std::map<std::string, bool> tabBools) {
try {
bool ifCurve = (tabBools.find("plotStroed")->second ||
......@@ -198,9 +195,9 @@ CompositeFunction_sptr ALFView_model::getDefaultFunction() {
CompositeFunction_sptr composite =
boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(
Mantid::API::FunctionFactory::Instance().createFunction(
"CompositeFunction"));
Mantid::API::FunctionFactory::Instance().createFunction(
"CompositeFunction"));
auto func = Mantid::API::FunctionFactory::Instance().createInitialized(
"name = FlatBackground");
composite->addFunction(func);
......
......@@ -8,19 +8,17 @@
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_
#include "BaseInstrumentModel.h"
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/CompositeFunction.h"
#include "MantidAPI/FunctionFactory.h"
#include <map>
#include <string>
namespace MantidQt {
namespace CustomInterfaces {
class ALFView_model : public BaseInstrumentModel {
public:
ALFView_model();
~ALFView_model(){};
......
......@@ -5,12 +5,11 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "ALFView_presenter.h"
#include "ALFView_view.h"
#include "ALFView_model.h"
#include "ALFView_view.h"
#include "MantidAPI/FileFinder.h"
#include <functional>
#include <tuple>
......@@ -19,10 +18,10 @@ namespace CustomInterfaces {
ALFView_presenter::ALFView_presenter(ALFView_view *view, ALFView_model *model,
PlotFitAnalysisPanePresenter *analysisPane)
: BaseInstrumentPresenter(view, model, analysisPane->getView()), m_view(view), m_model(model), m_analysisPane(analysisPane),
: BaseInstrumentPresenter(view, model, analysisPane->getView()),
m_view(view), m_model(model), m_analysisPane(analysisPane),
m_extractSingleTubeObserver(nullptr), m_averageTubeObserver(nullptr) {
addInstrument();
}
void ALFView_presenter::addInstrument() {
......@@ -36,9 +35,7 @@ void ALFView_presenter::setUpInstrumentAnalysisSplitter() {
m_view->setupAnalysisPane(m_analysisPane->getView());
}
void ALFView_presenter::loadSideEffects() {
m_analysisPane->clearCurrentWS();
}
void ALFView_presenter::loadSideEffects() { m_analysisPane->clearCurrentWS(); }
typedef std::pair<std::string,
std::vector<std::function<bool(std::map<std::string, bool>)>>>
......
......@@ -10,8 +10,8 @@
#include "BaseInstrumentPresenter.h"
#include "PlotFitAnalysisPanePresenter.h"
#include "ALFView_view.h"
#include "ALFView_model.h"
#include "ALFView_view.h"
#include "DllConfig.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
#include "MantidQtWidgets/Common/UserSubWindow.h"
......@@ -31,21 +31,19 @@ public:
delete m_extractSingleTubeObserver;
delete m_averageTubeObserver;
delete m_analysisPane;
delete m_model;};
delete m_model;
};
void addInstrument() override;
protected:
void loadSideEffects() override;
std::pair<instrumentSetUp, instrumentObserverOptions>
setupALFInstrument();
std::pair<instrumentSetUp, instrumentObserverOptions> setupALFInstrument();
private:
void setUpInstrumentAnalysisSplitter() override;
void extractSingleTube();
void averageTube();
......
......@@ -16,7 +16,8 @@ namespace MantidQt {
namespace CustomInterfaces {
ALFView_view::ALFView_view(const std::string &instrument, QWidget *parent)
: BaseInstrumentView(instrument, parent),m_extractSingleTubeObservable(nullptr), m_averageTubeObservable(nullptr),
: BaseInstrumentView(instrument, parent),
m_extractSingleTubeObservable(nullptr), m_averageTubeObservable(nullptr),
m_extractAction(nullptr), m_averageAction(nullptr),
m_analysisPane(nullptr) {
m_helpPage = "ALF View";
......@@ -28,7 +29,7 @@ void ALFView_view::setUpInstrument(
m_extractSingleTubeObservable = new Observable();
m_averageTubeObservable = new Observable();
auto instrumentWidget = new MantidWidgets::InstrumentWidget("ALFData");
instrumentWidget->removeTab("Instrument");
instrumentWidget->removeTab("Draw");
......@@ -39,13 +40,13 @@ void ALFView_view::setUpInstrument(
connect(m_extractAction, SIGNAL(triggered()), this,
SLOT(extractSingleTube())),
instrumentWidget->getPickTab()->addToContextMenu(m_extractAction,
binders[0]);
binders[0]);
// set up add to average
m_averageAction = new QAction("Add Tube To Average", this);
connect(m_averageAction, SIGNAL(triggered()), this, SLOT(averageTube())),
instrumentWidget->getPickTab()->addToContextMenu(m_averageAction,
binders[1]);
binders[1]);
setInstrumentWidget(instrumentWidget);
}
......@@ -79,7 +80,7 @@ void ALFView_view::addObserver(std::tuple<std::string, Observer *> &listener) {
}
void ALFView_view::setupAnalysisPane(PlotFitAnalysisPaneView *analysis) {
// keep a copy here so we can use a custom class
// keep a copy here so we can use a custom class
m_analysisPane = analysis;
// just adds it to the view
BaseInstrumentView::setupInstrumentAnalysisSplitters(analysis);
......@@ -87,8 +88,7 @@ void ALFView_view::setupAnalysisPane(PlotFitAnalysisPaneView *analysis) {
void ALFView_view::addSpectrum(std::string wsName) {
m_analysisPane->addSpectrum(wsName);
}
}
} // namespace CustomInterfaces
} // namespace MantidQt
\ No newline at end of file
......@@ -7,11 +7,11 @@
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_
#include "BaseInstrumentView.h"
#include "DllConfig.h"
#include "MantidQtWidgets/Common/MWRunFiles.h"
#include "MantidQtWidgets/Common/ObserverPattern.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidget.h"
#include "BaseInstrumentView.h"
#include "PlotFitAnalysisPaneView.h"
#include <QObject>
......@@ -30,18 +30,19 @@ public:
QWidget *parent = nullptr);
void observeExtractSingleTube(Observer *listner);
void observeAverageTube(Observer *listner);
void setUpInstrument(
const std::string fileName,
std::vector<std::function<bool(std::map<std::string, bool>)>> &binders) override;
void
setUpInstrument(const std::string fileName,
std::vector<std::function<bool(std::map<std::string, bool>)>>
&binders) override;
void addObserver(std::tuple<std::string, Observer *> &listener) override;
void addSpectrum(std::string wsName);
void setupAnalysisPane(PlotFitAnalysisPaneView *analysis);
public slots:
void extractSingleTube();
void averageTube();
void extractSingleTube();
void averageTube();
private:
Observable *m_extractSingleTubeObservable;
......
......@@ -53,35 +53,34 @@ BaseInstrumentModel::loadData(const std::string &name) {
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(m_wsName);
int runNumber = ws->getRunNumber();
std::string message = "success";
std::string message = "success";
return std::make_pair(runNumber, message);
}
return std::make_pair(runNumber, message);
}
void BaseInstrumentModel::rename() {
AnalysisDataService::Instance().rename(m_tmpName, m_wsName);
}
void BaseInstrumentModel::remove() {
AnalysisDataService::Instance().remove(m_tmpName);
}
void BaseInstrumentModel::rename() {
AnalysisDataService::Instance().rename(m_tmpName, m_wsName);
}
void BaseInstrumentModel::remove() {
AnalysisDataService::Instance().remove(m_tmpName);
}
std::string BaseInstrumentModel::dataFileName() { return m_wsName; }
std::string BaseInstrumentModel::dataFileName() { return m_wsName; }
int BaseInstrumentModel::currentRun() {
try {
int BaseInstrumentModel::currentRun() {
try {
auto ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(
m_wsName);
return ws->getRunNumber();
} catch (...) {
return ERRORCODE;
}
}
auto ws =
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(m_wsName);
return ws->getRunNumber();
} catch (...) {
return ERRORCODE;
}
}
bool BaseInstrumentModel::isErrorCode(const int run) {
return (run == ERRORCODE);
}
bool BaseInstrumentModel::isErrorCode(const int run) {
return (run == ERRORCODE);
}
} // namespace CustomInterfaces
} // namespace CustomInterfaces
} // namespace MantidQt
......@@ -14,7 +14,6 @@ namespace CustomInterfaces {
class BaseInstrumentModel {
public:
BaseInstrumentModel();
~BaseInstrumentModel(){};
......
......@@ -29,28 +29,29 @@ public:
QWidget *analysisView);
~BaseInstrumentPresenter() { delete m_loadRunObserver; };
typedef std::pair<std::string,
std::vector<std::function<bool(std::map<std::string, bool>)>>>
typedef std::pair<
std::string,
std::vector<std::function<bool(std::map<std::string, bool>)>>>
instrumentSetUp;
typedef std::vector<std::tuple<std::string, Observer *>>
instrumentObserverOptions;
void initLayout(std::pair<instrumentSetUp, instrumentObserverOptions> *setUp = nullptr);
void initLayout(
std::pair<instrumentSetUp, instrumentObserverOptions> *setUp = nullptr);
virtual void addInstrument();
protected:
virtual void loadSideEffects(){};
virtual void loadSideEffects(){};
private slots
:
private slots:
void loadRunNumber();
private:
void loadAndAnalysis(const std::string &run);
void initInstrument(std::pair<instrumentSetUp, instrumentObserverOptions> *setUp);
void
initInstrument(std::pair<instrumentSetUp, instrumentObserverOptions> *setUp);
virtual void setUpInstrumentAnalysisSplitter();
std::pair<instrumentSetUp, instrumentObserverOptions>
setupInstrument();
std::pair<instrumentSetUp, instrumentObserverOptions> setupInstrument();
BaseInstrumentView *m_view;
BaseInstrumentModel *m_model;
......@@ -58,7 +59,6 @@ private:
std::string m_currentFile;
VoidObserver *m_loadRunObserver;
QWidget *m_analysisPaneView;
};
} // namespace CustomInterfaces
} // namespace MantidQt
......
......@@ -5,8 +5,8 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "BaseInstrumentView.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include "MantidQtWidgets/Common/HelpWindow.h"
#include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include <QMessageBox>
#include <QSizePolicy>
......@@ -19,9 +19,10 @@ namespace CustomInterfaces {
BaseInstrumentView::BaseInstrumentView(const std::string &instrument,
QWidget *parent)
: QSplitter(Qt::Vertical, parent),m_helpPage(""), m_loadRunObservable(nullptr),
m_files(nullptr), m_instrument(QString::fromStdString(instrument)),
m_instrumentWidget(nullptr),m_help(nullptr){
: QSplitter(Qt::Vertical, parent), m_helpPage(""),
m_loadRunObservable(nullptr), m_files(nullptr),
m_instrument(QString::fromStdString(instrument)),
m_instrumentWidget(nullptr), m_help(nullptr) {
auto loadWidget = generateLoadWidget();
this->addWidget(loadWidget);
}
......@@ -59,7 +60,7 @@ QWidget *BaseInstrumentView::generateLoadWidget() {
return loadWidget;
}
void BaseInstrumentView::setupInstrumentAnalysisSplitters(
void BaseInstrumentView::setupInstrumentAnalysisSplitters(
QWidget *analysisPane) {
QSplitter *split = new QSplitter(Qt::Horizontal);
split->addWidget(m_instrumentWidget);
......@@ -67,56 +68,56 @@ QWidget *BaseInstrumentView::generateLoadWidget() {
this->addWidget(split);
}
void BaseInstrumentView::setupHelp(){
void BaseInstrumentView::setupHelp() {
QWidget *helpWidget = new QWidget();
m_help = new QPushButton("?");
m_help->setMaximumWidth(25);
auto helpLayout = new QHBoxLayout(helpWidget);
helpLayout->addWidget(m_help);
helpLayout->addItem(
new QSpacerItem(1000, 20, QSizePolicy::Expanding, QSizePolicy::Expanding));
this->addWidget(helpWidget);
connect(m_help, SIGNAL(clicked()), this, SLOT(openHelp()));
}
m_help = new QPushButton("?");
m_help->setMaximumWidth(25);
auto helpLayout = new QHBoxLayout(helpWidget);
helpLayout->addWidget(m_help);
helpLayout->addItem(new QSpacerItem(1000, 20, QSizePolicy::Expanding,
QSizePolicy::Expanding));
this->addWidget(helpWidget);
connect(m_help, SIGNAL(clicked()), this, SLOT(openHelp()));
}
void BaseInstrumentView::openHelp() {
if (m_helpPage == "") {
return;
}
MantidQt::API::HelpWindow::showCustomInterface(nullptr,
QString::fromStdString(m_helpPage));
void BaseInstrumentView::openHelp() {
if (m_helpPage == "") {
return;
}
MantidQt::API::HelpWindow::showCustomInterface(
nullptr, QString::fromStdString(m_helpPage));
}
std::string BaseInstrumentView::getFile() {
auto name = m_files->getFilenames();
if (name.size() > 0)
return name[0].toStdString();
return "";
}
std::string BaseInstrumentView::getFile() {
auto name = m_files->getFilenames();
if (name.size() > 0)
return name[0].toStdString();
return "";
}
void BaseInstrumentView::setRunQuietly(const std::string &runNumber) {
m_files->setText(QString::fromStdString(runNumber));
}
void BaseInstrumentView::setRunQuietly(const std::string &runNumber) {
m_files->setText(QString::fromStdString(runNumber));
}
void BaseInstrumentView::fileLoaded() {
if (m_files->getText().isEmpty())
return;
void BaseInstrumentView::fileLoaded() {
if (m_files->getText().isEmpty())
return;
if (!m_files->isValid()) {
warningBox(m_files->getFileProblem());
return;
}
m_loadRunObservable->notify();
if (!m_files->isValid()) {
warningBox(m_files->getFileProblem());
return;
}
m_loadRunObservable->notify();
}
void BaseInstrumentView::warningBox(const std::string &message) {
warningBox(QString::fromStdString(message));
}
void BaseInstrumentView::warningBox(const std::string &message) {
warningBox(QString::fromStdString(message));
}
void BaseInstrumentView::warningBox(const QString &message) {
QMessageBox::warning(this, m_instrument + " view", message);
}
void BaseInstrumentView::warningBox(const QString &message) {
QMessageBox::warning(this, m_instrument + " view", message);
}
} // namespace CustomInterfaces
} // namespace CustomInterfaces
\ No newline at end of file
} // namespace MantidQt
\ No newline at end of file
......@@ -56,7 +56,6 @@ protected:
std::string m_helpPage;
private:
QWidget *generateLoadWidget();
void warningBox(const QString &message);
Observable *m_loadRunObservable;
......@@ -64,7 +63,6 @@ private:
QString m_instrument;
MantidWidgets::InstrumentWidget *m_instrumentWidget;
QPushButton *m_help;
};
} // namespace CustomInterfaces
} // namespace MantidQt
......
......@@ -9,20 +9,20 @@
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/AlgorithmManager.h"
using namespace Mantid::API;
namespace MantidQt {
namespace CustomInterfaces {
IFunction_sptr PlotFitAnalysisPaneModel::doFit(const std::string &wsName,
const std::pair<double, double>& range,
IFunction_sptr func) {
IFunction_sptr
PlotFitAnalysisPaneModel::doFit(const std::string &wsName,
const std::pair<double, double> &range,
IFunction_sptr func) {
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("Fit");
alg->initialize();
alg->setProperty("Function", func);
alg->setProperty("InputWorkspace", wsName);
alg->setProperty("Output", wsName+"_fits");
alg->setProperty("Output", wsName + "_fits");
alg->setProperty("StartX", range.first);
alg->setProperty("EndX", range.second);
alg->execute();
......
......@@ -20,7 +20,7 @@ class PlotFitAnalysisPaneModel {
public:
IFunction_sptr doFit(const std::string &wsName,
const std::pair<double, double> &range,
const IFunction_sptr func);
const IFunction_sptr func);
};
} // namespace CustomInterfaces
......