Mantid
Loading...
Searching...
No Matches
LOQScriptInputDialog.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//---------------------------
8// Includes
9//--------------------------
12#include <QDir>
13#include <QFileInfo>
14
15// Add this class to the list of specialised dialogs in this namespace
18} // namespace MantidQt::CustomDialogs
19
20// Just to save writing this everywhere
21using namespace MantidQt::CustomDialogs;
22
23//---------------------------------------
24// Public member functions
25//---------------------------------------
26
28LOQScriptInputDialog::LOQScriptInputDialog(QWidget *parent) : AlgorithmDialog(parent) {}
29
34 m_uiForm.setupUi(this);
35
36 connect(m_uiForm.browseButton, SIGNAL(clicked()), this, SLOT(browseClicked()));
37
38 fillLineEdit("SampleWorkspace", m_uiForm.sampleBox);
39 fillLineEdit("EmptyCanWorkspace", m_uiForm.emptycanBox);
40 fillLineEdit("TransmissionSampleWorkspace", m_uiForm.transSampleBox);
41 fillLineEdit("TransmissionDirectWorkspace", m_uiForm.transDirectBox);
42 fillLineEdit("TransmissionEmptyCanWorkspace", m_uiForm.transEmptyBox);
43
44 fillLineEdit("Radius_min", m_uiForm.radMinBox);
45 fillLineEdit("Radius_max", m_uiForm.radMaxBox);
46
47 fillLineEdit("Wavelength_min", m_uiForm.wavMinBox);
48 fillLineEdit("Wavelength_max", m_uiForm.wavMaxBox);
49 fillLineEdit("Wavelength_delta", m_uiForm.wavBinBox);
50
51 fillLineEdit("Q_min", m_uiForm.momMinBox);
52 fillLineEdit("Q_max", m_uiForm.momMaxBox);
53 fillLineEdit("Q_delta", m_uiForm.momBinBox);
54
55 fillLineEdit("Beam_Centre_X", m_uiForm.beamXBox);
56 fillLineEdit("Beam_Centre_Y", m_uiForm.beamYBox);
57
58 // Efficiency correction
59 fillLineEdit("EfficiencyCorrectionFile", m_uiForm.effFileBox);
60
61 m_uiForm.sampleBox->setFocus();
62}
63
68 // All elements within the dialog are public memebers of the
69 // LOQScriptInputDialog class
70 // and have the names given to them in Qt Designer
71
72 // Simply access each widget and use storePropertyValue( propName,
73 // m_uiForm->propValue)
74 // method of the AlgorithmDialog base class to add the input value for this
75 // property
76
77 storePropertyValue("SampleWorkspace", m_uiForm.sampleBox->text());
78 storePropertyValue("EmptyCanWorkspace", m_uiForm.emptycanBox->text());
79 storePropertyValue("TransmissionSampleWorkspace", m_uiForm.transSampleBox->text());
80 storePropertyValue("TransmissionDirectWorkspace", m_uiForm.transDirectBox->text());
81 storePropertyValue("TransmissionEmptyCanWorkspace", m_uiForm.transEmptyBox->text());
82
83 storePropertyValue("Radius_min", m_uiForm.radMinBox->text());
84 storePropertyValue("Radius_max", m_uiForm.radMaxBox->text());
85
86 storePropertyValue("Wavelength_min", m_uiForm.wavMinBox->text());
87 storePropertyValue("Wavelength_max", m_uiForm.wavMaxBox->text());
88 storePropertyValue("Wavelength_delta", m_uiForm.wavBinBox->text());
89
90 storePropertyValue("Q_min", m_uiForm.momMinBox->text());
91 storePropertyValue("Q_max", m_uiForm.momMaxBox->text());
92 storePropertyValue("Q_delta", m_uiForm.momBinBox->text());
93
94 storePropertyValue("Beam_Centre_X", m_uiForm.beamXBox->text());
95 storePropertyValue("Beam_Centre_Y", m_uiForm.beamYBox->text());
96
97 // Efficiency correction
98 storePropertyValue("EfficiencyCorrectionFile", m_uiForm.effFileBox->text());
99}
100
105 if (!m_uiForm.effFileBox->text().isEmpty()) {
106 QString dir = QFileInfo(m_uiForm.effFileBox->text()).absoluteDir().path();
107 MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(dir);
108 }
109
110 QString filepath = this->openFileDialog("EfficiencyCorrectionFile");
111 if (!filepath.isEmpty())
112 m_uiForm.effFileBox->setText(filepath);
113}
#define DECLARE_DIALOG(classname)
QString openFileDialog(const QString &propName)
Open a file dialog to select a file.
void storePropertyValue(const QString &name, const QString &value)
Adds a property (name,value) pair to the stored map.
void fillLineEdit(const QString &propName, QLineEdit *field)
Fill in the necessary input for a text field.
This class gives specialised dialog for the LOQ input algorithm.
void parseInput() override
Get the input out of the dialog.
void initLayout() override
Initialize the layout.
LOQScriptInputDialog(QWidget *parent=nullptr)
Default constructor.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...