Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISISEnergyTransferPresenter no longer a QObject #37227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions qt/scientific_interfaces/Indirect/Reduction/CMakeLists.txt
Expand Up @@ -6,16 +6,16 @@ set(SRC_FILES
ILLEnergyTransfer.cpp
ISISCalibration.cpp
ISISDiagnostics.cpp
ISISEnergyTransferValidator.cpp
ISISEnergyTransferModel.cpp
ISISEnergyTransferView.cpp
ISISEnergyTransferPresenter.cpp
ISISEnergyTransferValidator.cpp
ISISEnergyTransferView.cpp
ReductionAlgorithmUtils.cpp
Transmission.cpp
)

set(INC_FILES ISISEnergyTransferData.h ISISEnergyTransferValidator.h ISISEnergyTransferModelUtils.h
ISISEnergyTransferModel.h ReductionAlgorithmUtils.h
ISISEnergyTransferModel.h ISISEnergyTransferPresenter.h ReductionAlgorithmUtils.h
)

set(MOC_FILES
Expand All @@ -25,7 +25,6 @@ set(MOC_FILES
ISISCalibration.h
ISISDiagnostics.h
ISISEnergyTransferView.h
ISISEnergyTransferPresenter.h
Transmission.h
)

Expand Down
8 changes: 0 additions & 8 deletions qt/scientific_interfaces/Indirect/Reduction/DataReduction.cpp
Expand Up @@ -41,22 +41,14 @@ DECLARE_SUBWINDOW(DataReduction)

DataReduction::DataReduction(QWidget *parent)
: InelasticInterface(parent), m_settingsGroup("CustomInterfaces/DataReduction"),
m_algRunner(new MantidQt::API::QtAlgorithmRunner(this)),
m_changeObserver(*this, &DataReduction::handleConfigChange), m_ipfFilename(""),
m_idfDirectory(Mantid::Kernel::ConfigService::Instance().getString("instrumentDefinition.directory")),
m_instDetails() {
// Signals to report load instrument algo result
connect(m_algRunner, SIGNAL(algorithmComplete(bool)), this, SLOT(instrumentLoadingDone(bool)));

Mantid::Kernel::ConfigService::Instance().addObserver(m_changeObserver);
}

DataReduction::~DataReduction() {
Mantid::Kernel::ConfigService::Instance().removeObserver(m_changeObserver);

// Make sure no algos are running after the window has been closed
m_algRunner->cancelRunningAlgorithm();

saveSettings();
}

Expand Down
10 changes: 6 additions & 4 deletions qt/scientific_interfaces/Indirect/Reduction/DataReduction.h
Expand Up @@ -12,7 +12,8 @@

#include "MantidAPI/MatrixWorkspace.h"
#include "MantidGeometry/IComponent.h"
#include "MantidQtWidgets/Common/QtAlgorithmRunner.h"
#include "MantidQtWidgets/Common/AlgorithmRunner.h"
#include "MantidQtWidgets/Common/QtJobRunner.h"

#include <QRegExp>
#include <QScrollArea>
Expand Down Expand Up @@ -166,7 +167,10 @@ private slots:
tabScrollArea->setWidget(tabContent);
tabScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

DataReductionTab *tabIDRContent = new TabPresenter(this, new TabView(tabContent), std::make_unique<TabModel>());
auto jobRunner = std::make_unique<MantidQt::API::QtJobRunner>();
auto algorithmRunner = std::make_unique<MantidQt::API::AlgorithmRunner>(std::move(jobRunner));
DataReductionTab *tabIDRContent =
new TabPresenter(this, new TabView(tabContent), std::make_unique<TabModel>(), std::move(algorithmRunner));

tabIDRContent->setupTab();
tabContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Expand All @@ -185,8 +189,6 @@ private slots:
Ui::DataReduction m_uiForm;
/// The settings group
QString m_settingsGroup;
/// Runner for insturment load algorithm
MantidQt::API::QtAlgorithmRunner *m_algRunner;

// All indirect tabs
QMap<QString, QPair<QWidget *, DataReductionTab *>> m_tabs;
Expand Down
Expand Up @@ -28,6 +28,13 @@ namespace MantidQt::CustomInterfaces {
DataReductionTab::DataReductionTab(IDataReduction *idrUI, QObject *parent)
: InelasticTab(parent), m_idrUI(idrUI), m_tabRunning(false) {
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(tabExecutionComplete(bool)));
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(handleNewInstrumentConfiguration()));
}

DataReductionTab::DataReductionTab(IDataReduction *idrUI, std::unique_ptr<API::IAlgorithmRunner> algorithmRunner)
: InelasticTab(), m_idrUI(idrUI), m_algorithmRunner(std::move(algorithmRunner)), m_tabRunning(false) {
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(tabExecutionComplete(bool)));
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(handleNewInstrumentConfiguration()));
}

DataReductionTab::~DataReductionTab() = default;
Expand Down Expand Up @@ -75,6 +82,8 @@ void DataReductionTab::tabExecutionComplete(bool error) {
}
}

void DataReductionTab::handleNewInstrumentConfiguration() { updateInstrumentConfiguration(); }

/**
* Gets the current instrument workspace
*
Expand Down
Expand Up @@ -11,6 +11,8 @@
#include "Common/InstrumentConfig.h"
#include "Common/OutputPlotOptionsPresenter.h"

#include "MantidQtWidgets/Common/AlgorithmRunner.h"

// Suppress a warning coming out of code that isn't ours
#if defined(__INTEL_COMPILER)
#pragma warning disable 1125
Expand Down Expand Up @@ -46,6 +48,7 @@ class MANTIDQT_INDIRECT_DLL DataReductionTab : public InelasticTab {

public:
DataReductionTab(IDataReduction *idrUI, QObject *parent = nullptr);
DataReductionTab(IDataReduction *idrUI, std::unique_ptr<API::IAlgorithmRunner> algorithmRunner);
~DataReductionTab() override;

/// Set the presenter for the output plotting options
Expand Down Expand Up @@ -85,12 +88,15 @@ public slots:

protected:
IDataReduction *m_idrUI;
std::unique_ptr<API::IAlgorithmRunner> m_algorithmRunner;

private slots:
void tabExecutionComplete(bool error);
void handleNewInstrumentConfiguration();

private:
virtual void setFileExtensionsByName(bool filter) { UNUSED_ARG(filter); };
virtual void updateInstrumentConfiguration() = 0;

std::unique_ptr<OutputPlotOptionsPresenter> m_plotOptionsPresenter;
bool m_tabRunning;
Expand Down
Expand Up @@ -33,7 +33,6 @@ namespace MantidQt::CustomInterfaces {
ILLEnergyTransfer::ILLEnergyTransfer(IDataReduction *idrUI, QWidget *parent) : DataReductionTab(idrUI, parent) {
m_uiForm.setupUi(parent);

connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setInstrumentDefault()));
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmComplete(bool)));

connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked()));
Expand Down Expand Up @@ -334,7 +333,7 @@ void ILLEnergyTransfer::save() {
/**
* Called when the instrument has changed, used to update default values.
*/
void ILLEnergyTransfer::setInstrumentDefault() {
void ILLEnergyTransfer::updateInstrumentConfiguration() {
auto const instrument = getInstrumentDetail("instrument");

// Set instrument in run file widgets
Expand Down
Expand Up @@ -30,14 +30,15 @@ public slots:

private slots:
void algorithmComplete(bool error);
void setInstrumentDefault();

void runClicked();
void setRunEnabled(bool enabled);
void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged",
QString const &message = "Run", QString const &tooltip = "");

private:
void updateInstrumentConfiguration() override;

Ui::ILLEnergyTransfer m_uiForm;
double m_backScaling = 1.;
double m_backCalibScaling = 1.;
Expand Down
Expand Up @@ -129,9 +129,6 @@ ISISCalibration::ISISCalibration(IDataReduction *idrUI, QWidget *parent)
auto resPeak = m_uiForm.ppResolution->addRangeSelector("ResPeak");
resPeak->setColour(Qt::red);

// Update instrument information when a new instrument config is selected
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setDefaultInstDetails()));

// Update property map when a range selector is moved
connectRangeSelectors();
// Update range selector positions when a value in the double manager changes
Expand Down Expand Up @@ -373,7 +370,7 @@ bool ISISCalibration::validate() {
/**
* Sets default spectra, peak and background ranges.
*/
void ISISCalibration::setDefaultInstDetails() {
void ISISCalibration::updateInstrumentConfiguration() {
try {
setDefaultInstDetails(getInstrumentDetails());
} catch (std::exception const &ex) {
Expand Down Expand Up @@ -466,7 +463,7 @@ void ISISCalibration::calPlotRaw() {
setPeakRangeLimits(dataX.front(), dataX.back());
setBackgroundRangeLimits(dataX.front(), dataX.back());

setDefaultInstDetails();
updateInstrumentConfiguration();

m_uiForm.ppCalibration->replot();

Expand Down
Expand Up @@ -60,7 +60,6 @@ private slots:
void calSetDefaultResolution(const Mantid::API::MatrixWorkspace_const_sptr &ws);
void resCheck(bool state); ///< handles checking/unchecking of "Create RES
/// File" checkbox
void setDefaultInstDetails();
void pbRunEditing(); //< Called when a user starts to type / edit the runs to load.
void pbRunFinding(); //< Called when the FileFinder starts finding the files.
void pbRunFinished(); //< Called when the FileFinder has finished finding the
Expand All @@ -75,6 +74,8 @@ private slots:
QString const &message = "Run", QString const &tooltip = "");

private:
void updateInstrumentConfiguration() override;

void setDefaultInstDetails(QMap<QString, QString> const &instrumentDetails);
void connectRangeSelectors();
void disconnectRangeSelectors();
Expand Down
Expand Up @@ -91,9 +91,6 @@ ISISDiagnostics::ISISDiagnostics(IDataReduction *idrUI, QWidget *parent) : DataR

// SIGNAL/SLOT CONNECTIONS

// Update instrument information when a new instrument config is selected
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setDefaultInstDetails()));

// Update properties when a range selector is changed
connect(peakRangeSelector, SIGNAL(selectionChanged(double, double)), this,
SLOT(rangeSelectorDropped(double, double)));
Expand Down Expand Up @@ -245,7 +242,7 @@ void ISISDiagnostics::algorithmComplete(bool error) {
/**
* Sets default spectra, peak and background ranges.
*/
void ISISDiagnostics::setDefaultInstDetails() {
void ISISDiagnostics::updateInstrumentConfiguration() {
try {
setDefaultInstDetails(getInstrumentDetails());
} catch (std::exception const &ex) {
Expand Down
Expand Up @@ -58,7 +58,6 @@ private slots:
void sliceCalib(bool state);
void rangeSelectorDropped(double /*min*/, double /*max*/);
void doublePropertyChanged(QtProperty * /*prop*/, double /*val*/);
void setDefaultInstDetails();
void sliceAlgDone(bool error);
void pbRunEditing(); //< Called when a user starts to type / edit the runs to load.
void pbRunFinding(); //< Called when the FileFinder starts finding the files.
Expand All @@ -73,6 +72,8 @@ private slots:
QString const &message = "Run", QString const &tooltip = "");

private:
void updateInstrumentConfiguration() override;

void setDefaultInstDetails(QMap<QString, QString> const &instrumentDetails);

void setFileExtensionsByName(bool filter) override;
Expand Down
Expand Up @@ -17,7 +17,7 @@ using namespace Mantid::API;
using namespace MantidQt::MantidWidgets::WorkspaceUtils;

namespace MantidQt::CustomInterfaces {
IETModel::IETModel() : m_outputWorkspaces() {}
IETModel::IETModel() : m_outputGroupName(), m_outputWorkspaces() {}

std::vector<std::string> IETModel::validateRunData(IETRunData const &runData) {
std::vector<std::string> errors;
Expand Down Expand Up @@ -119,8 +119,8 @@ std::string IETModel::getOutputGroupName(InstrumentData const &instData, std::st
return instrument + inputText + "_" + analyser + "_" + reflection + "_Reduced";
}

std::string IETModel::runIETAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner,
InstrumentData const &instData, IETRunData &runData) {
MantidQt::API::IConfiguredAlgorithm_sptr IETModel::energyTransferAlgorithm(InstrumentData const &instData,
IETRunData &runData) {
auto properties = runData.groupingProperties();

setInstrumentProperties(*properties, instData);
Expand All @@ -130,17 +130,12 @@ std::string IETModel::runIETAlgorithm(MantidQt::API::BatchAlgorithmRunner *batch
setRebinProperties(*properties, runData.getRebinData());
setAnalysisProperties(*properties, runData.getAnalysisData());

std::string outputGroupName = getOutputGroupName(instData, runData.getInputData().getInputText());
setOutputProperties(*properties, runData.getOutputData(), outputGroupName);
m_outputGroupName = getOutputGroupName(instData, runData.getInputData().getInputText());
setOutputProperties(*properties, runData.getOutputData(), m_outputGroupName);

auto reductionAlg = AlgorithmManager::Instance().create("ISISIndirectEnergyTransfer");
reductionAlg->initialize();
API::IConfiguredAlgorithm_sptr configuredAlg =
std::make_shared<API::ConfiguredAlgorithm>(std::move(reductionAlg), std::move(properties));

batchAlgoRunner->executeAlgorithmAsync(std::move(configuredAlg));

return outputGroupName;
return std::make_shared<API::ConfiguredAlgorithm>(std::move(reductionAlg), std::move(properties));
}

std::vector<std::string> IETModel::validatePlotData(IETPlotData const &plotParams) {
Expand Down
Expand Up @@ -27,8 +27,8 @@ class MANTIDQT_INDIRECT_DLL IIETModel {
virtual std::vector<std::string> validateRunData(IETRunData const &runData) = 0;
virtual std::vector<std::string> validatePlotData(IETPlotData const &plotData) = 0;

virtual std::string runIETAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner,
InstrumentData const &instData, IETRunData &runParams) = 0;
virtual MantidQt::API::IConfiguredAlgorithm_sptr energyTransferAlgorithm(InstrumentData const &instData,
IETRunData &runParams) = 0;
virtual std::deque<MantidQt::API::IConfiguredAlgorithm_sptr>
plotRawAlgorithmQueue(InstrumentData const &instData, IETPlotData const &plotData) const = 0;

Expand All @@ -41,6 +41,7 @@ class MANTIDQT_INDIRECT_DLL IIETModel {
virtual std::vector<std::string> groupWorkspaces(std::string const &groupName, std::string const &instrument,
std::string const &groupOption, bool const shouldGroup) = 0;

virtual std::string outputGroupName() const = 0;
virtual std::vector<std::string> outputWorkspaceNames() const = 0;
};

Expand All @@ -54,8 +55,8 @@ class MANTIDQT_INDIRECT_DLL IETModel : public IIETModel {
std::vector<std::string> validateRunData(IETRunData const &runData) override;
std::vector<std::string> validatePlotData(IETPlotData const &plotData) override;

std::string runIETAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner, InstrumentData const &instData,
IETRunData &runParams) override;
MantidQt::API::IConfiguredAlgorithm_sptr energyTransferAlgorithm(InstrumentData const &instData,
IETRunData &runParams) override;
std::deque<MantidQt::API::IConfiguredAlgorithm_sptr>
plotRawAlgorithmQueue(InstrumentData const &instData, IETPlotData const &plotData) const override;

Expand All @@ -79,6 +80,8 @@ class MANTIDQT_INDIRECT_DLL IETModel : public IIETModel {
std::string const &outputGroupName);
std::string getOutputGroupName(InstrumentData const &instData, std::string const &inputFiles);

[[nodiscard]] inline std::string outputGroupName() const noexcept override { return m_outputGroupName; }

[[nodiscard]] inline std::vector<std::string> outputWorkspaceNames() const noexcept override {
return m_outputWorkspaces;
}
Expand All @@ -97,6 +100,7 @@ class MANTIDQT_INDIRECT_DLL IETModel : public IIETModel {
plotRawAlgorithmQueue(std::string const &rawFile, std::string const &basename, std::string const &instrumentName,
std::vector<int> const &detectorList, IETBackgroundData const &backgroundData) const;

std::string m_outputGroupName;
std::vector<std::string> m_outputWorkspaces;
};
} // namespace CustomInterfaces
Expand Down