diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.h index 49d120f66c4083d005abc550c728932bb20512a0..0ec7889afb0df273c5907398cff0e577fb1efd86 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.h @@ -3,6 +3,9 @@ #include "ui_ForCE.h" #include "MantidQtCustomInterfaces/IndirectForeignTab.h" +#include "MantidAPI/ExperimentInfo.h" + +#include <QComboBox> namespace MantidQt { @@ -22,7 +25,16 @@ namespace MantidQt /// Load default settings into the interface void loadSettings(const QSettings& settings); + private slots: + /// Populate the analyser and reflection options on the interface + void instrumentChanged(const QString& instrument); + /// Populate the reflection option given the analyser + void analyserChanged(const QString& analyser); + private: + /// Load the IDF file and get the instrument + Mantid::Geometry::Instrument_const_sptr getInstrument(const QString& instrument); + //The ui form Ui::ForCE m_uiForm; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.ui b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.ui index a612f0bc67e3b41b3d3fc0bc2451de6cf3ff5d1e..6a49712ce328513209462b8684e9f7d0eb234cb6 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.ui +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ForCE.ui @@ -51,7 +51,13 @@ </widget> </item> <item> - <widget class="QComboBox" name="cbInstrument"/> + <widget class="MantidQt::MantidWidgets::InstrumentSelector" name="cbInstrument"> + <property name="techniques"> + <stringlist> + <string>Reactor Indirect Geometry Spectroscopy</string> + </stringlist> + </property> + </widget> </item> </layout> </item> @@ -221,6 +227,11 @@ <extends>QWidget</extends> <header>MantidQtMantidWidgets/MWRunFiles.h</header> </customwidget> + <customwidget> + <class>MantidQt::MantidWidgets::InstrumentSelector</class> + <extends>QComboBox</extends> + <header>MantidQtMantidWidgets/InstrumentSelector.h</header> + </customwidget> </customwidgets> <resources/> <connections/> diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/ForCE.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/ForCE.cpp index 0d3f0301e097ce97118557518f80e08afb3135a2..8371e3d7d8df6d325a8307574c4e215b38a4aba8 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/ForCE.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/ForCE.cpp @@ -1,6 +1,10 @@ +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/ExperimentInfo.h" +#include "MantidAPI/MatrixWorkspace.h" #include "MantidQtCustomInterfaces/ForCE.h" #include <QFileInfo> +#include <QStringList> namespace MantidQt { @@ -11,6 +15,14 @@ namespace MantidQt { m_uiForm.setupUi(parent); + connect(m_uiForm.cbInstrument, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(instrumentChanged(const QString&))); + connect(m_uiForm.cbAnalyser, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(analyserChanged(const QString&))); + + // Setup analysers and reflections + QString currentIntrument = m_uiForm.cbInstrument->currentText(); + instrumentChanged(currentIntrument); + QString currentAnalyser = m_uiForm.cbAnalyser->currentText(); + analyserChanged(currentAnalyser); } /** @@ -20,7 +32,6 @@ namespace MantidQt */ bool ForCE::validate() { - return true; } @@ -82,5 +93,68 @@ namespace MantidQt { m_uiForm.mwRun->readSettings(settings.group()); } + + /** + * Set the analyser and reflection options when the instrument changes. + * + * @param settings :: The settings to loading into the interface + */ + void ForCE::instrumentChanged(const QString& instrument) + { + using namespace Mantid::API; + + auto inst = getInstrument(instrument); + if(inst) + { + auto analysers = inst->getStringParameter("analysers"); + + m_uiForm.cbAnalyser->clear(); + + if( analysers.size() > 0 ) + { + QStringList refs = QString(analysers[0].c_str()).split(','); + m_uiForm.cbAnalyser->addItems(refs); + } + } + } + + Mantid::Geometry::Instrument_const_sptr ForCE::getInstrument(const QString& instrument) + { + using namespace Mantid::API; + + std::string idfPath = ExperimentInfo::getInstrumentFilename(instrument.toStdString()); + Algorithm_sptr loadEmptyInst = AlgorithmManager::Instance().createUnmanaged("LoadEmptyInstrument", -1); + + loadEmptyInst->initialize(); + loadEmptyInst->setChild(true); + loadEmptyInst->setRethrows(true); + loadEmptyInst->setPropertyValue("Filename", idfPath); + loadEmptyInst->setPropertyValue("OutputWorkspace", "__" + instrument.toStdString() + "_defintion"); + loadEmptyInst->executeAsChildAlg(); + + MatrixWorkspace_sptr idfWs = loadEmptyInst->getProperty("OutputWorkspace"); + return idfWs->getInstrument(); + } + + void ForCE::analyserChanged(const QString& analyser) + { + using namespace Mantid::API; + + auto inst = getInstrument(m_uiForm.cbInstrument->currentText()); + + m_uiForm.cbReflection->clear(); + + if(inst) + { + auto reflections = inst->getStringParameter("refl-"+analyser.toStdString()); + + if( reflections.size() > 0 ) + { + QStringList refs = QString(reflections[0].c_str()).split(','); + m_uiForm.cbReflection->addItems(refs); + } + } + } + } // namespace CustomInterfaces } // namespace MantidQt diff --git a/Code/Mantid/instrument/IN13_Definition_xml b/Code/Mantid/instrument/IN13_Definition.xml similarity index 100% rename from Code/Mantid/instrument/IN13_Definition_xml rename to Code/Mantid/instrument/IN13_Definition.xml