Skip to content

Commit

Permalink
Make TOF workspace grouping optional.
Browse files Browse the repository at this point in the history
Refs #10196.
  • Loading branch information
Harry Jeffery committed Sep 1, 2014
1 parent b5d5816 commit af28a8a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
25 changes: 16 additions & 9 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
Expand Up @@ -54,8 +54,9 @@ def __init__(self):
self.__instrumentRuns = None

self.__icat_download = False
self.__group_tof_workspaces = True

# Q Settings
# Q Settings
self.__generic_settings = "Mantid/ISISReflGui"
self.__live_data_settings = "Mantid/ISISReflGui/LiveData"
self.__search_settings = "Mantid/ISISReflGui/Search"
Expand All @@ -64,6 +65,7 @@ def __init__(self):
self.__ads_use_key = "AlgUse"
self.__live_data_frequency_key = "frequency"
self.__live_data_method_key = "method"
self.__group_tof_workspaces_key = "group_tof_workspaces"

#Setup instrument options with defaults assigned.
self.instrument_list = ['INTER', 'SURF', 'CRISP', 'POLREF']
Expand All @@ -89,11 +91,12 @@ def __init__(self):
settings.beginGroup(self.__generic_settings)

self.alg_use = settings.value(self.__ads_use_key, False, type=bool)

self.__icat_download = settings.value(self.__icat_download_key, False, type=bool)
self.__group_tof_workspaces = settings.value(self.__group_tof_workspaces_key, True, type=bool)

settings.setValue(self.__ads_use_key, self.alg_use)
settings.setValue(self.__icat_download_key, self.__icat_download)
settings.setValue(self.__group_tof_workspaces_key, self.__group_tof_workspaces)


settings.endGroup()
Expand Down Expand Up @@ -919,12 +922,13 @@ def _do_run(self, runno, row, which):
else:
wlam, wq, th = quick(loadedRun, trans=transmission_ws, theta=angle, tof_prefix="")

try:
tof_group = mtd["TOF"]
if not tof_group.contains(loadedRun):
tof_group.add(loadedRun)
except KeyError:
tof_group = GroupWorkspaces(InputWorkspaces=loadedRun, OutputWorkspace="TOF")
if self.__group_tof_workspaces:
if "TOF" in mtd:
tof_group = mtd["TOF"]
if not tof_group.contains(loadedRun):
tof_group.add(loadedRun)
else:
tof_group = GroupWorkspaces(InputWorkspaces=loadedRun, OutputWorkspace="TOF")

if ':' in runno:
runno = runno.split(':')[0]
Expand Down Expand Up @@ -1104,14 +1108,16 @@ def _options_dialog(self):
try:

dialog_controller = refl_options.ReflOptions(def_method = self.live_method, def_freq = self.live_freq,
def_alg_use = self.alg_use, def_icat_download=self.__icat_download)
def_alg_use = self.alg_use, def_icat_download=self.__icat_download,
def_group_tof_workspaces = self.__group_tof_workspaces)
if dialog_controller.exec_():

# Fetch the settings back off the controller
self.live_freq = dialog_controller.frequency()
self.live_method = dialog_controller.method()
self.alg_use = dialog_controller.useAlg()
self.__icat_download = dialog_controller.icatDownload()
self.__group_tof_workspaces = dialog_controller.groupTOFWorkspaces()

# Persist the settings
settings = QtCore.QSettings()
Expand All @@ -1122,6 +1128,7 @@ def _options_dialog(self):
settings.beginGroup(self.__generic_settings)
settings.setValue(self.__ads_use_key, self.alg_use)
settings.setValue(self.__icat_download_key, self.__icat_download)
settings.setValue(self.__group_tof_workspaces_key, self.__group_tof_workspaces)
settings.endGroup()
del settings
except Exception as ex:
Expand Down
11 changes: 10 additions & 1 deletion Code/Mantid/scripts/Interface/ui/reflectometer/refl_options.py
Expand Up @@ -17,7 +17,7 @@ class ReflOptions(QtGui.QDialog, refl_options_window.Ui_OptionsDialog):
__method_list = ["Add","Replace","Append"]
__icat_download = False

def __init__(self, def_method, def_freq, def_alg_use, def_icat_download):
def __init__(self, def_method, def_freq, def_alg_use, def_icat_download, def_group_tof_workspaces):
"""
Initialise the interface
"""
Expand All @@ -28,6 +28,7 @@ def __init__(self, def_method, def_freq, def_alg_use, def_icat_download):
self.__method = def_method
self.__frequency = def_freq
self.__icat_download = def_icat_download
self.__group_tof_workspaces = def_group_tof_workspaces


self.setupUi(self)
Expand All @@ -42,13 +43,15 @@ def __init__(self, def_method, def_freq, def_alg_use, def_icat_download):
self.dspinFrequency.setValue(def_freq)
self.checkAlg.setChecked(def_alg_use)
self.checkICATDownload.setChecked(def_icat_download)
self.checkGroupTOFWorkspaces.setChecked(def_group_tof_workspaces)


#connect update signals to functions
self.dspinFrequency.valueChanged.connect(self.__update_frequency)
self.comboAccMethod.activated.connect(self.__update_method)
self.checkAlg.clicked.connect(self.__update_Alg_use)
self.checkICATDownload.clicked.connect(self.__update_download_method)
self.checkGroupTOFWorkspaces.clicked.connect(self.__update_groupTOF_method)

def __update_Alg_use(self, checked):
self.__alg_use = checked
Expand All @@ -62,9 +65,15 @@ def __update_method(self, meth):
def __update_download_method(self, checked):
self.__icat_download = checked

def __update_groupTOF_method(self, checked):
self.__group_tof_workspaces = checked

def icatDownload(self):
return (self.__icat_download)

def groupTOFWorkspaces(self):
return self.__group_tof_workspaces

def frequency(self):
return self.__frequency

Expand Down
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'refl_options_window.ui'
#
# Created: Mon Aug 18 08:53:10 2014
# Created: Mon Sep 1 14:27:58 2014
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
Expand All @@ -26,7 +26,7 @@ def _translate(context, text, disambig):
class Ui_OptionsDialog(object):
def setupUi(self, OptionsDialog):
OptionsDialog.setObjectName(_fromUtf8("OptionsDialog"))
OptionsDialog.resize(330, 179)
OptionsDialog.resize(330, 194)
self.layoutLive = QtGui.QFormLayout(OptionsDialog)
self.layoutLive.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
self.layoutLive.setObjectName(_fromUtf8("layoutLive"))
Expand All @@ -45,15 +45,18 @@ def setupUi(self, OptionsDialog):
self.layoutLive.setWidget(1, QtGui.QFormLayout.FieldRole, self.dspinFrequency)
self.checkAlg = QtGui.QCheckBox(OptionsDialog)
self.checkAlg.setObjectName(_fromUtf8("checkAlg"))
self.layoutLive.setWidget(3, QtGui.QFormLayout.SpanningRole, self.checkAlg)
self.layoutLive.setWidget(2, QtGui.QFormLayout.SpanningRole, self.checkAlg)
self.checkICATDownload = QtGui.QCheckBox(OptionsDialog)
self.checkICATDownload.setObjectName(_fromUtf8("checkICATDownload"))
self.layoutLive.setWidget(5, QtGui.QFormLayout.SpanningRole, self.checkICATDownload)
self.layoutLive.setWidget(3, QtGui.QFormLayout.SpanningRole, self.checkICATDownload)
self.checkGroupTOFWorkspaces = QtGui.QCheckBox(OptionsDialog)
self.checkGroupTOFWorkspaces.setObjectName(_fromUtf8("checkGroupTOFWorkspaces"))
self.layoutLive.setWidget(4, QtGui.QFormLayout.SpanningRole, self.checkGroupTOFWorkspaces)
self.buttonsLive = QtGui.QDialogButtonBox(OptionsDialog)
self.buttonsLive.setOrientation(QtCore.Qt.Horizontal)
self.buttonsLive.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonsLive.setObjectName(_fromUtf8("buttonsLive"))
self.layoutLive.setWidget(6, QtGui.QFormLayout.SpanningRole, self.buttonsLive)
self.layoutLive.setWidget(5, QtGui.QFormLayout.SpanningRole, self.buttonsLive)
self.labelAccMethod.setBuddy(self.comboAccMethod)
self.labelFrequency.setBuddy(self.dspinFrequency)

Expand All @@ -68,4 +71,5 @@ def retranslateUi(self, OptionsDialog):
self.labelFrequency.setText(_translate("OptionsDialog", "Update Every", None))
self.checkAlg.setText(_translate("OptionsDialog", "Use ReflectometryReductionOneAuto Algorithm", None))
self.checkICATDownload.setText(_translate("OptionsDialog", "Download Files Using ICAT", None))
self.checkGroupTOFWorkspaces.setText(_translate("OptionsDialog", "Group TOF Workspaces", None))

Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>330</width>
<height>179</height>
<height>194</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -47,21 +47,28 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkAlg">
<property name="text">
<string>Use ReflectometryReductionOneAuto Algorithm</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkICATDownload">
<property name="text">
<string>Download Files Using ICAT</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="checkGroupTOFWorkspaces">
<property name="text">
<string>Group TOF Workspaces</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonsLive">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down

0 comments on commit af28a8a

Please sign in to comment.