Skip to content

Commit

Permalink
Merge pull request #38388 from mantidproject/38005_mvp_stretch
Browse files Browse the repository at this point in the history
Refactor the Stretch tab in BayesFitting to meet MVP design pattern
  • Loading branch information
SilkeSchomann authored Dec 9, 2024
2 parents 1648bba + 746f8a1 commit cb03080
Show file tree
Hide file tree
Showing 19 changed files with 1,318 additions and 574 deletions.
21 changes: 14 additions & 7 deletions qt/scientific_interfaces/Inelastic/BayesFitting/BayesFitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
#include "MantidQtWidgets/Spectroscopy/SettingsWidget/Settings.h"
#include "Quasi.h"
#include "ResNormPresenter.h"
#include "Stretch.h"
#include "StretchPresenter.h"

#include <MantidQtWidgets/Common/QtJobRunner.h>

using namespace MantidQt::CustomInterfaces;

namespace MantidQt::CustomInterfaces {
DECLARE_SUBWINDOW(BayesFitting)

Expand All @@ -25,17 +23,26 @@ BayesFitting::BayesFitting(QWidget *parent)
// Connect Poco Notification Observer
Mantid::Kernel::ConfigService::Instance().addObserver(m_changeObserver);

auto jobRunner = std::make_unique<MantidQt::API::QtJobRunner>(true);
auto algorithmRunner = std::make_unique<MantidQt::API::AlgorithmRunner>(std::move(jobRunner));
auto resNormRunner = createAlgorithmRunner();

// insert each tab into the interface on creation
auto resNormModel = std::make_unique<ResNormModel>();
auto resNormWidget = m_uiForm.bayesFittingTabs->widget(RES_NORM);
m_bayesTabs.emplace(RES_NORM, new ResNormPresenter(resNormWidget, std::move(algorithmRunner), std::move(resNormModel),
m_bayesTabs.emplace(RES_NORM, new ResNormPresenter(resNormWidget, std::move(resNormRunner), std::move(resNormModel),
new ResNormView(resNormWidget)));

m_bayesTabs.emplace(QUASI, new Quasi(m_uiForm.bayesFittingTabs->widget(QUASI)));
m_bayesTabs.emplace(STRETCH, new Stretch(m_uiForm.bayesFittingTabs->widget(STRETCH)));

auto stretchRunner = createAlgorithmRunner();

auto tabContent = m_uiForm.bayesFittingTabs->widget(STRETCH);
m_bayesTabs.emplace(STRETCH, new StretchPresenter(tabContent, new StretchView(tabContent),
std::make_unique<StretchModel>(), std::move(stretchRunner)));
}

std::unique_ptr<MantidQt::API::AlgorithmRunner> BayesFitting::createAlgorithmRunner() const {
auto jobRunner = std::make_unique<MantidQt::API::QtJobRunner>(true);
return std::make_unique<MantidQt::API::AlgorithmRunner>(std::move(jobRunner));
}

void BayesFitting::initLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class MANTIDQT_INELASTIC_DLL BayesFitting : public InelasticInterface {
void initLayout() override;

private:
std::unique_ptr<MantidQt::API::AlgorithmRunner> createAlgorithmRunner() const;

std::string documentationPage() const override;

void applySettings(std::map<std::string, QVariant> const &settings) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ set(SRC_FILES
ResNormModel.cpp
ResNormView.cpp
ResNormPresenter.cpp
Stretch.cpp
StretchView.cpp
StretchPresenter.cpp
StretchModel.cpp
)

set(INC_FILES ResNormPresenter.h ResNormModel.h)
set(INC_FILES ResNormPresenter.h ResNormModel.h StretchPresenter.h StretchModel.h)

set(MOC_FILES BayesFitting.h BayesFittingTab.h Quasi.h ResNormView.h Stretch.h)
set(MOC_FILES BayesFitting.h BayesFittingTab.h Quasi.h ResNormView.h StretchView.h)

set(UI_FILES BayesFitting.ui Quasi.ui ResNorm.ui Stretch.ui)

Expand All @@ -29,7 +31,6 @@ set(ALL_INC_FILES
${ALL_INC_FILES} ${INC_FILES}
PARENT_SCOPE
)

set(ALL_MOC_FILES
${ALL_MOC_FILES} ${MOC_FILES}
PARENT_SCOPE
Expand Down
Loading

0 comments on commit cb03080

Please sign in to comment.