Skip to content
Snippets Groups Projects
Commit 46eae78f authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #5422 Update ForCE to use load analysers and reflections.

parent 5197612f
No related merge requests found
......@@ -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;
......
......@@ -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/>
......
#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
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