Skip to content

Commit

Permalink
Merge branch 'feature/10266_idr_instrument_common_to_all_tabs' into d…
Browse files Browse the repository at this point in the history
…evelop

Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp

Refs #10266
  • Loading branch information
DanNixon committed Nov 4, 2014
2 parents 839270e + b0d950e commit ef2e4cb
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 379 deletions.
Expand Up @@ -47,12 +47,8 @@ namespace CustomInterfaces
virtual void run();
virtual bool validate();

void setIDFValues(const QString & prefix);

private slots:
void clearReflectionInfo(); ///< clear various line edit boxes
void analyserSelected(int index); ///< set up cbReflection based on Analyser selection
void reflectionSelected(int index); ///< set up parameter file values based on reflection
void setInstrumentDefault(); ///< Sets default parameters for current instrument
void mappingOptionSelected(const QString& groupType); ///< change ui to display appropriate options
void backgroundClicked(); ///< handles showing and hiding m_backgroundDialog
void backgroundRemoval(); ///< handles data from BG
Expand Down
Expand Up @@ -22,10 +22,10 @@ namespace MantidQt
//-------------------------------------------
class IndirectDataReductionTab;

/**
/**
This class defines the IndirectDataReduction interface. It handles the overall instrument settings
and sets up the appropriate interface depending on the deltaE mode of the instrument. The deltaE
mode is defined in the instrument definition file using the "deltaE-mode".
mode is defined in the instrument definition file using the "deltaE-mode".
@author Martyn Gigg, Tessella Support Services plc
@author Michael Whitty
Expand All @@ -48,7 +48,7 @@ namespace MantidQt
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/

class IndirectDataReduction : public MantidQt::API::UserSubWindow
Expand All @@ -67,40 +67,58 @@ namespace MantidQt

/// Initialize the layout
virtual void initLayout();
/// run Python-based initialisation commands
/// Run Python-based initialisation commands
virtual void initLocalPython();
/// gather necessary information from Instument Definition Files
virtual void setIDFValues(const QString & prefix);
/// perform any instrument-specific changes to layout
void performInstSpecific();

void handleDirectoryChange(Mantid::Kernel::ConfigValChangeNotification_ptr pNf); ///< handle POCO event
/// Handled configuration changes
void handleDirectoryChange(Mantid::Kernel::ConfigValChangeNotification_ptr pNf);

Mantid::API::MatrixWorkspace_sptr loadInstrumentIfNotExist(std::string instrumentName,
std::string analyser = "", std::string reflection = "");

std::vector<std::pair<std::string, std::vector<std::string> > > getInstrumentModes();

signals:
/// Emitted when the instrument setup is changed
void newInstrumentConfiguration();

private slots:
/// Opens the help page for the current tab
void helpClicked();
/// Runs the current tab
void runClicked();
void instrumentLoadingDone(bool error);

void userSelectInstrument(const QString& name);
/// Opens the manage directory dialog
void openDirectoryDialog();
void showMessageBox(const QString& message); /// Slot showing a message box to the user

/// Shows a information dialog box
void showMessageBox(const QString& message);
/// Updates the state of the Run button
void updateRunButton(bool enabled = true, QString message = "Run", QString tooltip = "");

/// Called when the load instrument algorithms complete
void instrumentLoadingDone(bool error);

/// Called when an instrument is selected from the combo box
void instrumentSelected(const QString& prefix);
/// Called when an analyser is selected form the combo box
void analyserSelected(int index);
/// Called when the instrument setup has been changed
void instrumentSetupChanged();

private:
void updateAnalyserList();

void readSettings();
void saveSettings();

void setDefaultInstrument(const QString & name);
void instrumentSelectChanged(const QString& name);

/// Set and show an instrument-specific widget
void setInstSpecificWidget(const std::string & parameterName, QCheckBox * checkBox, QCheckBox::ToggleState defaultState);
virtual void closeEvent(QCloseEvent* close);

/// The .ui form generated by Qt Designer
Ui::IndirectDataReduction m_uiForm;
/// Instrument the interface is currently set for.
QString m_curInterfaceSetup;
QString m_instrument;
/// The settings group
QString m_settingsGroup;
/// Runner for insturment load algorithm
Expand Down
Expand Up @@ -18,6 +18,80 @@
<property name="topMargin">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="gbC2EInstrument">
<property name="title">
<string>Instrument</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<property name="topMargin">
<number>1</number>
</property>
<item>
<widget class="MantidQt::MantidWidgets::InstrumentSelector" name="cbInst">
<property name="techniques" stdset="0">
<stringlist>
<string>TOF Indirect Geometry Spectroscopy</string>
</stringlist>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lbAnalyser">
<property name="text">
<string>Analyser</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbAnalyser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select Analyser bank to use.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbReflection">
<property name="text">
<string>Reflection</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbReflection">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select Reflection used for experiment(s).</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
Expand All @@ -43,80 +117,6 @@
<string>Energy Transfer</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="gbC2EInstrument">
<property name="title">
<string>Instrument</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<property name="topMargin">
<number>1</number>
</property>
<item>
<widget class="MantidQt::MantidWidgets::InstrumentSelector" name="cbInst">
<property name="techniques" stdset="0">
<stringlist>
<string>TOF Indirect Geometry Spectroscopy</string>
</stringlist>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lbAnalyser">
<property name="text">
<string>Analyser</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbAnalyser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select Analyser bank to use.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbReflection">
<property name="text">
<string>Reflection</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbReflection">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Select Reflection used for experiment(s).</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbConvertToEnergyInput">
<property name="title">
Expand Down Expand Up @@ -921,6 +921,19 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item>
<spacer name="etLayoutSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="gbSave">
<property name="title">
Expand Down
Expand Up @@ -82,8 +82,6 @@ namespace CustomInterfaces

protected:
Mantid::API::MatrixWorkspace_sptr loadInstrumentIfNotExist(std::string instrumentName, std::string analyser="", std::string reflection="");
/// Get information about the operation modes of an indirect instrument
std::vector<std::pair<std::string, std::vector<std::string> > > getInstrumentModes(std::string instrumentName);
/// Function to get details about the instrument configuration defined on C2E tab
std::map<QString, QString> getInstrumentDetails();

Expand All @@ -94,10 +92,14 @@ namespace CustomInterfaces
signals:
/// Update the Run button on the IDR main window
void updateRunButton(bool enabled = true, QString message = "Run", QString tooltip = "");
/// Emitted when the instrument setup is changed
void newInstrumentConfiguration();

private:
bool m_tabRunning;

QString getInstrumentParameterFrom(Mantid::Geometry::IComponent_const_sptr comp, std::string param);

private slots:
void tabExecutionComplete(bool error);

Expand Down
15 changes: 11 additions & 4 deletions Code/Mantid/MantidQt/CustomInterfaces/src/IndirectCalibration.cpp
Expand Up @@ -120,6 +120,9 @@ namespace CustomInterfaces
m_uiForm.cal_valIntensityScaleMultiplier->setText(" ");

// SIGNAL/SLOT CONNECTIONS
// Update instrument information when a new instrument config is selected
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setDefaultInstDetails()));

connect(m_rangeSelectors["ResPeak"], SIGNAL(rangeChanged(double, double)), m_rangeSelectors["ResBackground"], SLOT(setRange(double, double)));

// Update property map when a range seclector is moved
Expand Down Expand Up @@ -176,7 +179,9 @@ namespace CustomInterfaces
QString firstFile = m_uiForm.cal_leRunNo->getFirstFilename();
QString filenames = m_uiForm.cal_leRunNo->getFilenames().join(",");

QString detectorRange = m_uiForm.leSpectraMin->text() + "," + m_uiForm.leSpectraMax->text();
auto instDetails = getInstrumentDetails();
QString detectorRange = instDetails["spectra-min"] + "," + instDetails["spectra-max"];

QString peakRange = m_properties["CalPeakMin"]->valueText() + "," + m_properties["CalPeakMax"]->valueText();
QString backgroundRange = m_properties["CalBackMin"]->valueText() + "," + m_properties["CalBackMax"]->valueText();

Expand Down Expand Up @@ -329,7 +334,11 @@ namespace CustomInterfaces
QFileInfo fi(filename);
QString wsname = fi.baseName();

if(!loadFile(filename, wsname, m_uiForm.leSpectraMin->text().toInt(), m_uiForm.leSpectraMax->text().toInt()))
auto instDetails = getInstrumentDetails();
int specMin = instDetails["spectra-min"].toInt();
int specMax = instDetails["spectra-max"].toInt();

if(!loadFile(filename, wsname, specMin, specMax))
{
emit showMessageBox("Unable to load file.\nCheck whether your file exists and matches the selected instrument in the Energy Transfer tab.");
return;
Expand Down Expand Up @@ -369,7 +378,6 @@ namespace CustomInterfaces
QFileInfo fi(m_uiForm.cal_leRunNo->getFirstFilename());
QString outWS = fi.baseName() + "_" + m_uiForm.cbAnalyser->currentText() +
m_uiForm.cbReflection->currentText() + "_red";
/* outWS = outWS.toLower(); */

QString detRange = QString::number(m_dblManager->value(m_properties["ResSpecMin"])) + ","
+ QString::number(m_dblManager->value(m_properties["ResSpecMax"]));
Expand All @@ -381,7 +389,6 @@ namespace CustomInterfaces
reductionAlg->setProperty("Reflection", m_uiForm.cbReflection->currentText().toStdString());
reductionAlg->setProperty("InputFiles", files.toStdString());
reductionAlg->setProperty("DetectorRange", detRange.toStdString());
/* reductionAlg->setProperty("", ""); */
reductionAlg->execute();

Mantid::API::MatrixWorkspace_sptr input = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
Expand Down

0 comments on commit ef2e4cb

Please sign in to comment.