Commit 4652ece0 authored by Robert Applin's avatar Robert Applin
Browse files

Refs #28842. Connect Update estimate button to presenter.

parent 17e6df25
......@@ -25,6 +25,7 @@ public:
virtual std::string getCurrentWS() = 0;
virtual void clearCurrentWS() = 0;
virtual void doFit() = 0;
virtual void updateEstimate() = 0;
virtual void addSpectrum(const std::string &wsName) = 0;
virtual void addFunction(Mantid::API::IFunction_sptr func) = 0;
};
......@@ -46,11 +47,13 @@ public:
std::string getCurrentWS() override { return m_currentName; };
void clearCurrentWS() override { m_currentName = ""; };
void doFit() override;
void updateEstimate() override;
void addSpectrum(const std::string &wsName) override;
void addFunction(Mantid::API::IFunction_sptr func) override;
private:
VoidObserver *m_fitObserver;
VoidObserver *m_updateEstimateObserver;
IPlotFitAnalysisPaneView *m_view;
PlotFitAnalysisPaneModel *m_model;
std::string m_currentName;
......
......@@ -27,6 +27,7 @@ public:
IPlotFitAnalysisPaneView(){};
virtual ~IPlotFitAnalysisPaneView(){};
virtual void observeFitButton(Observer *listener) = 0;
virtual void observeUpdateEstimateButton(Observer *listener) = 0;
virtual std::pair<double, double> getRange() = 0;
virtual Mantid::API::IFunction_sptr getFunction() = 0;
virtual void addSpectrum(const std::string &wsName) = 0;
......@@ -52,6 +53,10 @@ public:
m_fitObservable->attach(listener);
};
void observeUpdateEstimateButton(Observer *listener) override {
m_updateEstimateObservable->attach(listener);
};
std::pair<double, double> getRange() override;
Mantid::API::IFunction_sptr getFunction() override;
void addSpectrum(const std::string &wsName) override;
......@@ -77,6 +82,7 @@ private:
QPushButton *m_fitButton;
QPushButton *m_updateEstimateButton;
Observable *m_fitObservable;
Observable *m_updateEstimateObservable;
};
} // namespace MantidWidgets
} // namespace MantidQt
......@@ -16,13 +16,22 @@ namespace MantidWidgets {
PlotFitAnalysisPanePresenter::PlotFitAnalysisPanePresenter(
IPlotFitAnalysisPaneView *view, PlotFitAnalysisPaneModel *model)
: m_fitObserver(nullptr), m_view(view), m_model(model), m_currentName("") {
: m_fitObserver(nullptr), m_updateEstimateObserver(nullptr), m_view(view),
m_model(model), m_currentName("") {
m_fitObserver = new VoidObserver();
m_updateEstimateObserver = new VoidObserver();
m_view->observeFitButton(m_fitObserver);
m_view->observeUpdateEstimateButton(m_updateEstimateObserver);
std::function<void()> fitBinder =
std::bind(&PlotFitAnalysisPanePresenter::doFit, this);
std::function<void()> updateEstimateBinder =
std::bind(&PlotFitAnalysisPanePresenter::updateEstimate, this);
m_fitObserver->setSlot(fitBinder);
m_updateEstimateObserver->setSlot(updateEstimateBinder);
}
void PlotFitAnalysisPanePresenter::doFit() {
......@@ -41,6 +50,8 @@ void PlotFitAnalysisPanePresenter::doFit() {
}
}
void PlotFitAnalysisPanePresenter::updateEstimate() {}
void PlotFitAnalysisPanePresenter::addFunction(
Mantid::API::IFunction_sptr func) {
m_view->addFunction(std::move(func));
......
......@@ -24,7 +24,8 @@ PlotFitAnalysisPaneView::PlotFitAnalysisPaneView(const double &start,
const double &end,
QWidget *parent)
: QWidget(parent), m_plot(nullptr), m_fitBrowser(nullptr), m_start(nullptr),
m_end(nullptr), m_fitButton(nullptr), m_fitObservable(nullptr) {
m_end(nullptr), m_fitButton(nullptr), m_fitObservable(nullptr),
m_updateEstimateObservable(nullptr) {
setupPlotFitSplitter(start, end);
}
......@@ -52,6 +53,7 @@ QWidget *PlotFitAnalysisPaneView::createFitPane(const double &start,
m_fitButton = new QPushButton("Fit");
m_updateEstimateButton = new QPushButton("Update Estimate");
m_fitObservable = new Observable();
m_updateEstimateObservable = new Observable();
connect(m_fitButton, SIGNAL(clicked()), this, SLOT(doFit()));
connect(m_updateEstimateButton, SIGNAL(clicked()), this,
SLOT(updateEstimate()));
......@@ -93,10 +95,7 @@ void PlotFitAnalysisPaneView::doFit() {
}
void PlotFitAnalysisPaneView::updateEstimate() {
auto function = m_fitBrowser->getFunction();
if (function) {
m_fitObservable->notify();
}
m_updateEstimateObservable->notify();
}
void PlotFitAnalysisPaneView::addSpectrum(const std::string &wsName) {
......
Supports Markdown
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