diff --git a/Code/Mantid/MantidQt/CustomDialogs/CMakeLists.txt b/Code/Mantid/MantidQt/CustomDialogs/CMakeLists.txt index 62b907313169ceacd1e79bae28c2d8a34286bd17..c226b44e11c349a96731ca7b8849b6b6fdd4887d 100644 --- a/Code/Mantid/MantidQt/CustomDialogs/CMakeLists.txt +++ b/Code/Mantid/MantidQt/CustomDialogs/CMakeLists.txt @@ -5,6 +5,7 @@ set ( SRC_FILES src/CreateSampleShapeDialog.cpp src/LoadDialog.cpp src/LoadAsciiDialog.cpp src/LoadDAEDialog.cpp + src/LoadInstrumentDialog.cpp src/LoadRawDialog.cpp src/LOQScriptInputDialog.cpp src/MantidGLWidget.cpp @@ -23,6 +24,7 @@ set ( MOC_FILES inc/MantidQtCustomDialogs/CreateSampleShapeDialog.h inc/MantidQtCustomDialogs/LoadDialog.h inc/MantidQtCustomDialogs/LoadAsciiDialog.h inc/MantidQtCustomDialogs/LoadDAEDialog.h + inc/MantidQtCustomDialogs/LoadInstrumentDialog.h inc/MantidQtCustomDialogs/LoadRawDialog.h inc/MantidQtCustomDialogs/LOQScriptInputDialog.h inc/MantidQtCustomDialogs/MantidGLWidget.h @@ -42,6 +44,7 @@ set ( UI_FILES inc/MantidQtCustomDialogs/CreateSampleShapeDialog.ui inc/MantidQtCustomDialogs/LOQScriptInputDialog.ui inc/MantidQtCustomDialogs/PlotAsymmetryByLogValueDialog.ui inc/MantidQtCustomDialogs/LoadDialog.ui + inc/MantidQtCustomDialogs/LoadInstrumentDialog.ui inc/MantidQtCustomDialogs/StartLiveDataDialog.ui inc/MantidQtCustomDialogs/SlicingAlgorithmDialog.ui inc/MantidQtCustomDialogs/FitDialog.ui diff --git a/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadInstrumentDialog.h b/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadInstrumentDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..03c408149171bd5871fb4e67ff8915c605310710 --- /dev/null +++ b/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadInstrumentDialog.h @@ -0,0 +1,50 @@ +#ifndef MANTIDQTCUSTOMDIALOGS_LOAD_INSTRUMENT_DIALOG_H_ +#define MANTIDQTCUSTOMDIALOGS_LOAD_INSTRUMENT_DIALOG_H_ + +//---------------------- +// Includes +//---------------------- +#include "ui_LoadInstrumentDialog.h" +#include "MantidQtAPI/AlgorithmDialog.h" +#include "MantidAPI/IAlgorithm.h" +#include "MantidAPI/Algorithm.h" + +namespace MantidQt +{ +namespace CustomDialogs +{ + +/* +Class SlicingAlgorithmDialog + +*/ +class LoadInstrumentDialog : public MantidQt::API::AlgorithmDialog +{ + Q_OBJECT +public: + + /// Default Constructor + LoadInstrumentDialog(QWidget *parent = 0); + + /// Destructor + ~LoadInstrumentDialog(); + +protected: + + /// view + Ui::Dialog ui; + +protected slots: + + void onBrowse(); + void accept(); + +private: + /// Initialize the layout + virtual void initLayout(); + +}; +} +} + +#endif diff --git a/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadInstrumentDialog.ui b/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadInstrumentDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..eade5e127f6019a350dff2d8425f58982cb3f6ac --- /dev/null +++ b/Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/LoadInstrumentDialog.ui @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Dialog</class> + <widget class="QDialog" name="Dialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>LoadInstrument</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="main_layout"> + <item row="1" column="0"> + <widget class="QLabel" name="lbl_workspace"> + <property name="text"> + <string>Workspace</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="lbl_instrument_file"> + <property name="text"> + <string>Instrument Definition File</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="lbl_instrument_name"> + <property name="text"> + <string>Instrument Name</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="lbl_idf_xml"> + <property name="text"> + <string>Instrument Definition XML</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="txt_idf"/> + </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="ck_rewrite_spec_map"> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> + <property name="text"> + <string>RewriteSpectraMap</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <layout class="QHBoxLayout" name="idf_validator_layout"> + <item row="2" column="3"> + <widget class="QLineEdit" name="txt_instrument_name"/> + </item> + </layout> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="txt_instrument_xml"/> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="btn_idf"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="MantidQt::MantidWidgets::WorkspaceSelector" name="workspaceSelector"/> + </item> + <item row="1" column="2"> + <layout class="QHBoxLayout" name="ws_validator_layout"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="controls"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>MantidQt::MantidWidgets::WorkspaceSelector</class> + <extends>QComboBox</extends> + <header>MantidQtMantidWidgets/WorkspaceSelector.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>controls</sender> + <signal>accepted()</signal> + <receiver>Dialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>controls</sender> + <signal>rejected()</signal> + <receiver>Dialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/Code/Mantid/MantidQt/CustomDialogs/src/LoadInstrumentDialog.cpp b/Code/Mantid/MantidQt/CustomDialogs/src/LoadInstrumentDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..802f1e232ff7d17fb739053f8a837c81f49c6dad --- /dev/null +++ b/Code/Mantid/MantidQt/CustomDialogs/src/LoadInstrumentDialog.cpp @@ -0,0 +1,96 @@ +#include "MantidQtCustomDialogs/LoadInstrumentDialog.h" + +#include <QFileDialog> +#include <QDir> +#include <QBoxLayout> +#include <QMessageBox> + +using namespace Mantid::API; + +namespace MantidQt +{ + namespace CustomDialogs + { + DECLARE_DIALOG(LoadInstrumentDialog); + + /** + Constructor + @param parent : parent widget + */ + LoadInstrumentDialog::LoadInstrumentDialog(QWidget* parent) : AlgorithmDialog(parent) + { + } + + + /// Set up the dialog layout + void LoadInstrumentDialog::initLayout() + { + ui.setupUi(this); + this->setWindowTitle(m_algName); + + // Add the description of the algorithm text to the dialog. + QVBoxLayout* tempLayout = new QVBoxLayout; + this->addOptionalMessage(tempLayout); + ui.main_layout->addLayout(tempLayout, 0, 0, 1, 3); + + tie(ui.workspaceSelector, "Workspace", ui.ws_validator_layout); + tie(ui.txt_idf, "Filename", ui.idf_validator_layout); + tie(ui.txt_instrument_name, "InstrumentName"); + tie(ui.txt_instrument_xml, "InstrumentXML"); + tie(ui.ck_rewrite_spec_map, "RewriteSpectraMap"); + + ui.workspaceSelector->setValidatingAlgorithm(m_algName); + + connect(ui.controls, SIGNAL(accepted()), this, SLOT(accept())); + + connect(ui.ck_rewrite_spec_map, SIGNAL(clicked(bool)), this, SLOT(onRewriteSpectraMapClicked(bool))); + } + + /** + Event handler for the browsing click event. + */ + void LoadInstrumentDialog::onBrowse() + { + QFileDialog dialog; + dialog.setDirectory(QDir::homePath()); + dialog.setNameFilter("IDF (*.xml)"); + if (dialog.exec()) + { + ui.txt_idf->setText(dialog.selectedFile()); + } + } + + /** + Event handler for the accepted slot. Called when the user wishes to execute the algorithm. + + Provides additional confirmation that the spectra-detector map will be overwritten if selected. + */ + void LoadInstrumentDialog::accept() + { + if(ui.ck_rewrite_spec_map->isChecked()) + { + QMessageBox warningBox; + warningBox.setText("Are you sure you want to re-write the spectra detector map with a 1:1 mapping?."); + warningBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + int result = warningBox.exec(); + if(result == QMessageBox::Cancel) + { + ui.ck_rewrite_spec_map->setChecked(false); + } + else + { + AlgorithmDialog::accept(); + } + } + + } + + /** + Destructor + */ + LoadInstrumentDialog::~LoadInstrumentDialog() + { + } + + } +} \ No newline at end of file