Commit 2ac227a7 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #26544 ALFView analysis pane added

parent 6812232f
......@@ -46,7 +46,7 @@ void ALFView::initLayout() {
}
typedef std::pair<std::string,
std::vector<std::function<bool(std::map<std::string, bool>)>>>
std::vector<std::function<bool(std::map<std::string, bool>)>>>
instrumentSetUp;
typedef std::vector<std::tuple<std::string, Observer *>>
instrumentObserverOptions;
......@@ -64,7 +64,7 @@ ALFView::initInstrument() {
// set up the slots for the custom context menu
std::vector<std::tuple<std::string, Observer *>> customInstrumentOptions;
std::vector<std::function<bool(std::map<std::string, bool>)>> binders;
// set up custom context menu conditions
std::function<bool(std::map<std::string, bool>)> extractConditionBinder =
std::bind(&ALFView_model::extractTubeConditon, m_model,
......@@ -73,16 +73,14 @@ ALFView::initInstrument() {
std::bind(&ALFView_model::averageTubeConditon, m_model,
std::placeholders::_1);
binders.push_back(extractConditionBinder);
binders.push_back(averageTubeConditonBinder);
setUpContextConditions =
std::make_pair(m_model->dataFileName(),binders);
binders.push_back(extractConditionBinder);
binders.push_back(averageTubeConditonBinder);
setUpContextConditions = std::make_pair(m_model->dataFileName(), binders);
// set up single tube extract
std::function<void()> extractSingleTubeBinder =
std::bind(&ALFView_model::extractSingleTube, m_model); // binder for slot
std::bind(&ALFView::extractSingleTube, this); // binder for slot
m_extractSingleTubeObserver->setSlot(
extractSingleTubeBinder); // add slot to observer
std::tuple<std::string, Observer *> tmp = std::make_tuple(
......@@ -91,14 +89,23 @@ ALFView::initInstrument() {
// set up average tube
std::function<void()> averageTubeBinder =
std::bind(&ALFView_model::averageTube, m_model);
std::bind(&ALFView::averageTube, this);
m_averageTubeObserver->setSlot(averageTubeBinder);
tmp = std::make_tuple("averageTube", m_averageTubeObserver);
customInstrumentOptions.push_back(tmp);
return std::make_pair(setUpContextConditions, customInstrumentOptions);
}
}
void ALFView::extractSingleTube() {
m_model->extractSingleTube();
m_view->addSpectrum(m_model->WSName());
}
void ALFView::averageTube() {
m_model->averageTube();
m_view->addSpectrum(m_model->WSName());
}
} // namespace CustomInterfaces
} // namespace MantidQt
......@@ -48,8 +48,10 @@ typedef std::pair < std::string,
instrumentObserverOptions;
std::pair<instrumentSetUp, instrumentObserverOptions> initInstrument();
void extractSingleTube();
void averageTube();
BaseInstrumentView *m_view;
ALFView_view *m_view;
ALFView_model *m_model;
ALFView_presenter *m_presenter;
VoidObserver *m_extractSingleTubeObserver;
......
......@@ -122,6 +122,11 @@ void ALFView_model::storeSingleTube(const std::string &name) {
AnalysisDataService::Instance().remove(CURVES);
}
std::string ALFView_model::WSName() {
const std::string name =
getInstrumentName() + std::to_string(getCurrentRun());
return EXTRACTEDWS + name;
}
void ALFView_model::averageTube() {
const std::string name = getInstrumentName() + std::to_string(getCurrentRun());
......
......@@ -31,7 +31,7 @@ public:
bool extractTubeConditon(std::map<std::string, bool> tabBools);
bool averageTubeConditon(std::map<std::string, bool> tabBools);
void extractSingleTube();
std::string WSName();
private:
int m_numberOfTubesInAverage;
int m_currentRun;
......
......@@ -31,7 +31,10 @@ void ALFView_presenter::initLayout(
std::bind(&ALFView_presenter::loadRunNumber, this);
m_loadRunObserver->setSlot(loadBinder);
initInstrument(setUp);
m_view->setupInstrumentPlotFitSplitters();
}
void ALFView_presenter::loadAndAnalysis(const std::string &pathToRun) {
......
......@@ -76,5 +76,11 @@ void ALFView_view::addObserver(std::tuple<std::string, Observer *> &listener) {
observeAverageTube(std::get<1>(listener));
}
}
void ALFView_view::addSpectrum(std::string wsName) {
m_plot->addSpectrum("Extracrted Data", wsName.c_str(), 0, Qt::black);
}
} // namespace CustomInterfaces
} // namespace MantidQt
\ No newline at end of file
......@@ -35,6 +35,7 @@ public:
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);
public slots:
void extractSingleTube();
......
......@@ -10,8 +10,8 @@
#include <QMessageBox>
#include <QSizePolicy>
#include <QSpacerItem>
#include <QVBoxLayout>
#include <QSplitter>
#include <QVBoxLayout>
namespace MantidQt {
namespace CustomInterfaces {
......@@ -19,10 +19,10 @@ namespace CustomInterfaces {
BaseInstrumentView::BaseInstrumentView(const std::string &instrument,
QWidget *parent)
: QSplitter(Qt::Vertical, parent), m_plot(nullptr), m_fitBrowser(nullptr),
m_start(nullptr), m_end(nullptr),
m_loadRunObservable(nullptr), m_files(nullptr),
m_instrument(QString::fromStdString(instrument)),
m_instrumentWidget(nullptr), m_fitPlotLayout(nullptr), m_fitButton(nullptr) {
m_start(nullptr), m_end(nullptr), m_loadRunObservable(nullptr),
m_files(nullptr), m_instrument(QString::fromStdString(instrument)),
m_instrumentWidget(nullptr), m_fitPlotLayout(nullptr),
m_fitButton(nullptr),m_fitObservable(nullptr) {
auto loadWidget = generateLoadWidget();
this->addWidget(loadWidget);
}
......@@ -59,25 +59,29 @@ QWidget *BaseInstrumentView::generateLoadWidget() {
}
void BaseInstrumentView::setupPlotFitSplitter() {
m_fitPlotLayout = new QSplitter(Qt::Vertical);
m_fitPlotLayout = new QSplitter(Qt::Vertical);
m_plot = new MantidWidgets::PreviewPlot();
m_plot->setCanvasColour(Qt::white);
m_fitPlotLayout->addWidget(m_plot);
m_fitPlotLayout->addWidget(createFitPane());
}
QWidget *BaseInstrumentView::createFitPane() {
auto fitPane = new QWidget();
auto fitPaneLayout = new QVBoxLayout(fitPane);
auto fitButtons = new QWidget();
auto layout = new QHBoxLayout(fitButtons);
m_fitButton = new QPushButton("Fit");
m_fitObservable = new Observable();
connect(m_fitButton, SIGNAL(clicked()), this, SLOT(doFit()));
layout->addWidget(m_fitButton);
layout->addItem(
new QSpacerItem(80, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
fitPaneLayout->addWidget(fitButtons);
m_fitBrowser = new MantidWidgets::FunctionBrowser(this);
......@@ -96,48 +100,54 @@ void BaseInstrumentView::setupPlotFitSplitter() {
rangeLayout->addWidget(end);
rangeLayout->addWidget(m_end);
fitPaneLayout->addWidget(range);
m_fitPlotLayout->addWidget(fitPane);
}
void BaseInstrumentView::setupInstrumentPlotFitSplitters() {
setupPlotFitSplitter();
QSplitter *split =
new QSplitter(Qt::Horizontal);
split->addWidget(m_instrumentWidget);
split->addWidget(m_fitPlotLayout);
this->addWidget(split);
return fitPane;
}
void BaseInstrumentView::setupInstrumentPlotFitSplitters() {
std::string BaseInstrumentView::getFile() {
auto name = m_files->getFilenames();
if (name.size() > 0)
return name[0].toStdString();
return "";
}
setupPlotFitSplitter();
QSplitter *split = new QSplitter(Qt::Horizontal);
split->addWidget(m_instrumentWidget);
split->addWidget(m_fitPlotLayout);
this->addWidget(split);
}
void BaseInstrumentView::setRunQuietly(const std::string &runNumber) {
m_files->setText(QString::fromStdString(runNumber));
}
std::string BaseInstrumentView::getFile() {
auto name = m_files->getFilenames();
if (name.size() > 0)
return name[0].toStdString();
return "";
}
void BaseInstrumentView::fileLoaded() {
if (m_files->getText().isEmpty())
return;
void BaseInstrumentView::setRunQuietly(const std::string &runNumber) {
m_files->setText(QString::fromStdString(runNumber));
}
if (!m_files->isValid()) {
warningBox(m_files->getFileProblem());
return;
void BaseInstrumentView::fileLoaded() {
if (m_files->getText().isEmpty())
return;
if (!m_files->isValid()) {
warningBox(m_files->getFileProblem());
return;
}
m_loadRunObservable->notify();
}
void BaseInstrumentView::doFit() {
auto function = m_fitBrowser->getFunction();
if (function->nFunctions() == 0) {
return;
}
m_fitObservable->notify();
}
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 MantidQt
\ No newline at end of file
} // namespace CustomInterfaces
\ No newline at end of file
......@@ -50,6 +50,7 @@ public:
public slots:
void fileLoaded();
void doFit();
protected:
MantidWidgets::PreviewPlot *m_plot;
......@@ -60,12 +61,14 @@ private:
QWidget *generateLoadWidget();
void warningBox(const QString &message);
void setupPlotFitSplitter();
QWidget *createFitPane();
Observable *m_loadRunObservable;
API::MWRunFiles *m_files;
QString m_instrument;
MantidWidgets::InstrumentWidget *m_instrumentWidget;
QSplitter *m_fitPlotLayout;
QPushButton *m_fitButton;
Observable *m_fitObservable;
};
} // namespace CustomInterfaces
} // namespace MantidQt
......
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