From f28fcd9ef52ea6b62d6836a62d1599e891583f42 Mon Sep 17 00:00:00 2001 From: Mathieu Doucet <doucetm@ornl.gov> Date: Mon, 11 Apr 2011 00:52:40 +0000 Subject: [PATCH] Added instrument update. Re #1732 --- Code/Mantid/instrument/BIOSANS_Parameters.xml | 4 +++ .../settings/application_settings.py | 11 ++++++- .../widgets/sans/hfir_instrument.py | 17 +++++++++++ .../widgets/sans/hfir_sample_data.py | 3 ++ .../Interface/ui/sans/hfir_instrument.ui | 30 +++++++++++++++++++ .../Interface/ui/sans/ui_hfir_instrument.py | 18 ++++++++++- 6 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Code/Mantid/instrument/BIOSANS_Parameters.xml b/Code/Mantid/instrument/BIOSANS_Parameters.xml index 6fa132de846..8439113b612 100644 --- a/Code/Mantid/instrument/BIOSANS_Parameters.xml +++ b/Code/Mantid/instrument/BIOSANS_Parameters.xml @@ -31,6 +31,10 @@ <value val="5.1000000"/> </parameter> +<parameter name="detector-distance-offset"> + <value val="837.9"/> +</parameter> + <!-- Aperture distances for 8 guides to 0 guides --> <parameter name="aperture-distances" type="string"> <value val="2018.0, 3426.9, 5449.1, 7473.8, 9497.2, 11527.1, 13546.6, 15568.2, 17594.6" /> diff --git a/Code/Mantid/scripts/Interface/reduction_gui/settings/application_settings.py b/Code/Mantid/scripts/Interface/reduction_gui/settings/application_settings.py index 4747fc031fd..9f002126764 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/settings/application_settings.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/settings/application_settings.py @@ -1,6 +1,6 @@ from PyQt4 import QtGui, QtCore -class GeneralSettings(object): +class GeneralSettings(QtCore.QObject): """ Settings class that will be passed from the main application to the control widgets. @@ -11,14 +11,23 @@ class GeneralSettings(object): last_file = '' instrument_name = '' + data_updated = QtCore.pyqtSignal('PyQt_PyObject','PyQt_PyObject') + def __init__(self, settings=None): """ Initialization. @param settings: QSettings object passed by the main application """ + super(GeneralSettings, self).__init__() if settings is not None: self.from_settings(settings) + def emit_key_value(self, key, value): + """ + Emit a signal to alert listeners of key/value update + """ + self.data_updated.emit(key, value) + def to_settings(self, settings): """ Write the current settings to a QSettings object diff --git a/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py b/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py index 30658aac70e..bb2d1078e9a 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py @@ -40,6 +40,23 @@ class SANSInstrumentWidget(BaseWidget): if settings is None: settings = GeneralSettings() self._settings = settings + # Connect do UI data update + self._settings.data_updated.connect(self._data_updated) + + def _data_updated(self, key, value): + """ + Respond to application-level key/value pair updates. + @param key: key string + @param value: value string + """ + if key == "sample_detector_distance": + self._summary.sample_dist_edit.setText(QtCore.QString(str(value))) + util._check_and_get_float_line_edit(self._summary.sample_dist_edit, min=0.0) + elif key == "wavelength": + self._summary.wavelength_edit.setText(QtCore.QString(str(value))) + util._check_and_get_float_line_edit(self._summary.wavelength_edit, min=0.0) + elif key == "wavelength_spread": + self._summary.wavelength_spread_edit.setText(QtCore.QString(str(value))) def content(self): return self._summary diff --git a/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py b/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py index 01ffc38ca24..6f1f1cd448f 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py @@ -374,9 +374,12 @@ class SampleDataWidget(BaseWidget): if dataproxy.sample_detector_distance is not None: self._content.sample_dist_edit.setText(QtCore.QString(str(dataproxy.sample_detector_distance))) util._check_and_get_float_line_edit(self._content.sample_dist_edit, min=0.0) + self._settings.emit_key_value("sample_detector_distance", QtCore.QString(str(dataproxy.sample_detector_distance))) if dataproxy.wavelength is not None: self._content.wavelength_edit.setText(QtCore.QString(str(dataproxy.wavelength))) util._check_and_get_float_line_edit(self._content.wavelength_edit, min=0.0) + self._settings.emit_key_value("wavelength", QtCore.QString(str(dataproxy.wavelength))) if dataproxy.wavelength_spread is not None: self._content.wavelength_spread_edit.setText(QtCore.QString(str(dataproxy.wavelength_spread))) + self._settings.emit_key_value("wavelength_spread", QtCore.QString(str(dataproxy.wavelength_spread))) \ No newline at end of file diff --git a/Code/Mantid/scripts/Interface/ui/sans/hfir_instrument.ui b/Code/Mantid/scripts/Interface/ui/sans/hfir_instrument.ui index b24a36eb49b..c915e81c799 100644 --- a/Code/Mantid/scripts/Interface/ui/sans/hfir_instrument.ui +++ b/Code/Mantid/scripts/Interface/ui/sans/hfir_instrument.ui @@ -580,6 +580,36 @@ in each direction and will create 9 sub-pixels.</string> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> </property> <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <layout class="QHBoxLayout" name="mask_template_horiz_layout"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="experiment_parameter_help"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true">font: italic 10pt "Bitstream Charter";</string> + </property> + <property name="text"> + <string>The sample-detector distance and wavelength are updated automatically when a sample data file is selected. +Values can be selected by hand by checking the boxes below.</string> + </property> + </widget> + </item> + </layout> + </item> <item> <layout class="QFormLayout" name="formLayout_3"> <property name="sizeConstraint"> diff --git a/Code/Mantid/scripts/Interface/ui/sans/ui_hfir_instrument.py b/Code/Mantid/scripts/Interface/ui/sans/ui_hfir_instrument.py index 4ce2b584201..9c09b0d6219 100644 --- a/Code/Mantid/scripts/Interface/ui/sans/ui_hfir_instrument.py +++ b/Code/Mantid/scripts/Interface/ui/sans/ui_hfir_instrument.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'ui/sans/hfir_instrument.ui' # -# Created: Sat Apr 2 10:52:57 2011 +# Created: Sun Apr 10 18:49:54 2011 # by: PyQt4 UI code generator 4.7.2 # # WARNING! All changes made in this file will be lost! @@ -225,6 +225,20 @@ class Ui_Frame(object): self.geometry_options_groupbox.setObjectName("geometry_options_groupbox") self.verticalLayout_5 = QtGui.QVBoxLayout(self.geometry_options_groupbox) self.verticalLayout_5.setObjectName("verticalLayout_5") + self.mask_template_horiz_layout = QtGui.QHBoxLayout() + self.mask_template_horiz_layout.setSpacing(0) + self.mask_template_horiz_layout.setObjectName("mask_template_horiz_layout") + self.experiment_parameter_help = QtGui.QLabel(self.geometry_options_groupbox) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.experiment_parameter_help.sizePolicy().hasHeightForWidth()) + self.experiment_parameter_help.setSizePolicy(sizePolicy) + self.experiment_parameter_help.setMinimumSize(QtCore.QSize(150, 0)) + self.experiment_parameter_help.setStyleSheet("font: italic 10pt \"Bitstream Charter\";") + self.experiment_parameter_help.setObjectName("experiment_parameter_help") + self.mask_template_horiz_layout.addWidget(self.experiment_parameter_help) + self.verticalLayout_5.addLayout(self.mask_template_horiz_layout) self.formLayout_3 = QtGui.QFormLayout() self.formLayout_3.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint) self.formLayout_3.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) @@ -453,6 +467,8 @@ class Ui_Frame(object): self.log_binning_radio.setToolTip(QtGui.QApplication.translate("Frame", "Select to use logarithmic binning for I(Q).", None, QtGui.QApplication.UnicodeUTF8)) self.log_binning_radio.setText(QtGui.QApplication.translate("Frame", "Log binning", None, QtGui.QApplication.UnicodeUTF8)) self.geometry_options_groupbox.setTitle(QtGui.QApplication.translate("Frame", "Experiment Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.experiment_parameter_help.setText(QtGui.QApplication.translate("Frame", "The sample-detector distance and wavelength are updated automatically when a sample data file is selected.\n" +"Values can be selected by hand by checking the boxes below.", None, QtGui.QApplication.UnicodeUTF8)) self.detector_offset_chk.setToolTip(QtGui.QApplication.translate("Frame", "Select to set the detector distance offset.", None, QtGui.QApplication.UnicodeUTF8)) self.detector_offset_chk.setText(QtGui.QApplication.translate("Frame", "Detector distance offset [mm]", None, QtGui.QApplication.UnicodeUTF8)) self.detector_offset_edit.setToolTip(QtGui.QApplication.translate("Frame", "Enter the detector distance offset in mm.", None, QtGui.QApplication.UnicodeUTF8)) -- GitLab