diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt index 3300327a96c9321aca03298bb0d04ee2717275f6..768e4f6b93abad41f33e8779c62d5d81db2e0060 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory( Event ) -#add_subdirectory(Experiment) +add_subdirectory(Experiment) #add_subdirectory(Instrument) #add_subdirectory(Runs) add_subdirectory( RunsTable ) diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h index d65cd662c4941c8657df60629bd4f4b2ac40269d..8daf59f758b4192dca57e4676a4ed5e4fc479f60 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Event/IEventPresenter.h @@ -39,11 +39,6 @@ enum class SliceType { None, UniformEven, Uniform, Custom, LogValue }; class IEventPresenter { public: virtual ~IEventPresenter() = default; - /// Time-slicing values -// virtual std::string getTimeSlicingValues() const = 0; -// /// Time-slicing type -// virtual std::string getTimeSlicingType() const = 0; - virtual void acceptMainPresenter(IReflBatchPresenter *mainPresenter) =0; virtual void onReductionPaused() = 0; virtual void onReductionResumed() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/CMakeLists.txt index 7daa57f0e5e34465af8f84698db32cb9cfe0e2ac..91aaccae4df10e2fca1fdfc6da3e9a174905b7d4 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/CMakeLists.txt +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/CMakeLists.txt @@ -1,16 +1,22 @@ set ( EXPERIMENT_SRC_FILES + ExperimentView.cpp + ExperimentPresenter.cpp ) # Include files aren't required, but this makes them appear in Visual Studio # IMPORTANT: Include files are required in the MOC_FILES set. Scroll down to find it. set ( EXPERIMENT_INC_FILES + ExperimentView.h + ExperimentPresenter.h + IExperimentView.h ) set ( EXPERIMENT_MOC_FILES + ExperimentView.h ) set ( EXPERIMENT_UI_FILES - ExperimentWidget.ui + ExperimentWidget.ui ) PREPEND( EXPERIMENT_SRC_FILES GUI/Experiment ${EXPERIMENT_SRC_FILES}) diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d746b9f44701f9f45aeb05669d9290dfeb3b6675 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.cpp @@ -0,0 +1,42 @@ +#include "ExperimentPresenter.h" + +namespace MantidQt { +namespace CustomInterfaces { + +ExperimentPresenter::ExperimentPresenter(IExperimentView *view) + : m_view(view), m_model() { + m_view->subscribe(this); +} + +void ExperimentPresenter::notifySettingsChanged() { + auto const analysisMode = analysisModeFromString(m_view->getAnalysisMode()); + auto const reductionType = + reductionTypeFromString(m_view->getReductionType()); + auto const summationType = + summationTypeFromString(m_view->getSummationType()); + auto const cRho = m_view->getCRho(); + auto const cAlpha = m_view->getCAlpha(); + auto const cAp = m_view->getCAp(); + auto const cPp = m_view->getCPp(); + auto polarizationCorrections = + PolarizationCorrections(cRho, cAlpha, cAp, cPp); + auto transmissionRunRange = + RangeInLambda(m_view->getTransmissionStartOverlap(), + m_view->getTransmissionEndOverlap()); + auto stitchParameters = m_view->getStitchOptions(); + + m_model = Experiment(analysisMode, reductionType, summationType, + polarizationCorrections, transmissionRunRange, + stitchParameters, {}); +} + +void ExperimentPresenter::notifySummationTypeChanged() { + if (m_model.get().summationType() == SummationType::SumInQ) + m_view->enableReductionType(); + else + m_view->disableReductionType(); +} + +Experiment const &ExperimentPresenter::experiment() const { return m_model.get(); } +} +} diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..a799a1c20b8a0909903678b9c753c891023f56a5 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenter.h @@ -0,0 +1,55 @@ +#ifndef MANTID_ISISREFLECTOMETRY_EXPERIMENTPRESENTER_H +#define MANTID_ISISREFLECTOMETRY_EXPERIMENTPRESENTER_H + +#include "../../DllConfig.h" +#include "IReflBatchPresenter.h" +#include "IExperimentView.h" +#include "IExperimentPresenter.h" +#include "../../Reduction/Experiment.h" +#include <boost/optional.hpp> + +namespace MantidQt { +namespace CustomInterfaces { + +/** @class ExperimentPresenter + +ExperimentPresenter is a presenter class for the widget 'Event' in the +ISIS Reflectometry Interface. + +Copyright © 2011-16 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class MANTIDQT_ISISREFLECTOMETRY_DLL ExperimentPresenter : + public ExperimentViewSubscriber, public IExperimentPresenter { +public: + ExperimentPresenter(IExperimentView *view); + void notifySettingsChanged() override; + void notifySummationTypeChanged() override; + + Experiment const& experiment() const; + +private: + IExperimentView* m_view; + boost::optional<Experiment> m_model; +}; +} +} +#endif // MANTID_ISISREFLECTOMETRY_EXPERIMENTPRESENTER_H diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..d7d21222ee66de4f11e01391566283b777b0663f --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentPresenterFactory.h @@ -0,0 +1,20 @@ +#ifndef MANTID_ISISREFLECTOMETRY_EXPERIMENTPRESENTERFACTORY_H +#define MANTID_ISISREFLECTOMETRY_EXPERIMENTPRESENTERFACTORY_H +#include "DllConfig.h" +#include "IExperimentView.h" +#include "IExperimentPresenter.h" +#include "ExperimentPresenter.h" +#include <memory> + +namespace MantidQt { +namespace CustomInterfaces { + +class ExperimentPresenterFactory { +public: + std::unique_ptr<IExperimentPresenter> make(IExperimentView *view) { + return std::make_unique<ExperimentPresenter>(view); + } +}; +} +} +#endif // MANTID_ISISREFLECTOMETRY_EXPERIMENTPRESENTERFACTORY_H diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentView.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5957d0354310ddecda1c00b7881a3dd57391c28d --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentView.cpp @@ -0,0 +1,443 @@ +#include "ExperimentView.h" +#include <boost/algorithm/string/join.hpp> +#include "MantidQtWidgets/Common/AlgorithmHintStrategy.h" +#include <QMessageBox> +#include <QScrollBar> + +namespace MantidQt { +namespace CustomInterfaces { + +/** Constructor +* @param parent :: [input] The parent of this widget +*/ +ExperimentView::ExperimentView( + Mantid::API::IAlgorithm_sptr algorithmForTooltips, QWidget *parent) { + UNUSED_ARG(parent); + initLayout(); + registerSettingsWidgets(algorithmForTooltips); +} + +void ExperimentView::subscribe(ExperimentViewSubscriber *notifyee) { + m_notifyee = notifyee; +} + +/** +Initialise the Interface +*/ +void ExperimentView::initLayout() { + m_ui.setupUi(this); + + auto blacklist = + std::vector<std::string>({"InputWorkspaces", "OutputWorkspace"}); + MantidWidgets::AlgorithmHintStrategy strategy("Stitch1DMany", blacklist); + createStitchHints(strategy.createHints()); + + initOptionsTable(); + + connect(m_ui.getExpDefaultsButton, SIGNAL(clicked()), this, + SLOT(requestExpDefaults())); + connect(m_ui.expSettingsGrid, SIGNAL(clicked(bool)), this, + SLOT(setPolarisationOptionsEnabled(bool))); + connect(m_ui.summationTypeComboBox, SIGNAL(currentIndexChanged(int)), this, + SLOT(summationTypeChanged(int))); + connect(m_ui.addPerAngleOptionsButton, SIGNAL(clicked()), this, + SLOT(addPerAngleOptionsTableRow())); +} + +void ExperimentView::initOptionsTable() { + auto table = m_ui.optionsTable; + + // Set angle and scale columns to a small width so everything fits + table->resizeColumnsToContents(); + + auto header = table->horizontalHeader(); + int totalRowHeight = 0; + for (int i = 0; i < table->rowCount(); ++i) { + totalRowHeight += table->rowHeight(i); + } + + const int padding = 2; + table->setMinimumHeight(totalRowHeight + header->height() + padding); +} + +void ExperimentView::connectSettingsChange(QLineEdit &edit) { + connect(&edit, SIGNAL(textChanged(QString const &)), this, + SLOT(notifySettingsChanged())); +} + +void ExperimentView::connectSettingsChange(QDoubleSpinBox &edit) { + connect(&edit, SIGNAL(valueChanged(QString const &)), this, + SLOT(notifySettingsChanged())); +} + +void ExperimentView::connectSettingsChange(QComboBox &edit) { + connect(&edit, SIGNAL(currentIndexChanged(int)), this, + SLOT(notifySettingsChanged())); +} + +void ExperimentView::connectSettingsChange(QCheckBox &edit) { + connect(&edit, SIGNAL(stateChanged(int)), this, + SLOT(notifySettingsChanged())); +} + +void ExperimentView::connectSettingsChange(QTableWidget &edit) { + connect(&edit, SIGNAL(cellChanged(int, int)), this, + SLOT(notifySettingsChanged())); +} + +void ExperimentView::disableAll() { m_ui.expSettingsGrid->setEnabled(false); } + +void ExperimentView::enableAll() { m_ui.expSettingsGrid->setEnabled(true); } + +void ExperimentView::registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg) { + registerExperimentSettingsWidgets(alg); +} + +void ExperimentView::registerExperimentSettingsWidgets( + Mantid::API::IAlgorithm_sptr alg) { + connectSettingsChange(*m_ui.optionsTable); + registerSettingWidget(*m_ui.analysisModeComboBox, "AnalysisMode", alg); + registerSettingWidget(*m_ui.startOverlapEdit, "StartOverlap", alg); + registerSettingWidget(*m_ui.endOverlapEdit, "EndOverlap", alg); + registerSettingWidget(*m_ui.polCorrComboBox, "PolarizationAnalysis", alg); + registerSettingWidget(*m_ui.CRhoEdit, "CRho", alg); + registerSettingWidget(*m_ui.CAlphaEdit, "CAlpha", alg); + registerSettingWidget(*m_ui.CApEdit, "CAp", alg); + registerSettingWidget(*m_ui.CPpEdit, "CPp", alg); + registerSettingWidget(stitchOptionsLineEdit(), "Params", alg); +} + +void ExperimentView::notifySettingsChanged() { + m_notifyee->notifySettingsChanged(); +} + +void ExperimentView::summationTypeChanged(int reductionTypeIndex) { + UNUSED_ARG(reductionTypeIndex); + m_notifyee->notifySettingsChanged(); + m_notifyee->notifySummationTypeChanged(); +} + +void ExperimentView::enableReductionType() { + m_ui.reductionTypeComboBox->setEnabled(true); +} + +void ExperimentView::disableReductionType() { + m_ui.reductionTypeComboBox->setEnabled(false); +} + +template <typename Widget> +void ExperimentView::registerSettingWidget(Widget &widget, + std::string const &propertyName, + Mantid::API::IAlgorithm_sptr alg) { + connectSettingsChange(widget); + setToolTipAsPropertyDocumentation(widget, propertyName, alg); +} + +void ExperimentView::setToolTipAsPropertyDocumentation( + QWidget &widget, std::string const &propertyName, + Mantid::API::IAlgorithm_sptr alg) { + widget.setToolTip(QString::fromStdString( + alg->getPointerToProperty(propertyName)->documentation())); +} + +void ExperimentView::setSelected(QComboBox &box, std::string const &str) { + auto const index = box.findText(QString::fromStdString(str)); + if (index != -1) + box.setCurrentIndex(index); +} + +void ExperimentView::setText(QLineEdit &lineEdit, + boost::optional<double> value) { + if (value) + setText(lineEdit, value.get()); +} + +void ExperimentView::setText(QLineEdit &lineEdit, boost::optional<int> value) { + if (value) + setText(lineEdit, value.get()); +} + +void ExperimentView::setText(QLineEdit &lineEdit, + boost::optional<std::string> const &text) { + if (text && !text->empty()) + setText(lineEdit, text); +} + +void ExperimentView::setText(QLineEdit &lineEdit, double value) { + auto valueAsString = QString::number(value); + lineEdit.setText(valueAsString); +} + +void ExperimentView::setText(QLineEdit &lineEdit, int value) { + auto valueAsString = QString::number(value); + lineEdit.setText(valueAsString); +} + +void ExperimentView::setText(QLineEdit &lineEdit, std::string const &text) { + auto textAsQString = QString::fromStdString(text); + lineEdit.setText(textAsQString); +} + +// void ExperimentView::setText(QTableWidget &table, +// std::string const &propertyName, +// boost::optional<double> value) { +// if (value) +// setText(table, propertyName, value.get()); +//} +// +// void ExperimentView::setText(QTableWidget &table, +// std::string const &propertyName, double value) { +// auto valueAsString = QString::number(value); +// setText(table, propertyName, valueAsString); +//} +// +// void ExperimentView::setText(QTableWidget &table, +// std::string const &propertyName, +// boost::optional<std::string> text) { +// if (text && !text->empty()) +// setText(table, propertyName, text.get()); +//} +// +// void ExperimentView::setText(QTableWidget &table, +// std::string const &propertyName, +// std::string const &text) { +// auto textAsQString = QString::fromStdString(text); +// setText(table, propertyName, textAsQString); +//} +// +// void ExperimentView::setText(QTableWidget &table, +// std::string const &propertyName, +// const QString &value) { +// // Find the column with this property name +// const auto columnIt = +// std::find(m_columnProperties.begin(), m_columnProperties.end(), +// QString::fromStdString(propertyName)); +// // Do nothing if column was not found +// if (columnIt == m_columnProperties.end()) +// return; +// +// const auto column = columnIt - m_columnProperties.begin(); +// +// // Set the value in this column for the first row. (We don't really know +// // which row(s) the user might want updated so for now keep it simple.) +// constexpr int row = 0; +// auto cell = table.item(row, column); +// if (!cell) { +// cell = new QTableWidgetItem(); +// table.setItem(row, column, cell); +// } +// cell->setText(value); +//} + +void ExperimentView::setChecked(QCheckBox &checkBox, bool checked) { + auto checkedAsCheckState = checked ? Qt::Checked : Qt::Unchecked; + checkBox.setCheckState(checkedAsCheckState); +} + +void ExperimentView::enablePolarisationCorrections() { + m_ui.polCorrComboBox->setEnabled(true); + m_ui.CRhoEdit->setEnabled(true); + m_ui.CAlphaEdit->setEnabled(true); + m_ui.CApEdit->setEnabled(true); + m_ui.CPpEdit->setEnabled(true); +} + +void ExperimentView::disablePolarisationCorrections() { + m_ui.polCorrComboBox->setEnabled(false); + m_ui.CRhoEdit->setEnabled(false); + m_ui.CAlphaEdit->setEnabled(false); + m_ui.CApEdit->setEnabled(false); + m_ui.CPpEdit->setEnabled(false); + + // Set polarisation corrections text to 'None' when disabled + setSelected(*m_ui.polCorrComboBox, "None"); + // Clear all parameters as well + m_ui.CRhoEdit->clear(); + m_ui.CAlphaEdit->clear(); + m_ui.CApEdit->clear(); + m_ui.CPpEdit->clear(); +} + +/** Add a new row to the transmission runs table + * */ +void ExperimentView::addPerAngleOptionsTableRow() { + auto numRows = m_ui.optionsTable->rowCount() + 1; + m_ui.optionsTable->setRowCount(numRows); + // Select the first cell in the new row + m_ui.optionsTable->setCurrentCell(numRows - 1, 0); +} + +std::string ExperimentView::getText(QLineEdit const &lineEdit) const { + return lineEdit.text().toStdString(); +} + +std::string ExperimentView::getText(QComboBox const &box) const { + return box.currentText().toStdString(); +} + +QString ExperimentView::messageFor( + InstrumentParameterTypeMissmatch const &typeError) const { + return QString::fromStdString(typeError.parameterName()) + + " should hold an " + QString::fromStdString(typeError.expectedType()) + + " value but does not.\n"; +} + +template <typename T, typename StringConverter> +std::string toCsv(std::vector<T> const &values, StringConverter toString) { + std::vector<std::string> valuesAsStrings; + valuesAsStrings.reserve(values.size()); + std::transform(values.cbegin(), values.cend(), + std::back_inserter(valuesAsStrings), toString); + return boost::algorithm::join(valuesAsStrings, ", "); +} + +QString ExperimentView::messageFor( + std::vector<MissingInstrumentParameterValue> const &missingValues) const { + auto missingNamesCsv = + toCsv(missingValues, + [](const MissingInstrumentParameterValue &missingValue) + -> std::string { return missingValue.parameterName(); }); + + return QString::fromStdString(missingNamesCsv) + + QString(missingValues.size() == 1 ? " is" : " are") + + " not set in the instrument parameter file but should be.\n"; +} + +void ExperimentView::showOptionLoadErrors( + std::vector<InstrumentParameterTypeMissmatch> const &typeErrors, + std::vector<MissingInstrumentParameterValue> const &missingValues) { + auto message = QString( + "Unable to retrieve default values for the following parameters:\n"); + + if (!missingValues.empty()) + message += messageFor(missingValues); + + for (auto &typeError : typeErrors) + message += messageFor(typeError); + + QMessageBox::warning( + this, "Failed to load one or more defaults from parameter file", message); +} + +QLineEdit &ExperimentView::stitchOptionsLineEdit() const { + return *static_cast<QLineEdit *>(m_stitchEdit); +} + +/** Creates hints for 'Stitch1DMany' +* @param hints :: Hints as a map +*/ +void ExperimentView::createStitchHints( + const std::vector<MantidWidgets::Hint> &hints) { + + // We want to add the stitch params box next to the stitch + // label, so first find the label's position + auto stitchLabelIndex = m_ui.expSettingsGrid->indexOf(m_ui.stitchLabel); + int row, col, rowSpan, colSpan; + m_ui.expSettingsGrid->getItemPosition(stitchLabelIndex, &row, &col, &rowSpan, + &colSpan); + // Create the new edit box and add it to the right of the label + m_stitchEdit = new MantidWidgets::HintingLineEdit(this, hints); + m_ui.expSettingsGrid->addWidget(m_stitchEdit, row, col + colSpan, 1, 3); +} + +double ExperimentView::getCRho() const { return m_ui.CRhoEdit->value(); } + +void ExperimentView::setCRho(double cRho) { m_ui.CRhoEdit->setValue(cRho); } + +double ExperimentView::getCAlpha() const { return m_ui.CAlphaEdit->value(); } + +void ExperimentView::setCAlpha(double cAlpha) { + m_ui.CAlphaEdit->setValue(cAlpha); +} + +double ExperimentView::getCAp() const { return m_ui.CApEdit->value(); } + +void ExperimentView::setCAp(double cAp) { m_ui.CApEdit->setValue(cAp); } + +double ExperimentView::getCPp() const { return m_ui.CPpEdit->value(); } + +void ExperimentView::setCPp(double cPp) { m_ui.CPpEdit->setValue(cPp); } + +std::string ExperimentView::getAnalysisMode() const { + return getText(*m_ui.analysisModeComboBox); +} + +void ExperimentView::setAnalysisMode(std::string const &analysisMode) { + setSelected(*m_ui.analysisModeComboBox, analysisMode); +} + +std::string ExperimentView::getSummationType() const { + return getText(*m_ui.summationTypeComboBox); +} + +void ExperimentView::setSummationType(std::string const &summationType) { + return setSelected(*m_ui.summationTypeComboBox, summationType); +} + +std::string ExperimentView::getReductionType() const { + return getText(*m_ui.reductionTypeComboBox); +} + +void ExperimentView::setReductionType(std::string const &reductionType) { + return setSelected(*m_ui.reductionTypeComboBox, reductionType); +} + +std::vector<std::array<std::string, 6>> +ExperimentView::getPerAngleOptions() const { + auto const &table = *m_ui.optionsTable; + auto rows = std::vector<std::array<std::string, 6>>(); + rows.reserve(table.rowCount()); + for (auto row = 0; row < table.rowCount(); ++row) { + rows.emplace_back( + std::array<std::string, 6>{table.item(row, 0)->text().toStdString(), + table.item(row, 1)->text().toStdString(), + table.item(row, 2)->text().toStdString(), + table.item(row, 3)->text().toStdString(), + table.item(row, 4)->text().toStdString(), + table.item(row, 5)->text().toStdString()}); + } + return rows; +} + +void ExperimentView::showPerAngleOptionsAsInvalid(int row, int column) { + m_ui.optionsTable->item(row, column)->setBackground(Qt::red); +} + +double ExperimentView::getTransmissionStartOverlap() const { + return m_ui.startOverlapEdit->value(); +} + +void ExperimentView::setTransmissionStartOverlap(double start) { + m_ui.startOverlapEdit->setValue(start); +} + +double ExperimentView::getTransmissionEndOverlap() const { + return m_ui.endOverlapEdit->value(); +} + +void ExperimentView::setTransmissionEndOverlap(double end) { + m_ui.endOverlapEdit->setValue(end); +} + +void ExperimentView::setPolarisationCorrectionType(std::string const &type) { + setSelected(*m_ui.polCorrComboBox, type); +} + +std::string ExperimentView::getPolarisationCorrectionType() const { + return getText(*m_ui.polCorrComboBox); +} + +std::string ExperimentView::getStitchOptions() const { + return getText(stitchOptionsLineEdit()); +} + +void ExperimentView::setStitchOptions(std::string const &stitchOptions) { + setText(stitchOptionsLineEdit(), stitchOptions); +} + +void showOptionLoadErrors( + std::vector<InstrumentParameterTypeMissmatch> const &typeErrors, + std::vector<MissingInstrumentParameterValue> const &missingValues); + +} // namespace CustomInterfaces +} // namespace Mantid diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentView.h new file mode 100644 index 0000000000000000000000000000000000000000..2b5a7ca1b93e5ee0347cd1abd5b42f4a0936548a --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentView.h @@ -0,0 +1,153 @@ +#ifndef MANTID_CUSTOMINTERFACES_EXPERIMENTVIEW_H_ +#define MANTID_CUSTOMINTERFACES_EXPERIMENTVIEW_H_ + +#include "DllConfig.h" +#include "ui_ExperimentWidget.h" +#include "IExperimentView.h" +#include "MantidQtWidgets/Common/HintingLineEdit.h" +#include <memory> +#include <QCheckBox> + +namespace MantidQt { +namespace CustomInterfaces { + +/** ExperiementView : Provides an interface for the "Experiement" tab in the +ISIS Reflectometry interface. + +Copyright © 2016 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid> +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class MANTIDQT_ISISREFLECTOMETRY_DLL ExperimentView + : public QWidget, + public IExperimentView { + Q_OBJECT +public: + ExperimentView(Mantid::API::IAlgorithm_sptr algorithmForTooltips, QWidget *parent = nullptr); + void subscribe(ExperimentViewSubscriber *notifyee) override; + + void + createStitchHints(const std::vector<MantidWidgets::Hint> &hints) override; + + std::string getAnalysisMode() const override; + void setAnalysisMode(std::string const& analysisMode) override; + + std::string getSummationType() const override; + void setSummationType(std::string const& summationType) override; + + std::string getReductionType() const override; + void setReductionType(std::string const& reductionType) override; + + std::vector<std::array<std::string, 6>> getPerAngleOptions() const override; + void showPerAngleOptionsAsInvalid(int row, int column) override; + + double getTransmissionStartOverlap() const override; + void setTransmissionStartOverlap(double start) override; + double getTransmissionEndOverlap() const override; + void setTransmissionEndOverlap(double end) override; + + std::string getPolarisationCorrectionType() const override; + void setPolarisationCorrectionType(std::string const& type) override; + double getCRho() const override; + void setCRho(double cRho) override; + double getCAlpha() const override; + void setCAlpha(double cAlpha) override; + double getCAp() const override; + void setCAp(double cAp) override; + double getCPp() const override; + void setCPp(double cPp) override; + + std::string getStitchOptions() const override; + void setStitchOptions(std::string const& stitchOptions) override; + + void showOptionLoadErrors( + std::vector<InstrumentParameterTypeMissmatch> const &typeErrors, + std::vector<MissingInstrumentParameterValue> const &missingValues) override; + + void disableAll() override; + void enableAll() override; + + void enableReductionType() override; + void disableReductionType() override; + + void enablePolarisationCorrections() override; + void disablePolarisationCorrections() override; + +public slots: + void notifySettingsChanged(); + /// Adds another row to the per-angle options table + void addPerAngleOptionsTableRow(); + void summationTypeChanged(int reductionTypeIndex); + +private: + QString messageFor( + std::vector<MissingInstrumentParameterValue> const &missingValues) const; + QString messageFor(const InstrumentParameterTypeMissmatch &typeError) const; + + /// Initialise the interface + void initLayout(); + void initOptionsTable(); + void registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); + void registerInstrumentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); + void registerExperimentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); + void setToolTipAsPropertyDocumentation(QWidget &widget, + std::string const &propertyName, + Mantid::API::IAlgorithm_sptr alg); + + template <typename Widget> + void registerSettingWidget(Widget &widget, std::string const &propertyName, + Mantid::API::IAlgorithm_sptr alg); + void connectSettingsChange(QLineEdit &edit); + void connectSettingsChange(QComboBox &edit); + void connectSettingsChange(QCheckBox &edit); + void connectSettingsChange(QTableWidget &edit); + void connectSettingsChange(QDoubleSpinBox &edit); + QLineEdit &stitchOptionsLineEdit() const; + void setSelected(QComboBox &box, std::string const &str); + void setText(QLineEdit &lineEdit, int value); + void setText(QLineEdit &lineEdit, double value); + void setText(QLineEdit &lineEdit, std::string const &value); + void setText(QLineEdit &lineEdit, boost::optional<int> value); + void setText(QLineEdit &lineEdit, boost::optional<double> value); + void setText(QLineEdit &lineEdit, boost::optional<std::string> const &value); +// void setText(QTableWidget &table, std::string const &propertyName, +// double value); +// void setText(QTableWidget &table, std::string const &propertyName, +// boost::optional<double> value); +// void setText(QTableWidget &table, std::string const &propertyName, +// boost::optional<std::string> value); +// void setText(QTableWidget &table, std::string const &propertyName, +// std::string const &value); +// void setText(QTableWidget &table, std::string const &propertyName, +// const QString &value); + void setChecked(QCheckBox &checkBox, bool checked); + std::string getText(QLineEdit const &lineEdit) const; + std::string getText(QComboBox const &box) const; + /// The stitch params entry widget + MantidQt::MantidWidgets::HintingLineEdit *m_stitchEdit; + + Ui::ExperimentWidget m_ui; + ExperimentViewSubscriber *m_notifyee; +}; + +} // namespace Mantid +} // namespace CustomInterfaces + +#endif /* MANTID_CUSTOMINTERFACES_EXPERIMENTVIEW_H_ */ diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui index f305fe0d5e816da24b5617c3641c5abda557b52c..43c103483aa8385470918289be3914a3a14153e8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui @@ -26,7 +26,7 @@ <property name="windowTitle"> <string>Settings Tab</string> </property> - <layout class="QVBoxLayout" name="settingsMainLayout" stretch="0"> + <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0"> <property name="leftMargin"> <number>5</number> </property> @@ -40,403 +40,442 @@ <number>5</number> </property> <item> - <widget class="QGroupBox" name="expSettingsGroup"> - <property name="title"> - <string>E&xperiment Settings</string> + <layout class="QGridLayout" name="expSettingsGrid" rowstretch="1,1,1,1,1,1,1,1,0,0,0,0" columnstretch="1,1,1,1"> + <property name="leftMargin"> + <number>10</number> </property> - <property name="checkable"> - <bool>true</bool> + <property name="topMargin"> + <number>10</number> </property> - <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,2"> - <item> - <layout class="QGridLayout" name="expSettingsGrid" rowstretch="1,1,1,1,1,1,1,1,0,0,0,0" columnstretch="1,1,1,1"> - <property name="leftMargin"> - <number>10</number> + <property name="rightMargin"> + <number>10</number> + </property> + <property name="bottomMargin"> + <number>10</number> + </property> + <item row="8" column="0"> + <widget class="QLabel" name="polCorrLabel"> + <property name="minimumSize"> + <size> + <width>117</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>PolarisationCorrections</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="perAngleTableLabel"> + <property name="text"> + <string>Per-angle defaults</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item row="3" column="1" rowspan="3" colspan="3"> + <widget class="QTableWidget" name="optionsTable"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>600</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Specify options based on the run angle. Leave the angle empty to specify defaults for all runs.</string> + </property> + <property name="whatsThis"> + <string>This table allows you to specify default values for runs that do not have values specified on the Runs tab. You can specify these on a per-angle basis, where the angle from the Runs table will be looked up in the this table and those options will be used where a match is found. You may also leave the angle blank in this table to specify the default options that should be used for all runs.</string> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + <property name="rowCount"> + <number>3</number> + </property> + <property name="columnCount"> + <number>7</number> + </property> + <attribute name="horizontalHeaderVisible"> + <bool>true</bool> + </attribute> + <attribute name="horizontalHeaderMinimumSectionSize"> + <number>40</number> + </attribute> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + <attribute name="verticalHeaderVisible"> + <bool>false</bool> + </attribute> + <row> + <property name="text"> + <string>New Row</string> + </property> + </row> + <row> + <property name="text"> + <string>New Row</string> + </property> + </row> + <row> + <property name="text"> + <string>New Row</string> + </property> + </row> + <column> + <property name="text"> + <string>Angle</string> + </property> + <property name="toolTip"> + <string/> + </property> + </column> + <column> + <property name="text"> + <string>Transmission Run(s)</string> + </property> + </column> + <column> + <property name="text"> + <string>Q min</string> + </property> + </column> + <column> + <property name="text"> + <string>Q max</string> + </property> + </column> + <column> + <property name="text"> + <string>dQ/Q</string> + </property> + </column> + <column> + <property name="text"> + <string>Scale</string> </property> - <property name="topMargin"> - <number>10</number> + </column> + <column> + <property name="text"> + <string>ProcessingInstructions</string> + </property> + </column> + </widget> + </item> + <item row="7" column="2"> + <widget class="QLabel" name="endOverlapLabel"> + <property name="minimumSize"> + <size> + <width>117</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>TransRunEndOverlap</string> + </property> + </widget> + </item> + <item row="10" column="0"> + <widget class="QLabel" name="CApLabel"> + <property name="text"> + <string>CAp</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="summationTypeComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <item> + <property name="text"> + <string>SumInLambda</string> + </property> + </item> + <item> + <property name="text"> + <string>SumInQ</string> </property> - <property name="rightMargin"> - <number>10</number> + </item> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="summationTypeLabel"> + <property name="minimumSize"> + <size> + <width>117</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>SummationType</string> + </property> + </widget> + </item> + <item row="11" column="0"> + <widget class="QLabel" name="stitchLabel"> + <property name="text"> + <string>Stitch1DMany</string> + </property> + </widget> + </item> + <item row="9" column="2"> + <widget class="QLabel" name="CAlphaLabel"> + <property name="minimumSize"> + <size> + <width>117</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>CAlpha</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="reductionTypeLabel"> + <property name="minimumSize"> + <size> + <width>117</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>ReductionType</string> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="QComboBox" name="polCorrComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <item> + <property name="text"> + <string>None</string> </property> - <property name="bottomMargin"> - <number>10</number> + </item> + <item> + <property name="text"> + <string>PA</string> </property> - <item row="8" column="0"> - <widget class="QLabel" name="polCorrLabel"> - <property name="minimumSize"> - <size> - <width>117</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>PolarisationCorrections</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="perAngleTableLabel"> - <property name="text"> - <string>Per-angle defaults</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="3" column="1" rowspan="3" colspan="3"> - <widget class="QTableWidget" name="optionsTable"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>600</width> - <height>0</height> - </size> - </property> - <property name="toolTip"> - <string>Specify options based on the run angle. Leave the angle empty to specify defaults for all runs.</string> - </property> - <property name="whatsThis"> - <string>This table allows you to specify default values for runs that do not have values specified on the Runs tab. You can specify these on a per-angle basis, where the angle from the Runs table will be looked up in the this table and those options will be used where a match is found. You may also leave the angle blank in this table to specify the default options that should be used for all runs.</string> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> - <property name="rowCount"> - <number>3</number> - </property> - <property name="columnCount"> - <number>7</number> - </property> - <attribute name="horizontalHeaderVisible"> - <bool>true</bool> - </attribute> - <attribute name="horizontalHeaderMinimumSectionSize"> - <number>40</number> - </attribute> - <attribute name="horizontalHeaderStretchLastSection"> - <bool>true</bool> - </attribute> - <attribute name="verticalHeaderVisible"> - <bool>false</bool> - </attribute> - <row> - <property name="text"> - <string>New Row</string> - </property> - </row> - <row> - <property name="text"> - <string>New Row</string> - </property> - </row> - <row> - <property name="text"> - <string>New Row</string> - </property> - </row> - <column> - <property name="text"> - <string>Angle</string> - </property> - <property name="toolTip"> - <string/> - </property> - </column> - <column> - <property name="text"> - <string>Transmission Run(s)</string> - </property> - </column> - <column> - <property name="text"> - <string>Q min</string> - </property> - </column> - <column> - <property name="text"> - <string>Q max</string> - </property> - </column> - <column> - <property name="text"> - <string>dQ/Q</string> - </property> - </column> - <column> - <property name="text"> - <string>Scale</string> - </property> - </column> - <column> - <property name="text"> - <string>ProcessingInstructions</string> - </property> - </column> - </widget> - </item> - <item row="9" column="1"> - <widget class="QLineEdit" name="CRhoEdit"/> - </item> - <item row="10" column="3"> - <widget class="QLineEdit" name="CPpEdit"/> - </item> - <item row="7" column="2"> - <widget class="QLabel" name="endOverlapLabel"> - <property name="minimumSize"> - <size> - <width>117</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>TransRunEndOverlap</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <widget class="QLineEdit" name="startOverlapEdit"/> - </item> - <item row="10" column="0"> - <widget class="QLabel" name="CApLabel"> - <property name="text"> - <string>CAp</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="summationTypeComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <item> - <property name="text"> - <string>SumInLambda</string> - </property> - </item> - <item> - <property name="text"> - <string>SumInQ</string> - </property> - </item> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="summationTypeLabel"> - <property name="minimumSize"> - <size> - <width>117</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>SummationType</string> - </property> - </widget> - </item> - <item row="10" column="1"> - <widget class="QLineEdit" name="CApEdit"/> - </item> - <item row="11" column="0"> - <widget class="QLabel" name="stitchLabel"> - <property name="text"> - <string>Stitch1DMany</string> - </property> - </widget> - </item> - <item row="9" column="2"> - <widget class="QLabel" name="CAlphaLabel"> - <property name="minimumSize"> - <size> - <width>117</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>CAlpha</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="reductionTypeLabel"> - <property name="minimumSize"> - <size> - <width>117</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>ReductionType</string> - </property> - </widget> - </item> - <item row="8" column="1"> - <widget class="QComboBox" name="polCorrComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <item> - <property name="text"> - <string>None</string> - </property> - </item> - <item> - <property name="text"> - <string>PA</string> - </property> - </item> - <item> - <property name="text"> - <string>PNR</string> - </property> - </item> - </widget> - </item> - <item row="7" column="3"> - <widget class="QLineEdit" name="endOverlapEdit"/> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="startOverlapLabel"> - <property name="text"> - <string>TransRunStartOverlap</string> - </property> - </widget> - </item> - <item row="10" column="2"> - <widget class="QLabel" name="CPpLabel"> - <property name="minimumSize"> - <size> - <width>117</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>CPp</string> - </property> - </widget> - </item> - <item row="9" column="3"> - <widget class="QLineEdit" name="CAlphaEdit"/> - </item> - <item row="9" column="0"> - <widget class="QLabel" name="CRhoLabel"> - <property name="text"> - <string>CRho</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QComboBox" name="reductionTypeComboBox"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <item> - <property name="text"> - <string>Normal</string> - </property> - </item> - <item> - <property name="text"> - <string>DivergentBeam</string> - </property> - </item> - <item> - <property name="text"> - <string>NonFlatSample</string> - </property> - </item> - </widget> - </item> - <item row="6" column="1"> - <widget class="QPushButton" name="addPerAngleOptionsButton"> - <property name="toolTip"> - <string>Add another row to the per-angle options table</string> - </property> - <property name="whatsThis"> - <string>Adds another row to the per-angle options table so that additional angles can be added</string> - </property> - <property name="text"> - <string>Add row</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="analysisModeComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <item> - <property name="text"> - <string>PointDetectorAnalysis</string> - </property> - </item> - <item> - <property name="text"> - <string>MultiDetectorAnalysis</string> - </property> - </item> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="analysisModeLabel"> - <property name="text"> - <string>AnalysisMode</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QPushButton" name="getExpDefaultsButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + </item> + <item> + <property name="text"> + <string>PNR</string> + </property> + </item> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="startOverlapLabel"> + <property name="text"> + <string>TransRunStartOverlap</string> + </property> + </widget> + </item> + <item row="10" column="2"> + <widget class="QLabel" name="CPpLabel"> + <property name="minimumSize"> + <size> + <width>117</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>CPp</string> + </property> + </widget> + </item> + <item row="9" column="0"> + <widget class="QLabel" name="CRhoLabel"> + <property name="text"> + <string>CRho</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QComboBox" name="reductionTypeComboBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <item> + <property name="text"> + <string>Normal</string> </property> - <property name="minimumSize"> - <size> - <width>71</width> - <height>32</height> - </size> + </item> + <item> + <property name="text"> + <string>DivergentBeam</string> </property> + </item> + <item> <property name="text"> - <string>Restore Defaults</string> + <string>NonFlatSample</string> </property> - <property name="fixedWidth" stdset="0"> - <number>70</number> + </item> + </widget> + </item> + <item row="6" column="1"> + <widget class="QPushButton" name="addPerAngleOptionsButton"> + <property name="toolTip"> + <string>Add another row to the per-angle options table</string> + </property> + <property name="whatsThis"> + <string>Adds another row to the per-angle options table so that additional angles can be added</string> + </property> + <property name="text"> + <string>Add row</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="analysisModeComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <item> + <property name="text"> + <string>PointDetectorAnalysis</string> </property> - <property name="fixedHeight" stdset="0"> - <number>100</number> + </item> + <item> + <property name="text"> + <string>MultiDetectorAnalysis</string> </property> - <layout class="QHBoxLayout" name="getExpDefaultsButtonLayout"/> - </widget> - </item> - </layout> + </item> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="analysisModeLabel"> + <property name="text"> + <string>AnalysisMode</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QDoubleSpinBox" name="startOverlapEdit"> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + </widget> + </item> + <item row="7" column="3"> + <widget class="QDoubleSpinBox" name="endOverlapEdit"> + <property name="decimals"> + <number>5</number> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="QDoubleSpinBox" name="CRhoEdit"> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="9" column="3"> + <widget class="QDoubleSpinBox" name="CAlphaEdit"> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="10" column="1"> + <widget class="QDoubleSpinBox" name="CApEdit"> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="10" column="3"> + <widget class="QDoubleSpinBox" name="CPpEdit"> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>100000.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="getExpDefaultsButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>71</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string>Restore Defaults</string> + </property> + <property name="fixedWidth" stdset="0"> + <number>70</number> + </property> + <property name="fixedHeight" stdset="0"> + <number>100</number> + </property> + <layout class="QHBoxLayout" name="getExpDefaultsButtonLayout"/> </widget> </item> </layout> diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..a4d93fcf8b81b477e408e0ca435a68a2d3794a3c --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentPresenter.h @@ -0,0 +1,42 @@ +#ifndef MANTID_ISISREFLECTOMETRY_IEXPERIMENTPRESENTER_H +#define MANTID_ISISREFLECTOMETRY_IEXPERIMENTPRESENTER_H + +#include <string> +#include "../../IReflBatchPresenter.h" + +namespace MantidQt { +namespace CustomInterfaces { + +/** @class IEventPresenter + +IReflEventPresenter is an interface which defines the functions that need +to be implemented by a concrete 'Event' presenter + +Copyright © 2011-16 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class IExperimentPresenter { +public: + virtual ~IExperimentPresenter() = default; +}; +} +} +#endif /* MANTID_ISISREFLECTOMETRY_IEXPERIMENTPRESENTER_H */ diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentView.h new file mode 100644 index 0000000000000000000000000000000000000000..b7dd4415fcf1d2326464dde6ad6bd72d59764b10 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/IExperimentView.h @@ -0,0 +1,104 @@ +#ifndef MANTID_ISISREFLECTOMETRY_IEXPERIMENTVIEW_H +#define MANTID_ISISREFLECTOMETRY_IEXPERIMENTVIEW_H + +#include "DllConfig.h" +#include "ExperimentOptionDefaults.h" +#include "GetInstrumentParameter.h" +#include "InstrumentOptionDefaults.h" +#include "InstrumentParameters.h" +#include "MantidAPI/Algorithm.h" +#include "MantidQtWidgets/Common/DataProcessorUI/OptionsQMap.h" +#include "MantidQtWidgets/Common/Hint.h" +#include <map> +#include <vector> +#include "IReflSettingsTabPresenter.h" + +namespace MantidQt { +namespace CustomInterfaces { + +/** @class IEventView + +IReflSettingsView is the base view class for the Reflectometry settings. It +contains no QT specific functionality as that should be handled by a subclass. + +Copyright © 2011-16 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid>. +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ + +class MANTIDQT_ISISREFLECTOMETRY_DLL ExperimentViewSubscriber { +public: + virtual void notifySettingsChanged() = 0; + virtual void notifySummationTypeChanged() = 0; +}; + +class MANTIDQT_ISISREFLECTOMETRY_DLL IExperimentView { +public: + virtual void subscribe(ExperimentViewSubscriber *notifyee) = 0; + virtual void + createStitchHints(const std::vector<MantidWidgets::Hint> &hints) = 0; + + virtual std::string getAnalysisMode() const = 0; + virtual void setAnalysisMode(std::string const& analysisMode) = 0; + + virtual std::string getSummationType() const = 0; + virtual void setSummationType(std::string const& summationType) = 0; + + virtual std::string getReductionType() const = 0; + virtual void setReductionType(std::string const& reductionType) = 0; + virtual void enableReductionType() = 0; + virtual void disableReductionType() = 0; + + virtual std::vector<std::array<std::string, 6>> getPerAngleOptions() const = 0; + virtual void showPerAngleOptionsAsInvalid(int row, int column) = 0; + + virtual void enablePolarisationCorrections() = 0; + virtual void disablePolarisationCorrections() = 0; + + virtual double getTransmissionStartOverlap() const = 0; + virtual void setTransmissionStartOverlap(double start) = 0; + virtual double getTransmissionEndOverlap() const = 0; + virtual void setTransmissionEndOverlap(double end) = 0; + + virtual std::string getPolarisationCorrectionType() const = 0; + virtual void setPolarisationCorrectionType(std::string const& type) = 0; + virtual double getCRho() const = 0; + virtual void setCRho(double cRho) = 0; + virtual double getCAlpha() const = 0; + virtual void setCAlpha(double cAlpha) = 0; + virtual double getCAp() const = 0; + virtual void setCAp(double cAp) = 0; + virtual double getCPp() const = 0; + virtual void setCPp(double cPp) = 0; + + virtual std::string getStitchOptions() const = 0; + virtual void setStitchOptions(std::string const& stitchOptions) = 0; + + virtual void showOptionLoadErrors( + std::vector<InstrumentParameterTypeMissmatch> const &typeErrors, + std::vector<MissingInstrumentParameterValue> const &missingValues) = 0; + + virtual void disableAll() = 0; + virtual void enableAll() = 0; + virtual ~IExperimentView() = default; +}; +} +} +#endif /* MANTID_ISISREFLECTOMETRY_IEXPERIMENTVIEW_H */ diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h b/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h index b9b53e5a17418024668cc7bed314f288dc7d77a2..ada5c2b3dc3e55143abee0bf25fe38d071d76f2d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflBatchView.h @@ -5,6 +5,7 @@ #include "IReflRunsTabView.h" #include "IReflSettingsTabView.h" #include "GUI/Event/IEventView.h" +#include "GUI/Experiment/IExperimentView.h" #include "IReflSaveTabView.h" namespace MantidQt { @@ -44,6 +45,7 @@ public: virtual IEventView* eventHandling() const = 0; virtual IReflSettingsTabView* settings() const = 0; virtual IReflSaveTabView* save() const = 0; + virtual IExperimentView* experiment() const = 0; virtual ~IReflBatchView() = default; }; } diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp index 87bc10d76fa5e1cf37f47a563aa08093145e30e8..d345fd9bce27f646b3e805c6a823c9097aa5d502 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.cpp @@ -33,6 +33,13 @@ void QtReflBatchView::initLayout() { m_save = createSaveTab(); m_ui.batchTabs->addTab(m_save.get(), "Save ASCII"); + + m_experiment = Mantid::Kernel::make_unique<ExperimentView>(createReductionAlg(), this); + m_ui.batchTabs->addTab(m_experiment.get(), "Experiment Settings"); +} + +IExperimentView* QtReflBatchView::experiment() const { + return m_experiment.get(); } IReflRunsTabView *QtReflBatchView::runs() const { return m_runs.get(); } diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h index 71a4cbc2c672c8718582198611ef410c31785db1..61dd722cb69bc2ebe83b773d45a90af53df0cf83 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflBatchView.h @@ -7,6 +7,7 @@ #include <memory> #include "QtReflSaveTabView.h" #include "GUI/Event/EventView.h" +#include "GUI/Experiment/ExperimentView.h" #include "QtReflSettingsTabView.h" #include "QtReflRunsTabView.h" #include "MantidAPI/IAlgorithm.h" @@ -48,6 +49,7 @@ public: IEventView *eventHandling() const override; IReflSettingsTabView *settings() const override; IReflSaveTabView *save() const override; + IExperimentView* experiment() const override; private: void initLayout(); @@ -64,6 +66,7 @@ private: std::unique_ptr<EventView> m_eventHandling; std::unique_ptr<QtReflSettingsTabView> m_settings; std::unique_ptr<QtReflSaveTabView> m_save; + std::unique_ptr<ExperimentView> m_experiment; }; } } diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp b/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp index 33d67315b4eb4e8cfd611e9f5e37ae5326174f3f..58acdeb03c397bf696f475aac6b84c9a2b282a5d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp @@ -12,8 +12,7 @@ namespace CustomInterfaces { DECLARE_SUBWINDOW(QtReflMainWindowView) QtReflMainWindowView::QtReflMainWindowView(QWidget *parent) - : UserSubWindow(parent) { -} + : UserSubWindow(parent) {} IReflBatchView *QtReflMainWindowView::newBatch() { auto index = m_ui.mainTabs->count(); @@ -40,7 +39,8 @@ void QtReflMainWindowView::initLayout() { connect(m_ui.helpButton, SIGNAL(clicked()), this, SLOT(helpPressed())); connect(m_ui.mainTabs, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabCloseRequested(int))); - connect(m_ui.newBatch, SIGNAL(triggered(bool)), this, SLOT(onNewBatchRequested(bool))); + connect(m_ui.newBatch, SIGNAL(triggered(bool)), this, + SLOT(onNewBatchRequested(bool))); auto instruments = std::vector<std::string>( {{"INTER", "SURF", "CRISP", "POLREF", "OFFSPEC"}}); @@ -48,8 +48,8 @@ void QtReflMainWindowView::initLayout() { auto defaultSlicing = Slicing(); auto thetaTolerance = 0.01; auto makeWorkspaceNames = WorkspaceNamesFactory(defaultSlicing); - auto makeBatchPresenter = - RunsTablePresenterFactory(instruments, thetaTolerance, makeWorkspaceNames); + auto makeBatchPresenter = RunsTablePresenterFactory( + instruments, thetaTolerance, makeWorkspaceNames); auto defaultInstrumentIndex = 0; // TODO: Look this up properly; auto searcher = boost::shared_ptr<IReflSearcher>(); @@ -61,9 +61,12 @@ void QtReflMainWindowView::initLayout() { auto makeSettingsPresenter = SettingsPresenterFactory(); auto makeSaveSettingsPresenter = SavePresenterFactory(); + auto makeExperimentPresenter = ExperimentPresenterFactory(); + auto makeReflBatchPresenter = ReflBatchPresenterFactory( std::move(makeRunsPresenter), std::move(makeEventPresenter), - std::move(makeSettingsPresenter), std::move(makeSaveSettingsPresenter)); + std::move(makeExperimentPresenter), std::move(makeSettingsPresenter), + std::move(makeSaveSettingsPresenter)); // Create the presenter m_presenter = diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/AnalysisMode.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/AnalysisMode.h index df94dece87663da06b20ab9dc6a0adbfa4f312f3..95184b7a650b9a597659aa5639c307502642fbd0 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/AnalysisMode.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/AnalysisMode.h @@ -1,8 +1,19 @@ #ifndef MANTID_CUSTOMINTERFACES_ANALYSISMODE_H_ #define MANTID_CUSTOMINTERFACES_ANALYSISMODE_H_ +#include <stdexcept> +#include <string> namespace MantidQt { namespace CustomInterfaces { enum class AnalysisMode { PointDetector, MultiDetector }; + +inline AnalysisMode analysisModeFromString(std::string const& analysisMode) { + if (analysisMode == "PointDetectorAnalysis") + return AnalysisMode::PointDetector; + else if (analysisMode == "MultiDetectorAnalysis") + return AnalysisMode::MultiDetector; + else + throw std::runtime_error("Unexpected analysis mode."); +} } } #endif // MANTID_CUSTOMINTERFACES_ANALYSISMODE_H_ diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp index 8543603e340f9c5e50903de9be24b963a678cdb8..d3820de06354a82a3d752b41470b02d1331986f7 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.cpp @@ -1,4 +1,6 @@ #include "Experiment.h" +#include <cmath> + namespace MantidQt { namespace CustomInterfaces { @@ -7,42 +9,38 @@ Experiment::Experiment(AnalysisMode analysisMode, ReductionType reductionType, PolarizationCorrections polarizationCorrections, RangeInLambda transmissionRunRange, std::string stitchParameters, - std::vector<RowTemplate> rowTemplate) + std::vector<RowTemplate> rowTemplates) : m_analysisMode(analysisMode), m_reductionType(reductionType), m_summationType(summationType), - m_polarizatioCorrections(polarizationCorrections), m_transmissionRuns(transmissionRunRange), + m_polarizationCorrections(std::move(polarizationCorrections)), + m_transmissionRunRange(std::move(transmissionRunRange)), m_stitchParameters(std::move(stitchParameters)), m_rowTemplates(std::move(rowTemplates)) {} -AnalysisMode Experiment::analysisMode() const { - return m_analysisMode; -} -ReductionType reductionType() const { - return m_reductionType; -} -SummationType summationType() const { - return m_summationType; -} -PolarizationCorrections const &polarizationCorrections() const { +AnalysisMode Experiment::analysisMode() const { return m_analysisMode; } +ReductionType Experiment::reductionType() const { return m_reductionType; } +SummationType Experiment::summationType() const { return m_summationType; } +PolarizationCorrections const &Experiment::polarizationCorrections() const { return m_polarizationCorrections; } -RangeInLambda const &transissionRunRange() const { +RangeInLambda const &Experiment::transissionRunRange() const { return m_transmissionRunRange; } -std::string stitchParameters() const { - return m_stitchParameters; -} -std::vector<RowTemplate> const &rowTemplates() const { +std::string Experiment::stitchParameters() const { return m_stitchParameters; } +std::vector<RowTemplate> const &Experiment::rowTemplates() const { return m_rowTemplates; } -RowTemplate const* rowTemplateForTheta(double thetaAngle, double tolerance) const { - auto smallestIt = std::min_element(m_rowTemplates, [thetaAngle](RowTemplate const& lhs, RowTemplate const& rhs) -> bool { - return std::abs(thetaAngle - lhs.theta()); - }); +RowTemplate const *Experiment::rowTemplateForTheta(double thetaAngle, + double tolerance) const { + auto smallestIt = std::min_element( + m_rowTemplates.cbegin(), + m_rowTemplates.cend(), + [thetaAngle](RowTemplate const &lhs, RowTemplate const &rhs) + -> bool { return std::abs(thetaAngle - lhs.theta()) < std::abs(thetaAngle - rhs.theta()); }); - auto const* closestCandidate = &(*smallestIt); + auto const *closestCandidate = &(*smallestIt); if (std::abs(thetaAngle - closestCandidate->theta()) <= tolerance) { return closestCandidate; } else { diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h index 5d14064e22dc6f5b7e993254a0621ea74528163e..a47c1c6a636d89934944cad47c26fac1e89bc79c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Experiment.h @@ -21,6 +21,14 @@ File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ #include "../DllConfig.h" +#include "AnalysisMode.h" +#include "ReductionType.h" +#include "SummationType.h" +#include "PolarizationCorrections.h" +#include "RangeInLambda.h" +#include "RowTemplate.h" +#include <string> +#include <vector> namespace MantidQt { namespace CustomInterfaces { @@ -31,7 +39,7 @@ public: SummationType summationType, PolarizationCorrections polarizationCorrections, RangeInLambda transmissionRunRange, - std::string const &stitchParameters, + std::string stitchParameters, std::vector<RowTemplate> rowTemplate); AnalysisMode analysisMode() const; @@ -42,7 +50,7 @@ public: std::string stitchParameters() const; std::vector<RowTemplate> const &rowTemplates() const; - RowTemplate const *rowTemplateForTheta(double thetaAngle) const; + RowTemplate const *rowTemplateForTheta(double thetaAngle, double tolerance) const; private: AnalysisMode m_analysisMode; @@ -52,7 +60,7 @@ private: PolarizationCorrections m_polarizationCorrections; RangeInLambda m_transmissionRunRange; - std::string m_stitchParams; + std::string m_stitchParameters; std::vector<RowTemplate> m_rowTemplates; }; } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionOptionsMap.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionOptionsMap.h new file mode 100644 index 0000000000000000000000000000000000000000..1004c3375c35b963928856e5faf0cd5a7b297dd4 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionOptionsMap.h @@ -0,0 +1,9 @@ +#ifndef MANTID_CUSTOMINTERFACES_REDUCTIONOPTIONSMAP_H_ +#define MANTID_CUSTOMINTERFACES_REDUCTIONOPTIONSMAP_H_ +#include <map> +namespace MantidQt { +namespace CustomInterfaces { +using ReductionOptionsMap = std::map<std::string, std::string>; +} +} +#endif // MANTID_CUSTOMINTERFACES_REDUCTIONOPTIONSMAP_H_ diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionType.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionType.h index c51af2fd788262ac3bb940db6be39c152835efdd..f90b3b543fe81a79b93e926a65ee4bf712b1274b 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionType.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionType.h @@ -1,9 +1,21 @@ #ifndef MANTID_CUSTOMINTERFACES_REDUCTIONTYPE_H_ #define MANTID_CUSTOMINTERFACES_REDUCTIONTYPE_H_ #include "../DllConfig.h" +#include <boost/optional.hpp> namespace MantidQt { namespace CustomInterfaces { -enum class ReductionType { DivergentBeam, NonFlatSample }; +enum class ReductionType { DivergentBeam, NonFlatSample, Normal }; + +inline ReductionType reductionTypeFromString(std::string const &reductionType) { + if (reductionType == "Normal") + return ReductionType::Normal; + else if (reductionType == "DivergentBeam") + return ReductionType::DivergentBeam; + else if (reductionType == "NonFlatSample") + return ReductionType::NonFlatSample; + else + throw std::runtime_error("Unexpected reduction type."); +} } } #endif // MANTID_CUSTOMINTERFACES_REDUCTIONTYPE_H_ diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/Row.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/Row.h index f7d32038f032c9d23b8f876ed2206de17377f5af..b540912b5d71a9557ef96971ebbbb3bb0bb309a2 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/Row.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/Row.h @@ -24,7 +24,6 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> #define MANTID_CUSTOMINTERFACES_RUN_H_ #include <string> #include <vector> -#include <map> #include <boost/variant.hpp> #include <boost/range/algorithm/set_algorithm.hpp> #include <boost/optional.hpp> @@ -32,13 +31,13 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> #include "WorkspaceNamesFactory.h" #include "ReductionWorkspaces.h" #include "SlicedReductionWorkspaces.h" +#include "ReductionOptionsMap.h" #include "Slicing.h" #include "../DllConfig.h" namespace MantidQt { namespace CustomInterfaces { -using ReductionOptionsMap = std::map<std::string, std::string>; // Immutability here makes update notification easier. template <typename ReducedWorkspaceNames> diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.cpp index 95d1f308409d4ed105721e52eae0962fef7ff896..7cc2091136f9da91dbebadd148191c4dfd3c1b92 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.cpp @@ -8,15 +8,11 @@ RowTemplate::RowTemplate(double theta, boost::optional<RangeInQ> qRange, boost::optional<double> scaleFactor, ReductionOptionsMap reductionOptions) - : m_theta(std::move(theta)), m_qRange(std::move(qRange)), - m_scaleFactor(std::move(scaleFactor)), + : m_theta(std::move(theta)), m_transmissionRuns(std::move(transmissionRuns)), + m_qRange(std::move(qRange)), m_scaleFactor(std::move(scaleFactor)), m_reductionOptions(std::move(reductionOptions)) {} -std::vector<std::string> const &RowTemplate::runNumbers() const { - return m_runNumbers; -} - std::pair<std::string, std::string> const & RowTemplate::transmissionWorkspaceNames() const { return m_transmissionRuns; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.h index 138743d3d0a692b450078d11d80cfd2e1571ed64..a21b8ecdcf33970c429e5aabc67a9cd2ef45a3bd 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/RowTemplate.h @@ -1,16 +1,19 @@ #ifndef MANTID_CUSTOMINTERFACES_ROWTEMPLATE_H_ #define MANTID_CUSTOMINTERFACES_ROWTEMPLATE_H_ #include <boost/optional.hpp> +#include "ReductionOptionsMap.h" #include "RangeInQ.h" #include "../DllConfig.h" +#include <vector> namespace MantidQt { namespace CustomInterfaces { class MANTIDQT_ISISREFLECTOMETRY_DLL RowTemplate { public: RowTemplate(double theta, std::pair<std::string, std::string> tranmissionRuns, - boost::optional<RangeInQ> qRange, boost::optional<double> scaleFactor, - ReductionOptionsMap reductionOptions); + boost::optional<RangeInQ> qRange, + boost::optional<double> scaleFactor, + ReductionOptionsMap reductionOptions); std::pair<std::string, std::string> const &transmissionWorkspaceNames() const; double theta() const; @@ -25,7 +28,6 @@ private: boost::optional<double> m_scaleFactor; ReductionOptionsMap m_reductionOptions; }; - } } #endif // MANTID_CUSTOMINTERFACES_ROWTEMPLATE_H_ diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/SummationType.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/SummationType.h index a08f629a35f13b09e26a19ee56125ddb509b6619..af8f84baf3a596d91209e8cb1aea41d6aaf54d57 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/SummationType.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/SummationType.h @@ -1,10 +1,22 @@ #ifndef MANTID_CUSTOMINTERFACES_SUMMATIONTYPE_H_ #define MANTID_CUSTOMINTERFACES_SUMMATIONTYPE_H_ +#include <string> +#include <stdexcept> +#include <boost/optional.hpp> + namespace MantidQt { namespace CustomInterfaces { enum class SummationType { SumInLambda, SumInQ }; +inline SummationType summationTypeFromString(std::string const& summationType) { + if (summationType == "SumInLambda") + return SummationType::SumInLambda; + else if (summationType == "SumInQ") + return SummationType::SumInQ; + else + throw std::runtime_error("Unexpected summation type."); +} } } #endif // MANTID_CUSTOMINTERFACES_SUMMATIONTYPE_H_ diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp index 645812655f636a5cb40c89c6cbf88846e540f418..9882e3d5bb26703b146d144235bc113ac5bb5cb5 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.cpp @@ -22,11 +22,13 @@ namespace CustomInterfaces { ReflBatchPresenter::ReflBatchPresenter( IReflBatchView *view, std::unique_ptr<IReflRunsTabPresenter> runsPresenter, std::unique_ptr<IEventPresenter> eventPresenter, + std::unique_ptr<IExperimentPresenter> experimentPresenter, std::unique_ptr<IReflSettingsTabPresenter> settingsPresenter, std::unique_ptr<IReflSaveTabPresenter> savePresenter) : m_view(view), m_runsPresenter(std::move(runsPresenter)), m_eventPresenter(std::move(eventPresenter)), m_settingsPresenter(std::move(settingsPresenter)), + m_experimentPresenter(std::move(experimentPresenter)), m_savePresenter(std::move(savePresenter)) { // Tell the tab presenters that this is going to be the main presenter diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h index 46062d0df679ce0169fc1a44d4b962711d9d9403..69caa81da438968670fc691b6450d59e7983fcb9 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenter.h @@ -3,6 +3,7 @@ #include "DllConfig.h" #include "IReflBatchPresenter.h" +#include "GUI/Experiment/IExperimentPresenter.h" #include <memory> namespace MantidQt { @@ -47,6 +48,7 @@ public: ReflBatchPresenter(IReflBatchView *view, std::unique_ptr<IReflRunsTabPresenter> runsPresenter, std::unique_ptr<IEventPresenter> eventPresenter, + std::unique_ptr<IExperimentPresenter> experimentPresenter, std::unique_ptr<IReflSettingsTabPresenter> settingsPresenter, std::unique_ptr<IReflSaveTabPresenter> savePresenter); @@ -93,6 +95,7 @@ private: std::unique_ptr<IEventPresenter> m_eventPresenter; /// The presenter of tab 'Settings' std::unique_ptr<IReflSettingsTabPresenter> m_settingsPresenter; + std::unique_ptr<IExperimentPresenter> m_experimentPresenter; /// The presenter of tab 'Save ASCII' std::unique_ptr<IReflSaveTabPresenter> m_savePresenter; }; diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h index 630ee4c8e84e8fbc859597f2a5b541de6675d025..23a2150f2185f4a6e94637ae30dc7209b59de366 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflBatchPresenterFactory.h @@ -6,6 +6,7 @@ #include "ReflRunsPresenterFactory.h" #include "ReflSavePresenterFactory.h" #include "ReflSettingsPresenterFactory.h" +#include "GUI/Experiment/ExperimentPresenterFactory.h" #include "GUI/Event/EventPresenterFactory.h" #include "ReflBatchPresenter.h" #include <memory> @@ -17,26 +18,33 @@ public: ReflBatchPresenterFactory( RunsPresenterFactory runsPresenterFactory, EventPresenterFactory eventPresenterFactory, + ExperimentPresenterFactory experimentPresenterFactory, SettingsPresenterFactory settingsPresenterFactory, SavePresenterFactory savePresenterFactory) - : m_runsPresenterFactory(std::move(runsPresenterFactory)), - m_eventPresenterFactory(std::move(eventPresenterFactory)), - m_settingsPresenterFactory(std::move(settingsPresenterFactory)), - m_savePresenterFactory(std::move(savePresenterFactory)) {} + : m_runsPresenterFactory(std::move(runsPresenterFactory)), + m_eventPresenterFactory(std::move(eventPresenterFactory)), + m_experimentPresenterFactory(std::move(experimentPresenterFactory)), + m_settingsPresenterFactory(std::move(settingsPresenterFactory)), + m_savePresenterFactory(std::move(savePresenterFactory)) {} std::unique_ptr<IReflBatchPresenter> make(IReflBatchView *view) { auto runsPresenter = m_runsPresenterFactory.make(view->runs()); auto eventPresenter = m_eventPresenterFactory.make(view->eventHandling()); + auto experimentPresenter = + m_experimentPresenterFactory.make(view->experiment()); auto settingsPresenter = m_settingsPresenterFactory.make(view->settings()); auto savePresenter = m_savePresenterFactory.make(view->save()); return std::make_unique<ReflBatchPresenter>( view, std::move(runsPresenter), std::move(eventPresenter), - std::move(settingsPresenter), std::move(savePresenter)); + std::move(experimentPresenter), std::move(settingsPresenter), + std::move(savePresenter)); } + private: RunsPresenterFactory m_runsPresenterFactory; EventPresenterFactory m_eventPresenterFactory; + ExperimentPresenterFactory m_experimentPresenterFactory; SettingsPresenterFactory m_settingsPresenterFactory; SavePresenterFactory m_savePresenterFactory; };