Skip to content
Snippets Groups Projects
Unverified Commit ece6114c authored by Anthony's avatar Anthony Committed by GitHub
Browse files

Merge branch 'release-v3.12' into 22031_phaseQuadGUI

parents 0463b4bc be5642e3
Branches 22031_phaseQuadGUI
No related tags found
No related merge requests found
Showing
with 252 additions and 174 deletions
......@@ -25,12 +25,14 @@ Interface
- The period display no longer becomes blank when changing the period selection in multiple fitting mode.
- The group/pair selection in Muon Analysis no longer resets when changing tabs or loading data.
- The Frequency Domain Analysis GUI now uses :ref:`CalMuonDetectorPhases <algm-CalMuonDetectorPhases>` to create the phase table for PhaseQuad FFTs.
- The Frequency Domain Analysis GUI now uses :ref:`MuonMaxent <algm-MuonMaxent>` to calculate the frequency spectrum in MaxEnt mode.
- The ALC interface now allows background sections with negative values.
- The period summation/subtraction can now be used in multiple fitting.
- The Frequency Domain Analysis GUI now uses :ref:`MuonMaxent <algm-MuonMaxent>` to calculate the frequency spectrum in MaxEnt mode.
- The ALC interface now allows background sections with negative values.
- If data is loaded with 0 good frames into Muon Analysis then it will try to load the data without dead time correction (does not need number of good frames).
- Muon analysis no longer disables the "co add" and "simultaneous" buttons in the multiple fitting interface.
- Frequency domain analysis will reload the data if the active workspace has changed.
- Muon analysis no longer crashes when using the browse button in sequential fitting.
- The period summation/subtraction can now be used in multiple fitting.
- Muon analysis now handles the "auto background" gracefully in single and multiple fitting modes.
Algorithms
----------
......
......@@ -12,7 +12,7 @@ ISIS Reflectometry Interface
New features
############
- A new table has been added to the Settings tab to allow default transmission runs to be specified on a per-angle basis. If a row in the Runs tab contains an angle, it will be looked up in this table and those transmission runs will be used if a matching angle is found (the angle does not have to be exact as it will match to within 100th of a degree). If you want to specify transmission runs that will be used by default for all runs, then simply leave the angle empty.
- A new table has been added to the Settings tab to allow default options to be specified on a per-angle basis. If a row in the Runs tab contains an angle, it will be looked up in this table and those options will be used if a matching angle is found (the angle does not have to be exact as it will match to within 100th of a degree). If you want to specify values that will be used by default for all runs, then simply leave the angle empty.
- Two new boxes have been added to the settings tab of the ISIS Reflectometry interface, 'ReductionType' and 'SummationType' which are passed to the corresponding parameters of :ref:`algm-ReflectometryReductionOneAuto`.
- The ISIS Reflectometry interface now has a checkbox 'CorrectDetectors' which maps to the corresponding property in :ref:`algm-ReflectometryReductionOneAuto`.
- The 'Get Defaults' button now looks for values for the following additional properties in the IDF:
......
......@@ -11,8 +11,11 @@ bool operator==(const ExperimentOptionDefaults &lhs,
lhs.CAp == rhs.CAp && lhs.CPp == rhs.CPp &&
lhs.TransRunStartOverlap == rhs.TransRunStartOverlap &&
lhs.TransRunEndOverlap == rhs.TransRunEndOverlap &&
lhs.MomentumTransferMin == rhs.MomentumTransferMin &&
lhs.MomentumTransferMax == rhs.MomentumTransferMax &&
lhs.MomentumTransferStep == rhs.MomentumTransferStep &&
lhs.ScaleFactor == rhs.ScaleFactor &&
lhs.ProcessingInstructions == rhs.ProcessingInstructions &&
lhs.ReductionType == rhs.ReductionType &&
lhs.SummationType == rhs.SummationType &&
lhs.StitchParams == rhs.StitchParams;
......@@ -30,10 +33,16 @@ std::ostream &operator<<(std::ostream &os,
os << "',\nTransRunStartOverlap: " << defaults.TransRunStartOverlap.get();
if (defaults.TransRunEndOverlap)
os << ",\nTransRunEndOverlap: " << defaults.TransRunEndOverlap.get();
if (defaults.MomentumTransferMin)
os << ",\nMomentumTransferMin: " << defaults.MomentumTransferMin.get();
if (defaults.MomentumTransferMax)
os << ",\nMomentumTransferMax: " << defaults.MomentumTransferMax.get();
if (defaults.MomentumTransferStep)
os << ",\nMomentumTransferStep: " << defaults.MomentumTransferStep.get();
if (defaults.ScaleFactor)
os << ",\nScaleFactor: " << defaults.ScaleFactor.get();
if (defaults.ProcessingInstructions)
os << ",\nScaleFactor: " << defaults.ProcessingInstructions.get();
if (defaults.StitchParams)
os << ", \nStitchParams: '" << defaults.StitchParams.get();
os << "' }" << std::endl;
......
......@@ -19,8 +19,11 @@ struct MANTIDQT_ISISREFLECTOMETRY_DLL ExperimentOptionDefaults {
std::string CPp;
boost::optional<double> TransRunStartOverlap;
boost::optional<double> TransRunEndOverlap;
boost::optional<double> MomentumTransferMin;
boost::optional<double> MomentumTransferMax;
boost::optional<double> MomentumTransferStep;
boost::optional<double> ScaleFactor;
boost::optional<std::string> ProcessingInstructions;
boost::optional<std::string> StitchParams;
};
......
......@@ -50,10 +50,10 @@ public:
virtual void notifyReductionResumed(int group) = 0;
/// Transmission runs for a specific run angle
virtual std::string getTransmissionRunsForAngle(int group,
const double angle) const = 0;
virtual MantidWidgets::DataProcessor::OptionsQMap
getOptionsForAngle(int group, const double angle) const = 0;
/// Whether there are per-angle transmission runs specified
virtual bool hasPerAngleTransmissionRuns(int group) const = 0;
virtual bool hasPerAngleOptions(int group) const = 0;
/// Pre-processing
virtual MantidWidgets::DataProcessor::OptionsQMap
getTransmissionOptions(int group) const = 0;
......
......@@ -42,9 +42,10 @@ class IReflSettingsPresenter {
public:
virtual ~IReflSettingsPresenter(){};
/// Transmission runs for a particular angle
virtual std::string getTransmissionRunsForAngle(const double angle) const = 0;
virtual MantidWidgets::DataProcessor::OptionsQMap
getOptionsForAngle(const double angle) const = 0;
/// Whether per-angle transmission runs are set
virtual bool hasPerAngleTransmissionRuns() const = 0;
virtual bool hasPerAngleOptions() const = 0;
/// Pre-processing
virtual MantidWidgets::DataProcessor::OptionsQMap
getTransmissionOptions() const = 0;
......
......@@ -40,10 +40,10 @@ class IReflSettingsTabPresenter {
public:
virtual ~IReflSettingsTabPresenter(){};
/// Transmission runs for a particular run angle
virtual std::string getTransmissionRunsForAngle(int group,
const double angle) const = 0;
virtual MantidWidgets::DataProcessor::OptionsQMap
getOptionsForAngle(int group, const double angle) const = 0;
/// Whether per-angle transmission runs are specified
virtual bool hasPerAngleTransmissionRuns(int group) const = 0;
virtual bool hasPerAngleOptions(int group) const = 0;
/// Pre-processing
virtual MantidWidgets::DataProcessor::OptionsQMap
getTransmissionOptions(int group) const = 0;
......
......@@ -2,13 +2,14 @@
#define MANTID_ISISREFLECTOMETRY_IREFLSETTINGSVIEW_H
#include "DllConfig.h"
#include <map>
#include <vector>
#include "MantidAPI/Algorithm.h"
#include "ExperimentOptionDefaults.h"
#include "InstrumentOptionDefaults.h"
#include "GetInstrumentParameter.h"
#include "InstrumentOptionDefaults.h"
#include "InstrumentParameters.h"
#include "MantidAPI/Algorithm.h"
#include "MantidQtWidgets/Common/DataProcessorUI/OptionsQMap.h"
#include <map>
#include <vector>
namespace MantidQt {
namespace CustomInterfaces {
......@@ -58,7 +59,9 @@ public:
/// Experiment settings
virtual std::string getAnalysisMode() const = 0;
virtual std::map<std::string, std::string> getTransmissionRuns() const = 0;
virtual std::map<std::string,
MantidQt::MantidWidgets::DataProcessor::OptionsQMap>
getPerAngleOptions() const = 0;
virtual std::string getStartOverlap() const = 0;
virtual std::string getEndOverlap() const = 0;
virtual std::string getPolarisationCorrections() const = 0;
......@@ -66,8 +69,6 @@ public:
virtual std::string getCAlpha() const = 0;
virtual std::string getCAp() const = 0;
virtual std::string getCPp() const = 0;
virtual std::string getMomentumTransferStep() const = 0;
virtual std::string getScaleFactor() const = 0;
/// Instrument settings
virtual std::string getIntMonCheck() const = 0;
virtual std::string getMonitorIntegralMin() const = 0;
......@@ -77,7 +78,6 @@ public:
virtual std::string getLambdaMin() const = 0;
virtual std::string getLambdaMax() const = 0;
virtual std::string getI0MonitorIndex() const = 0;
virtual std::string getProcessingInstructions() const = 0;
virtual std::string getDetectorCorrectionType() const = 0;
virtual std::string getSummationType() const = 0;
virtual std::string getReductionType() const = 0;
......
......@@ -12,7 +12,6 @@ bool operator==(InstrumentOptionDefaults const &lhs,
lhs.MonitorBackgroundMin == rhs.MonitorBackgroundMin &&
lhs.LambdaMin == rhs.LambdaMin && lhs.LambdaMax == rhs.LambdaMax &&
lhs.I0MonitorIndex == rhs.I0MonitorIndex &&
lhs.ProcessingInstructions == rhs.ProcessingInstructions &&
lhs.DetectorCorrectionType == rhs.DetectorCorrectionType;
}
......@@ -29,9 +28,6 @@ std::ostream &operator<<(std::ostream &os,
<< ",\n I0MonitorIndex: " << defaults.I0MonitorIndex
<< ",\n CorrectDetectors: "
<< (defaults.CorrectDetectors ? "true" : "false");
if (defaults.ProcessingInstructions)
os << ",\n ProcessingInstructions: '"
<< defaults.ProcessingInstructions.get() << "'";
os << ",\n DetectorCorrectionType: '" << defaults.DetectorCorrectionType
<< "' }" << std::endl;
return os;
......
......@@ -19,7 +19,6 @@ struct MANTIDQT_ISISREFLECTOMETRY_DLL InstrumentOptionDefaults {
double LambdaMin;
double LambdaMax;
boost::variant<int, double> I0MonitorIndex;
boost::optional<std::string> ProcessingInstructions;
bool CorrectDetectors;
std::string DetectorCorrectionType;
};
......
#include "QtReflSettingsView.h"
#include "MantidKernel/System.h"
#include "MantidQtWidgets/Common/DataProcessorUI/OptionsQMap.h"
#include "MantidQtWidgets/Common/HintingLineEdit.h"
#include "ReflSettingsPresenter.h"
#include <QMessageBox>
......@@ -10,6 +11,7 @@ namespace MantidQt {
namespace CustomInterfaces {
using namespace MantidQt::MantidWidgets;
using namespace MantidQt::MantidWidgets::DataProcessor;
//----------------------------------------------------------------------------------------------
/** Constructor
......@@ -36,7 +38,7 @@ Initialise the Interface
*/
void QtReflSettingsView::initLayout() {
m_ui.setupUi(this);
initTransmissionRunsTable();
initOptionsTable();
connect(m_ui.getExpDefaultsButton, SIGNAL(clicked()), this,
SLOT(requestExpDefaults()));
......@@ -46,24 +48,28 @@ void QtReflSettingsView::initLayout() {
SLOT(setPolarisationOptionsEnabled(bool)));
connect(m_ui.summationTypeComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(summationTypeChanged(int)));
connect(m_ui.addTransmissionRowButton, SIGNAL(clicked()), this,
SLOT(addTransmissionTableRow()));
connect(m_ui.addPerAngleOptionsButton, SIGNAL(clicked()), this,
SLOT(addPerAngleOptionsTableRow()));
connect(m_ui.correctDetectorsCheckBox, SIGNAL(clicked(bool)), this,
SLOT(setDetectorCorrectionEnabled(bool)));
}
void QtReflSettingsView::initTransmissionRunsTable() {
auto table = m_ui.transmissionRunsTable;
const auto columnHeadings = QStringList({"Angle", "Transmission Run(s)"});
table->setColumnCount(columnHeadings.size());
table->setHorizontalHeaderLabels(columnHeadings);
table->setColumnWidth(0, 40);
void QtReflSettingsView::initOptionsTable() {
auto table = m_ui.optionsTable;
m_columnProperties =
QStringList({"ThetaIn", "FirstTransmissionRun", "MomentumTransferMin",
"MomentumTransferMax", "MomentumTransferStep", "ScaleFactor",
"ProcessingInstructions"});
if (m_columnProperties.size() != table->columnCount())
throw std::runtime_error(
"Error setting up properties for per-angle options table");
// Set angle and scale columns to a small width so everything fits
table->resizeColumnsToContents();
auto header = table->horizontalHeader();
header->setStretchLastSection(true);
const int typicalNumberOfRows = 3;
table->setRowCount(typicalNumberOfRows);
int totalRowHeight = 0;
for (int i = 0; i < typicalNumberOfRows; ++i) {
for (int i = 0; i < table->rowCount(); ++i) {
totalRowHeight += table->rowHeight(i);
}
const int padding = 2;
......@@ -126,7 +132,6 @@ void QtReflSettingsView::registerInstrumentSettingsWidgets(
registerSettingWidget(*m_ui.lamMinEdit, "WavelengthMin", alg);
registerSettingWidget(*m_ui.lamMaxEdit, "WavelengthMax", alg);
registerSettingWidget(*m_ui.I0MonIndexEdit, "I0MonitorIndex", alg);
registerSettingWidget(*m_ui.procInstEdit, "ProcessingInstructions", alg);
registerSettingWidget(*m_ui.detectorCorrectionTypeComboBox,
"DetectorCorrectionType", alg);
registerSettingWidget(*m_ui.correctDetectorsCheckBox, "CorrectDetectors",
......@@ -138,9 +143,8 @@ void QtReflSettingsView::registerInstrumentSettingsWidgets(
void QtReflSettingsView::registerExperimentSettingsWidgets(
Mantid::API::IAlgorithm_sptr alg) {
connectSettingsChange(*m_ui.expSettingsGroup);
connectSettingsChange(*m_ui.optionsTable);
registerSettingWidget(*m_ui.analysisModeComboBox, "AnalysisMode", alg);
registerSettingWidget(*m_ui.transmissionRunsTable, "FirstTransmissionRun",
alg);
registerSettingWidget(*m_ui.startOverlapEdit, "StartOverlap", alg);
registerSettingWidget(*m_ui.endOverlapEdit, "EndOverlap", alg);
registerSettingWidget(*m_ui.polCorrComboBox, "PolarizationAnalysis", alg);
......@@ -148,9 +152,6 @@ void QtReflSettingsView::registerExperimentSettingsWidgets(
registerSettingWidget(*m_ui.CAlphaEdit, "CAlpha", alg);
registerSettingWidget(*m_ui.CApEdit, "CAp", alg);
registerSettingWidget(*m_ui.CPpEdit, "CPp", alg);
registerSettingWidget(*m_ui.momentumTransferStepEdit, "MomentumTransferStep",
alg);
registerSettingWidget(*m_ui.scaleFactorEdit, "ScaleFactor", alg);
registerSettingWidget(stitchOptionsLineEdit(), "Params", alg);
}
......@@ -227,9 +228,16 @@ void QtReflSettingsView::setExpDefaults(ExperimentOptionDefaults defaults) {
setText(*m_ui.CPpEdit, defaults.CPp);
setText(*m_ui.startOverlapEdit, defaults.TransRunStartOverlap);
setText(*m_ui.endOverlapEdit, defaults.TransRunEndOverlap);
setText(*m_ui.momentumTransferStepEdit, defaults.MomentumTransferStep);
setText(*m_ui.scaleFactorEdit, defaults.ScaleFactor);
setText(stitchOptionsLineEdit(), defaults.StitchParams);
setText(*m_ui.optionsTable, "MomentumTransferMin",
defaults.MomentumTransferMin);
setText(*m_ui.optionsTable, "MomentumTransferMax",
defaults.MomentumTransferMax);
setText(*m_ui.optionsTable, "MomentumTransferStep",
defaults.MomentumTransferStep);
setText(*m_ui.optionsTable, "ScaleFactor", defaults.ScaleFactor);
setText(*m_ui.optionsTable, "ProcessingInstructions",
defaults.ProcessingInstructions);
}
void QtReflSettingsView::setSelected(QComboBox &box, std::string const &str) {
......@@ -242,21 +250,18 @@ void QtReflSettingsView::setText(QLineEdit &lineEdit,
boost::optional<double> value) {
if (value)
setText(lineEdit, value.get());
else
setText(lineEdit, "");
}
void QtReflSettingsView::setText(QLineEdit &lineEdit,
boost::optional<int> value) {
if (value)
setText(lineEdit, value.get());
else
setText(lineEdit, "");
}
void QtReflSettingsView::setText(QLineEdit &lineEdit,
boost::optional<std::string> const &text) {
setText(lineEdit, value_or(text, ""));
if (text && !text->empty())
setText(lineEdit, text);
}
void QtReflSettingsView::setText(QLineEdit &lineEdit, double value) {
......@@ -274,6 +279,58 @@ void QtReflSettingsView::setText(QLineEdit &lineEdit, std::string const &text) {
lineEdit.setText(textAsQString);
}
void QtReflSettingsView::setText(QTableWidget &table,
std::string const &propertyName,
boost::optional<double> value) {
if (value)
setText(table, propertyName, value.get());
}
void QtReflSettingsView::setText(QTableWidget &table,
std::string const &propertyName,
double value) {
auto valueAsString = QString::number(value);
setText(table, propertyName, valueAsString);
}
void QtReflSettingsView::setText(QTableWidget &table,
std::string const &propertyName,
boost::optional<std::string> text) {
if (text && !text->empty())
setText(table, propertyName, text.get());
}
void QtReflSettingsView::setText(QTableWidget &table,
std::string const &propertyName,
std::string const &text) {
auto textAsQString = QString::fromStdString(text);
setText(table, propertyName, textAsQString);
}
void QtReflSettingsView::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 QtReflSettingsView::setChecked(QCheckBox &checkBox, bool checked) {
auto checkedAsCheckState = checked ? Qt::Checked : Qt::Unchecked;
checkBox.setCheckState(checkedAsCheckState);
......@@ -311,7 +368,6 @@ void QtReflSettingsView::setInstDefaults(InstrumentOptionDefaults defaults) {
defaults.I0MonitorIndex);
setSelected(*m_ui.detectorCorrectionTypeComboBox,
defaults.DetectorCorrectionType);
setText(*m_ui.procInstEdit, defaults.ProcessingInstructions);
setChecked(*m_ui.correctDetectorsCheckBox, defaults.CorrectDetectors);
}
......@@ -346,11 +402,11 @@ void QtReflSettingsView::setPolarisationOptionsEnabled(bool enable) {
/** Add a new row to the transmission runs table
* */
void QtReflSettingsView::addTransmissionTableRow() {
auto numRows = m_ui.transmissionRunsTable->rowCount() + 1;
m_ui.transmissionRunsTable->setRowCount(numRows);
void QtReflSettingsView::addPerAngleOptionsTableRow() {
auto numRows = m_ui.optionsTable->rowCount() + 1;
m_ui.optionsTable->setRowCount(numRows);
// Select the first cell in the new row
m_ui.transmissionRunsTable->setCurrentCell(numRows - 1, 0);
m_ui.optionsTable->setCurrentCell(numRows - 1, 0);
}
std::string QtReflSettingsView::getText(QLineEdit const &lineEdit) const {
......@@ -440,32 +496,49 @@ std::string QtReflSettingsView::getAnalysisMode() const {
return getText(*m_ui.analysisModeComboBox);
}
/** Return selected transmission run(s)
* @return :: selected transmission run(s)
/** Create the options map for a given row in the per-angle options table
* @param row [in] : the row index
*/
OptionsQMap QtReflSettingsView::createOptionsMapForRow(const int row) const {
OptionsQMap rowOptions;
const auto &table = m_ui.optionsTable;
for (int col = 1; col < table->columnCount(); ++col) {
auto colItem = table->item(row, col);
auto colValue = colItem ? colItem->text() : "";
if (!colValue.isEmpty()) {
rowOptions[m_columnProperties[col]] = colValue;
}
}
return rowOptions;
}
/** Return the per-angle options
* @return :: return a map of angles to the options
*/
std::map<std::string, std::string>
QtReflSettingsView::getTransmissionRuns() const {
std::map<std::string, OptionsQMap>
QtReflSettingsView::getPerAngleOptions() const {
const auto &table = m_ui.transmissionRunsTable;
const auto &table = m_ui.optionsTable;
// Check that we have 2 columns (angle and runs)
if (table->columnCount() != 2)
throw std::runtime_error("Transmission runs table must have 2 columns");
// Check that we have at least 2 columns (the angle and some values)
if (table->columnCount() < 2)
throw std::runtime_error(
"Per-angle options table must have at least 2 columns");
// Return values in a map
std::map<std::string, std::string> results;
std::map<std::string, OptionsQMap> results;
for (auto row = 0; row < table->rowCount(); ++row) {
auto angleItem = table->item(row, 0);
auto runsItem = table->item(row, 1);
// Extract the string values
auto angle = angleItem ? angleItem->text() : "";
auto runs = runsItem ? runsItem->text() : "";
// Skip empty rows
if (angle.isEmpty() && runs.isEmpty())
continue;
// Add to the map
results[angle.toStdString()] = runs.toStdString();
auto rowOptions = createOptionsMapForRow(row);
const bool emptyRow = angle.isEmpty() && rowOptions.isEmpty();
// Add the row options to the result. We could do with a better way to
// handle duplicate keys but for now it's ok to just ignore subsequent rows
// with the same angle
if (!emptyRow && !results.count(angle.toStdString()))
results[angle.toStdString()] = rowOptions;
}
return results;
}
......@@ -519,20 +592,6 @@ std::string QtReflSettingsView::getCPp() const {
return getText(*m_ui.CPpEdit);
}
/** Return momentum transfer limits
* @return :: momentum transfer limits
*/
std::string QtReflSettingsView::getMomentumTransferStep() const {
return getText(*m_ui.momentumTransferStepEdit);
}
/** Return scale factor
* @return :: scale factor
*/
std::string QtReflSettingsView::getScaleFactor() const {
return getText(*m_ui.scaleFactorEdit);
}
/** Return integrated monitors option
* @return :: integrated monitors check
*/
......@@ -589,13 +648,6 @@ std::string QtReflSettingsView::getI0MonitorIndex() const {
return getText(*m_ui.I0MonIndexEdit);
}
/** Return processing instructions
* @return :: processing instructions
*/
std::string QtReflSettingsView::getProcessingInstructions() const {
return getText(*m_ui.procInstEdit);
}
std::string QtReflSettingsView::getReductionType() const {
return getText(*m_ui.reductionTypeComboBox);
}
......
#ifndef MANTID_CUSTOMINTERFACES_QTREFLSETTINGSVIEW_H_
#define MANTID_CUSTOMINTERFACES_QTREFLSETTINGSVIEW_H_
......@@ -55,8 +56,9 @@ public:
std::string getStitchOptions() const override;
/// Return selected analysis mode
std::string getAnalysisMode() const override;
/// Return transmission runs
std::map<std::string, std::string> getTransmissionRuns() const override;
/// Return the per-angle options
std::map<std::string, MantidQt::MantidWidgets::DataProcessor::OptionsQMap>
getPerAngleOptions() const override;
/// Return start overlap for transmission runs
std::string getStartOverlap() const override;
/// Return end overlap for transmission runs
......@@ -71,10 +73,6 @@ public:
std::string getCAp() const override;
/// Return Cpp
std::string getCPp() const override;
/// Return momentum transfer limits
std::string getMomentumTransferStep() const override;
/// Return scale factor
std::string getScaleFactor() const override;
/// Return integrated monitors option
std::string getIntMonCheck() const override;
/// Return monitor integral wavelength min
......@@ -91,8 +89,6 @@ public:
std::string getLambdaMax() const override;
/// Return I0MonitorIndex
std::string getI0MonitorIndex() const override;
/// Return processing instructions
std::string getProcessingInstructions() const override;
/// Return selected detector correction type
std::string getDetectorCorrectionType() const override;
/// Return selected summation type
......@@ -134,13 +130,13 @@ public slots:
QString messageFor(
std::vector<MissingInstrumentParameterValue> const &missingValues) const;
QString messageFor(const InstrumentParameterTypeMissmatch &typeError) const;
/// Adds another row to the transmission runs table
void addTransmissionTableRow();
/// Adds another row to the per-angle options table
void addPerAngleOptionsTableRow();
private:
/// Initialise the interface
void initLayout();
void initTransmissionRunsTable();
void initOptionsTable();
void registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg);
void registerInstrumentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg);
void registerExperimentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg);
......@@ -164,9 +160,22 @@ private:
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;
/// Put the per-angle options for a row into a map
MantidQt::MantidWidgets::DataProcessor::OptionsQMap
createOptionsMapForRow(const int row) const;
/// The widget
Ui::ReflSettingsWidget m_ui;
......@@ -176,6 +185,10 @@ private:
mutable bool m_isPolCorrEnabled;
/// The stitch params entry widget
MantidQt::MantidWidgets::HintingLineEdit *m_stitchEdit;
/// The algorithm properties relating to the options table
/// @todo Could we use the data processor whitelist to get the properties
/// instead?
QStringList m_columnProperties;
};
} // namespace Mantid
} // namespace CustomInterfaces
......
......@@ -472,7 +472,7 @@ bool ReflDataProcessorPresenter::reduceRowAsEventWS(RowData_sptr rowData,
// from the latest slice. It would be good to do some validation
// that the results are the same for each slice e.g. the resolution
// should always be the same.
updateModelFromAlgorithm(alg, rowData);
updateModelFromResults(alg, rowData);
} catch (...) {
return false;
}
......@@ -974,7 +974,7 @@ OptionsMap ReflDataProcessorPresenter::getProcessingOptions(RowData_sptr data) {
// Get the angle for the current row. The angle is the second data item
if (!hasAngle(data)) {
if (m_mainPresenter->hasPerAngleTransmissionRuns()) {
if (m_mainPresenter->hasPerAngleOptions()) {
// The user has specified per-angle transmission runs on the settings
// tab. In theory this is fine, but it could cause confusion when the
// angle is not available in the data processor table because the
......@@ -994,14 +994,13 @@ OptionsMap ReflDataProcessorPresenter::getProcessingOptions(RowData_sptr data) {
}
}
// Insert the transmission runs as the "FirstTransmissionRun" property
auto transmissionRuns =
m_mainPresenter->getTransmissionRunsForAngle(angle(data));
if (!transmissionRuns.isEmpty()) {
options["FirstTransmissionRun"] = transmissionRuns;
}
// Get the options for this angle
auto optionsForAngle =
convertOptionsFromQMap(m_mainPresenter->getOptionsForAngle(angle(data)));
// Add the default options (only added if per-angle options don't exist)
optionsForAngle.insert(options.begin(), options.end());
return options;
return optionsForAngle;
}
}
}
......@@ -161,21 +161,21 @@ std::string ReflMainWindowPresenter::getTimeSlicingType(int group) const {
* @param angle :: the run angle to look up transmission runs for
* @return :: Values passed for 'Transmission run(s)'
*/
std::string
ReflMainWindowPresenter::getTransmissionRunsForAngle(int group,
const double angle) const {
OptionsQMap
ReflMainWindowPresenter::getOptionsForAngle(int group,
const double angle) const {
checkSettingsPtrValid(m_settingsPresenter);
return m_settingsPresenter->getTransmissionRunsForAngle(group, angle);
return m_settingsPresenter->getOptionsForAngle(group, angle);
}
/** Returns whether there are per-angle transmission runs specified
* @return :: true if there are per-angle transmission runs
* */
bool ReflMainWindowPresenter::hasPerAngleTransmissionRuns(int group) const {
bool ReflMainWindowPresenter::hasPerAngleOptions(int group) const {
checkSettingsPtrValid(m_settingsPresenter);
return m_settingsPresenter->hasPerAngleTransmissionRuns(group);
return m_settingsPresenter->hasPerAngleOptions(group);
}
/**
......
......@@ -52,10 +52,10 @@ public:
~ReflMainWindowPresenter() override;
/// Returns values passed for 'Transmission run(s)'
std::string getTransmissionRunsForAngle(int group,
const double angle) const override;
MantidWidgets::DataProcessor::OptionsQMap
getOptionsForAngle(int group, const double angle) const override;
/// Whether there are per-angle transmission runs specified
bool hasPerAngleTransmissionRuns(int group) const override;
bool hasPerAngleOptions(int group) const override;
/// Returns global options for 'CreateTransmissionWorkspaceAuto'
MantidWidgets::DataProcessor::OptionsQMap
getTransmissionOptions(int group) const override;
......
......@@ -475,18 +475,15 @@ QString ReflRunsTabPresenter::getTimeSlicingType() const {
* by the main presenter
* @return :: Transmission run(s) as a comma-separated list
*/
QString
ReflRunsTabPresenter::getTransmissionRunsForAngle(const double angle) const {
return QString::fromStdString(m_mainPresenter->getTransmissionRunsForAngle(
m_view->getSelectedGroup(), angle));
OptionsQMap ReflRunsTabPresenter::getOptionsForAngle(const double angle) const {
return m_mainPresenter->getOptionsForAngle(m_view->getSelectedGroup(), angle);
}
/** Check whether there are per-angle transmission runs in the settings
* @return :: true if there are per-angle transmission runs
*/
bool ReflRunsTabPresenter::hasPerAngleTransmissionRuns() const {
return m_mainPresenter->hasPerAngleTransmissionRuns(
m_view->getSelectedGroup());
bool ReflRunsTabPresenter::hasPerAngleOptions() const {
return m_mainPresenter->hasPerAngleOptions(m_view->getSelectedGroup());
}
/** Tells the view to update the enabled/disabled state of all relevant widgets
......
......@@ -77,8 +77,9 @@ public:
QString getPostprocessingOptionsAsString() const override;
QString getTimeSlicingValues() const override;
QString getTimeSlicingType() const override;
QString getTransmissionRunsForAngle(const double angle) const override;
bool hasPerAngleTransmissionRuns() const override;
MantidWidgets::DataProcessor::OptionsQMap
getOptionsForAngle(const double angle) const override;
bool hasPerAngleOptions() const override;
/// Handle data reduction paused/resumed
void pause() const override;
void resume() const override;
......
......@@ -104,6 +104,19 @@ OptionsQMap ReflSettingsPresenter::transmissionOptionsMap() const {
return options;
}
/** Get the processing instructinons.
* @return : the processing instructions, or an empty string if not set
*/
QString ReflSettingsPresenter::getProcessingInstructions() const {
// the processing instructions are set in the per-angle options table. We
// only set them if there is a default (i.e. not linked to an angle).
auto options = getDefaultOptions();
if (options.count("ProcessingInstructions"))
return options["ProcessingInstructions"].toString();
return QString();
}
/** Returns global options for 'CreateTransmissionWorkspaceAuto'. Note that
* this must include all applicable options, even if they are empty, because
* the GenericDataProcessorPresenter has no other way of knowing which options
......@@ -129,6 +142,8 @@ OptionsQMap ReflSettingsPresenter::getTransmissionOptions() const {
setTransmissionOption(options, "AnalysisMode", m_view->getAnalysisMode());
setTransmissionOption(options, "StartOverlap", m_view->getStartOverlap());
setTransmissionOption(options, "EndOverlap", m_view->getEndOverlap());
setTransmissionOption(options, "ProcessingInstructions",
getProcessingInstructions());
}
if (m_view->instrumentSettingsEnabled()) {
......@@ -144,8 +159,6 @@ OptionsQMap ReflSettingsPresenter::getTransmissionOptions() const {
setTransmissionOption(options, "WavelengthMax", m_view->getLambdaMax());
setTransmissionOption(options, "I0MonitorIndex",
m_view->getI0MonitorIndex());
setTransmissionOption(options, "ProcessingInstructions",
m_view->getProcessingInstructions());
}
return options;
......@@ -206,9 +219,6 @@ OptionsQMap ReflSettingsPresenter::getReductionOptions() const {
addIfNotEmpty(options, "CPp", m_view->getCPp());
addIfNotEmpty(options, "PolarizationAnalysis",
m_view->getPolarisationCorrections());
addIfNotEmpty(options, "ScaleFactor", m_view->getScaleFactor());
addIfNotEmpty(options, "MomentumTransferStep",
m_view->getMomentumTransferStep());
addIfNotEmpty(options, "StartOverlap", m_view->getStartOverlap());
addIfNotEmpty(options, "EndOverlap", m_view->getEndOverlap());
......@@ -218,16 +228,10 @@ OptionsQMap ReflSettingsPresenter::getReductionOptions() const {
if (hasReductionTypes(summationType))
addIfNotEmpty(options, "ReductionType", m_view->getReductionType());
// Add transmission runs. Note that the value here may be
// a comma-separated list of multiple values. We return the
// string as entered by the user because parsing is done in
// the data processor widget. Note also that we can only
// return default values here if provided; the user may also
// provide per-angle transmission runs, but these need to be
// requested on a per-row basis when we know what the angle is
// for that row.
auto transmissionRuns = getDefaultTransmissionRuns();
addIfNotEmpty(options, "FirstTransmissionRun", transmissionRuns);
auto defaultOptions = getDefaultOptions();
for (auto iter = defaultOptions.begin(); iter != defaultOptions.end();
++iter)
addIfNotEmpty(options, iter.key(), iter.value().toString());
}
if (m_view->instrumentSettingsEnabled()) {
......@@ -244,8 +248,6 @@ OptionsQMap ReflSettingsPresenter::getReductionOptions() const {
addIfNotEmpty(options, "WavelengthMin", m_view->getLambdaMin());
addIfNotEmpty(options, "WavelengthMax", m_view->getLambdaMax());
addIfNotEmpty(options, "I0MonitorIndex", m_view->getI0MonitorIndex());
addIfNotEmpty(options, "ProcessingInstructions",
m_view->getProcessingInstructions());
addIfNotEmpty(options, "DetectorCorrectionType",
m_view->getDetectorCorrectionType());
auto const correctDetectors =
......@@ -258,20 +260,20 @@ OptionsQMap ReflSettingsPresenter::getReductionOptions() const {
/** Check whether per-angle transmission runs are specified
*/
bool ReflSettingsPresenter::hasPerAngleTransmissionRuns() const {
bool ReflSettingsPresenter::hasPerAngleOptions() const {
// Check the setting is enabled
if (!m_view->experimentSettingsEnabled())
return false;
// Check we have some entries in the table
auto runsPerAngle = m_view->getTransmissionRuns();
auto runsPerAngle = m_view->getPerAngleOptions();
if (runsPerAngle.empty())
return false;
// To save confusion, we only allow EITHER a default transmission runs string
// OR multiple per-angle strings. Therefore if there is a default set there
// cannot be per-angle runs.
if (!getDefaultTransmissionRuns().empty())
if (!getDefaultOptions().empty())
return false;
// Ok, we have some entries and they're not defaults, so assume they're valid
......@@ -285,13 +287,13 @@ bool ReflSettingsPresenter::hasPerAngleTransmissionRuns() const {
* @return :: the transmission run(s) as a string of comma-separated values
* @throws :: if the settings the user entered are invalid
*/
std::string ReflSettingsPresenter::getDefaultTransmissionRuns() const {
OptionsQMap ReflSettingsPresenter::getDefaultOptions() const {
if (!m_view->experimentSettingsEnabled())
return std::string();
return OptionsQMap();
// Values are entered as a map of angle to transmission runs. Loop
// through them, checking for the required angle
auto runsPerAngle = m_view->getTransmissionRuns();
auto runsPerAngle = m_view->getPerAngleOptions();
auto iter = runsPerAngle.find("");
if (iter != runsPerAngle.end()) {
// We found an empty angle. Check there is only one entry in the
......@@ -306,22 +308,22 @@ std::string ReflSettingsPresenter::getDefaultTransmissionRuns() const {
}
// If not found, return an empty string
return std::string();
return OptionsQMap();
}
/** Gets the user-specified transmission runs from the view
* @param angleToFind :: the run angle that transmission runs are valid for
* @return :: the transmission run(s) as a string of comma-separated values
*/
std::string ReflSettingsPresenter::getTransmissionRunsForAngle(
const double angleToFind) const {
std::string result;
OptionsQMap
ReflSettingsPresenter::getOptionsForAngle(const double angleToFind) const {
OptionsQMap result;
if (!hasPerAngleTransmissionRuns())
if (!hasPerAngleOptions())
return result;
// Values are entered as a map of angle to transmission runs
auto runsPerAngle = m_view->getTransmissionRuns();
auto runsPerAngle = m_view->getPerAngleOptions();
// We use a generous tolerance to check the angle because values
// from the log are not that accurate
......@@ -331,7 +333,7 @@ std::string ReflSettingsPresenter::getTransmissionRunsForAngle(
double smallestDist = std::numeric_limits<double>::max();
for (auto kvp : runsPerAngle) {
auto angleStr = kvp.first;
auto runsStr = kvp.second;
auto values = kvp.second;
// Convert the angle to a double
double angle = 0.0;
......@@ -346,7 +348,7 @@ std::string ReflSettingsPresenter::getTransmissionRunsForAngle(
double dist = std::abs(angle - angleToFind);
if (dist <= tolerance) {
if (dist < smallestDist) {
result = runsStr;
result = values;
smallestDist = dist;
}
}
......@@ -409,8 +411,12 @@ void ReflSettingsPresenter::getExpDefaults() {
defaults.CAp = value_or(parameters.optional<std::string>("cAp"), "1");
defaults.CPp = value_or(parameters.optional<std::string>("cPp"), "1");
defaults.MomentumTransferMin = parameters.optional<double>("Q min");
defaults.MomentumTransferMax = parameters.optional<double>("Q max");
defaults.MomentumTransferStep = parameters.optional<double>("dQ/Q");
defaults.ScaleFactor = parameters.optional<double>("Scale");
defaults.ProcessingInstructions =
parameters.optional<std::string>("ProcessingInstructions");
defaults.StitchParams = parameters.optional<std::string>("Stitch1DMany");
if (m_currentInstrumentName != "SURF" && m_currentInstrumentName != "CRISP") {
......@@ -456,8 +462,6 @@ void ReflSettingsPresenter::getInstDefaults() {
defaults.LambdaMax = parameters.mandatory<double>("LambdaMax");
defaults.I0MonitorIndex =
parameters.mandatoryVariant<int, double>("I0MonitorIndex");
defaults.ProcessingInstructions =
parameters.optional<std::string>("ProcessingInstructions");
defaults.CorrectDetectors =
value_or(parameters.optional<bool>("CorrectDetectors"),
alg->getProperty("CorrectDetectors"));
......
......@@ -53,12 +53,12 @@ public:
void setInstrumentName(const std::string &instName) override;
/// Returns per-angle values passed for 'Transmission run(s)'
std::string
getTransmissionRunsForAngle(const double angleToFind) const override;
MantidWidgets::DataProcessor::OptionsQMap
getOptionsForAngle(const double angleToFind) const override;
/// Returns default values passed for 'Transmission run(s)'
std::string getDefaultTransmissionRuns() const;
MantidWidgets::DataProcessor::OptionsQMap getDefaultOptions() const;
/// Whether per-angle transmission runs are specified
bool hasPerAngleTransmissionRuns() const override;
bool hasPerAngleOptions() const override;
/// Returns global options for 'CreateTransmissionWorkspaceAuto'
MantidWidgets::DataProcessor::OptionsQMap
getTransmissionOptions() const override;
......@@ -97,6 +97,7 @@ private:
void
addTransmissionOptions(MantidWidgets::DataProcessor::OptionsQMap &options,
std::initializer_list<QString> keys) const;
QString getProcessingInstructions() const;
/// The view we are managing
IReflSettingsView *m_view;
......
......@@ -65,17 +65,18 @@ void ReflSettingsTabPresenter::onReductionPaused(int group) {
* @param angle :: the run angle to look up transmission runs for
* @return :: Values passed for 'Transmission run(s)'
*/
std::string ReflSettingsTabPresenter::getTransmissionRunsForAngle(
int group, const double angle) const {
OptionsQMap
ReflSettingsTabPresenter::getOptionsForAngle(int group,
const double angle) const {
return m_settingsPresenters.at(group)->getTransmissionRunsForAngle(angle);
return m_settingsPresenters.at(group)->getOptionsForAngle(angle);
}
/** Check whether per-angle transmission runs are specified
* @return :: true if per-angle transmission runs are specified
*/
bool ReflSettingsTabPresenter::hasPerAngleTransmissionRuns(int group) const {
return m_settingsPresenters.at(group)->hasPerAngleTransmissionRuns();
bool ReflSettingsTabPresenter::hasPerAngleOptions(int group) const {
return m_settingsPresenters.at(group)->hasPerAngleOptions();
}
/** Returns global options for 'CreateTransmissionWorkspaceAuto'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment