Skip to content

Commit

Permalink
Refs #9457 - Add temp SANS2DTUBES option to GUI.
Browse files Browse the repository at this point in the history
Replaced InstrumentSelector widget with plain QComboBox, as it was the
easiest way to get SANS2DTUBES in the dropdown.

Some nasty hacks to accomodate the new option.

Everything in this commit should be reversed upon completion of #9367.
  • Loading branch information
PeterParker committed May 14, 2014
1 parent c8049a8 commit 60abae4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 39 deletions.
Expand Up @@ -286,13 +286,7 @@
</widget>
</item>
<item>
<widget class="MantidQt::MantidWidgets::InstrumentSelector" name="inst_opt">
<property name="techniques" stdset="0">
<stringlist>
<string>Small Angle Scattering</string>
</stringlist>
</property>
</widget>
<widget class="QComboBox" name="inst_opt"/>
</item>
</layout>
</item>
Expand Down Expand Up @@ -337,7 +331,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="scatterSample">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="scatterSample" native="true">
<property name="toolTip">
<string>The run with the sample under investigation</string>
</property>
Expand All @@ -353,7 +347,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="scatCan">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="scatCan" native="true">
<property name="toolTip">
<string>The run with the sample under investigation</string>
</property>
Expand Down Expand Up @@ -394,7 +388,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="transmis">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="transmis" native="true">
<property name="toolTip">
<string>The run with the sample under investigation</string>
</property>
Expand All @@ -413,7 +407,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="transCan">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="transCan" native="true">
<property name="toolTip">
<string>The run with the sample under investigation</string>
</property>
Expand Down Expand Up @@ -454,7 +448,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="direct">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="direct" native="true">
<property name="toolTip">
<string>The run with the sample under investigation</string>
</property>
Expand All @@ -473,7 +467,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="dirCan">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="dirCan" native="true">
<property name="toolTip">
<string>The run with the sample under investigation</string>
</property>
Expand Down Expand Up @@ -559,8 +553,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="file_opt">
</widget>
<widget class="QComboBox" name="file_opt"/>
</item>
</layout>
</item>
Expand Down Expand Up @@ -1903,7 +1896,7 @@ intermediate ranges are there for comparison</string>
</widget>
</item>
<item>
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="floodRearFile">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="floodRearFile" native="true">
<property name="findRunFiles" stdset="0">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -1933,7 +1926,7 @@ intermediate ranges are there for comparison</string>
</widget>
</item>
<item>
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="floodFrontFile">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="floodFrontFile" native="true">
<property name="findRunFiles" stdset="0">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -3239,8 +3232,8 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<widget class="MantidQt::MantidWidgets::MessageDisplay" name="centre_logging">
<property name="source">
<widget class="MantidQt::MantidWidgets::MessageDisplay" name="centre_logging" native="true">
<property name="source" stdset="0">
<string>CentreFinder</string>
</property>
</widget>
Expand Down Expand Up @@ -3590,8 +3583,8 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="0">
<widget class="MantidQt::MantidWidgets::MessageDisplay" name="logging_field">
<property name="source">
<widget class="MantidQt::MantidWidgets::MessageDisplay" name="logging_field" native="true">
<property name="source" stdset="0">
<string>SANS</string>
</property>
</widget>
Expand Down Expand Up @@ -3849,7 +3842,7 @@ p, li { white-space: pre-wrap; }
<number>6</number>
</property>
<item row="0" column="0">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="file_run_edit">
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="file_run_edit" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -4110,11 +4103,6 @@ p, li { white-space: pre-wrap; }
<extends>QWidget</extends>
<header>MantidQtMantidWidgets/MWRunFiles.h</header>
</customwidget>
<customwidget>
<class>MantidQt::MantidWidgets::InstrumentSelector</class>
<extends>QComboBox</extends>
<header>MantidQtMantidWidgets/InstrumentSelector.h</header>
</customwidget>
<customwidget>
<class>MantidQt::MantidWidgets::MessageDisplay</class>
<extends>QWidget</extends>
Expand Down
35 changes: 23 additions & 12 deletions Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp
Expand Up @@ -147,6 +147,10 @@ void SANSRunWindow::initLayout()
{
g_log.debug("Initializing interface layout");
m_uiForm.setupUi(this);
m_uiForm.inst_opt->addItem("LARMOR");
m_uiForm.inst_opt->addItem("LOQ");
m_uiForm.inst_opt->addItem("SANS2D");
m_uiForm.inst_opt->addItem("SANS2DTUBES");

m_reducemapper = new QSignalMapper(this);

Expand Down Expand Up @@ -692,8 +696,7 @@ bool SANSRunWindow::loadUserFile()
}

QString pyCode = "i.Clean()";
pyCode += "\ni.ReductionSingleton().set_instrument(isis_instrument.";
pyCode += getInstrumentClass()+")";
pyCode += "\ni." + getInstrumentClass();
pyCode += "\ni.ReductionSingleton().user_settings =";
// Use python function to read the settings file and then extract the fields
pyCode += "isis_reduction_steps.UserFile(r'"+filetext+"')";
Expand Down Expand Up @@ -1597,7 +1600,7 @@ void SANSRunWindow::setGeometryDetails()
setLOQGeometry(can_workspace, 1);
}
}
else if( m_uiForm.inst_opt->currentText() == "SANS2D" )
else if( m_uiForm.inst_opt->currentText() == "SANS2D" || m_uiForm.inst_opt->currentText() == "SANS2DTUBES")
{
if( colour == "red" )
{
Expand Down Expand Up @@ -2366,7 +2369,7 @@ void SANSRunWindow::handleReduceButtonClick(const QString & typeStr)
if (runMode == SingleMode) // TODO: test if it is really necessary to reload the file settings.
{
py_code = "\ni.ReductionSingleton.clean(isis_reducer.ISISReducer)";
py_code += "\ni.ReductionSingleton().set_instrument(isis_instrument."+getInstrumentClass()+")";
py_code += "\ni." + getInstrumentClass();
//restore the settings from the user file
py_code += "\ni.ReductionSingleton().user_file_path='"+
QFileInfo(m_uiForm.userfile_edit->text()).path() + "'";
Expand Down Expand Up @@ -2565,7 +2568,7 @@ void SANSRunWindow::handleRunFindCentre()
{
m_uiForm.beam_rmax->setText("200");
}
else if( m_uiForm.inst_opt->currentText() == "SANS2D" )
else if( m_uiForm.inst_opt->currentText() == "SANS2D" || m_uiForm.inst_opt->currentText() == "SANS2DTUBES")
{
m_uiForm.beam_rmax->setText("280");
}
Expand Down Expand Up @@ -2644,8 +2647,7 @@ void SANSRunWindow::handleRunFindCentre()
}
}
QString pyCode = "i.ReductionSingleton.clean(isis_reducer.ISISReducer)";
pyCode += "\ni.ReductionSingleton().set_instrument(isis_instrument.";
pyCode += getInstrumentClass()+")";
pyCode += "\ni." + getInstrumentClass();
pyCode += "\ni.ReductionSingleton().user_settings =";
// Use python function to read the settings file and then extract the fields
pyCode += "isis_reduction_steps.UserFile(r'"+m_uiForm.userfile_edit->text().trimmed()+"')";
Expand Down Expand Up @@ -2817,7 +2819,17 @@ void SANSRunWindow::handleInstrumentChange()
}

// need this if facility changed to force update of technique at this point
m_uiForm.inst_opt->setTechniques(m_uiForm.inst_opt->getTechniques());
// m_uiForm.inst_opt->setTechniques(m_uiForm.inst_opt->getTechniques());

if( m_uiForm.inst_opt->currentText() == "SANS2DTUBES" )
ConfigService::Instance().setString("default.instrument", "SANS2D");
else
ConfigService::Instance().setString("default.instrument", m_uiForm.inst_opt->currentText().toStdString());

// Hide the "SANS2D_EVENT" instrument, if present.
const int sans2dEventIndex = m_uiForm.inst_opt->findText("SANS2D_EVENT");
if( sans2dEventIndex != -1 )
m_uiForm.inst_opt->removeItem(sans2dEventIndex);

//set up the required Python objects and delete what's out of date (perhaps everything is cleaned here)
const QString instClass(getInstrumentClass());
Expand All @@ -2826,12 +2838,11 @@ void SANSRunWindow::handleInstrumentChange()
// This is useful on interface start up, where we have already loaded the user file
// and don't want to set the instrument twice.
const QString currentInstName = runPythonCode(
"print i.ReductionSingleton().get_instrument().name()").trimmed();
"print i.ReductionSingleton().get_instrument().versioned_name()").trimmed();
if( currentInstName != m_uiForm.inst_opt->currentText() )
{
QString pyCode("i.ReductionSingleton.clean(isis_reducer.ISISReducer)");
pyCode += "\ni.ReductionSingleton().set_instrument(isis_instrument.";
pyCode += instClass+")";
pyCode += "\ni." + instClass;
runReduceScriptFunction(pyCode);
}

Expand All @@ -2853,7 +2864,7 @@ void SANSRunWindow::handleInstrumentChange()
m_uiForm.geom_stack->setCurrentIndex(0);

}
else if ( instClass == "SANS2D()" )
else if ( instClass == "SANS2D()" || instClass == "SANS2DTUBES()")
{
m_uiForm.beam_rmax->setText("280");

Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/scripts/SANS/isis_instrument.py
Expand Up @@ -41,6 +41,16 @@ def name(self):
Return the name of the instrument
"""
return self._NAME

def versioned_name(self):
"""
Hack-workaround so that we may temporarily display "SANS2DTUBES" as
an option in the instrument dropdown menu in the interface. To be removed
as part of #9367.
"""
if "SANS2D_Definition_Tubes" in self.idf_path:
return "SANS2DTUBES"
return self._NAME

def view(self, workspace_name = None):
"""
Expand Down

0 comments on commit 60abae4

Please sign in to comment.