Skip to content

Commit

Permalink
Re-add convert to energy
Browse files Browse the repository at this point in the history
Refs #10266
  • Loading branch information
DanNixon committed Nov 4, 2014
1 parent 4d0af24 commit 2810681
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 86 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 @@ -75,7 +75,7 @@ namespace MantidQt

signals:
/// Emitted when the instrument setup is changed
void newInstrumentConfiguration(QString instrumentName, QString analyser, QString reflection);
void newInstrumentConfiguration();

private slots:
/// Opens the help page for the current tab
Expand Down
Expand Up @@ -168,7 +168,7 @@ namespace CustomInterfaces
/// 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(QString instrumentName, QString analyser, QString reflection);
void newInstrumentConfiguration();

private:
/// Overidden by child class.
Expand Down
Expand Up @@ -28,10 +28,8 @@ namespace CustomInterfaces
m_uiForm.entryRebinHigh->setValidator(m_valDbl);

// SIGNAL/SLOT CONNECTIONS
// Updates current analyser when analyser is selected from drop down
connect(m_uiForm.cbAnalyser, SIGNAL(activated(int)), this, SLOT(analyserSelected(int)));
// Updates current reflection when reflection is selected from drop down
connect(m_uiForm.cbReflection, SIGNAL(activated(int)), this, SLOT(reflectionSelected(int)));
// Update instrument information when a new instrument config is selected
connect(this, SIGNAL(newInstrumentConfiguration()), this, SLOT(setInstrumentDefault()));
// Shows required mapping option UI widgets when a new mapping option is selected from drop down
connect(m_uiForm.cbMappingOptions, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(mappingOptionSelected(const QString&)));
// Shows background removal dialog when user clicks Background Removal
Expand Down Expand Up @@ -82,6 +80,11 @@ namespace CustomInterfaces

void IndirectConvertToEnergy::setup()
{
detailedBalanceCheck(m_uiForm.ckDetailedBalance->isChecked());
scaleMultiplierCheck(m_uiForm.ckScaleMultiplier->isChecked());

// Load the default instrument parameters
setInstrumentDefault();
}

void IndirectConvertToEnergy::run()
Expand Down Expand Up @@ -318,48 +321,15 @@ namespace CustomInterfaces
return valid;
}

/**
* This function is called when the user selects an analyser from the cbAnalyser QComboBox
* object. It's main purpose is to initialise the values for the Reflection ComboBox.
* @param index :: Index of the value selected in the combo box.
*/
void IndirectConvertToEnergy::analyserSelected(int index)
{
// populate Reflection combobox with correct values for Analyser selected.
m_uiForm.cbReflection->clear();
clearReflectionInfo();

QVariant currentData = m_uiForm.cbAnalyser->itemData(index);
if ( currentData == QVariant::Invalid )
{
m_uiForm.lbReflection->setEnabled(false);
m_uiForm.cbReflection->setEnabled(false);
return;
}
else
{
m_uiForm.lbReflection->setEnabled(true);
m_uiForm.cbReflection->setEnabled(true);
QStringList reflections = currentData.toStringList();
for ( int i = 0; i < reflections.count(); i++ )
{
m_uiForm.cbReflection->addItem(reflections[i]);
}
}

reflectionSelected(m_uiForm.cbReflection->currentIndex());
}

/**
* This function is called when the user selects a reflection from the cbReflection QComboBox
* object.
* @param index :: Index of the value selected in the combo box.
* Called when the instrument has changed, used to update default values.
*/
void IndirectConvertToEnergy::reflectionSelected(int index)
void IndirectConvertToEnergy::setInstrumentDefault()
{
UNUSED_ARG(index);
// first, clear values in assosciated boxes:
clearReflectionInfo();
m_uiForm.leSpectraMin->clear();
m_uiForm.leSpectraMax->clear();
m_uiForm.leEfixed->clear();

std::map<QString, QString> instDetails = getInstrumentDetails();

Expand Down Expand Up @@ -456,40 +426,6 @@ namespace CustomInterfaces
m_uiForm.pbBack_2->setText("Background Removal (Off)");
}

/**
* This function holds any steps that must be performed on the selection of an instrument,
* for example loading values from the Instrument Definition File (IDF).
* @param prefix :: The selected instruments prefix in Mantid.
*/
void IndirectConvertToEnergy::setIDFValues(const QString & prefix)
{
UNUSED_ARG(prefix);

// empty ComboBoxes, LineEdits,etc of previous values
m_uiForm.cbAnalyser->clear();
m_uiForm.cbReflection->clear();
clearReflectionInfo();

rebinEntryToggle(m_uiForm.rebin_ckDNR->isChecked());
detailedBalanceCheck(m_uiForm.ckDetailedBalance->isChecked());
/* resCheck(m_uiForm.cal_ckRES->isChecked()); */

scaleMultiplierCheck(m_uiForm.ckScaleMultiplier->isChecked());

QString instName = m_uiForm.cbInst->currentText();
}

/**
* This function clears the values of the QLineEdit objec ts used to hold Reflection-specific
* information.
*/
void IndirectConvertToEnergy::clearReflectionInfo()
{
m_uiForm.leSpectraMin->clear();
m_uiForm.leSpectraMax->clear();
m_uiForm.leEfixed->clear();
}

/**
* This function will disable the necessary elements of the interface when the user selects "Do Not Rebin"
* and enable them again when this is de-selected.
Expand Down
Expand Up @@ -89,6 +89,8 @@ void IndirectDataReduction::helpClicked()
url += "Calibration";
else if ( tabName == "Diagnostics" )
url += "Diagnostics";
else if (tabName == "Symmetrise")
url += "Symmetrise";
else if ( tabName == "S(Q, w)" )
url += "SofQW";
else if (tabName == "Transmission")
Expand Down Expand Up @@ -125,7 +127,7 @@ void IndirectDataReduction::initLayout()
instrumentSelected(m_uiForm.cbInst->currentText());

// Create the tabs
/* m_tabs["Energy Transfer"] = new IndirectConvertToEnergy(m_uiForm, this); */
m_tabs["Energy Transfer"] = new IndirectConvertToEnergy(m_uiForm, this);
m_tabs["Calibration"] = new IndirectCalibration(m_uiForm, this);
m_tabs["Diagnostics"] = new IndirectDiagnostics(m_uiForm, this);
m_tabs["Transmission"] = new IndirectTransmission(m_uiForm, this);
Expand Down Expand Up @@ -156,7 +158,7 @@ void IndirectDataReduction::initLayout()
connect(it->second, SIGNAL(runAsPythonScript(const QString&, bool)), this, SIGNAL(runAsPythonScript(const QString&, bool)));
connect(it->second, SIGNAL(showMessageBox(const QString&)), this, SLOT(showMessageBox(const QString&)));
connect(it->second, SIGNAL(updateRunButton(bool, QString, QString)), this, SLOT(updateRunButton(bool, QString, QString)));
connect(this, SIGNAL(newInstrumentConfiguration(QString, QString, QString)), it->second, SIGNAL(newInstrumentConfiguration(QString, QString, QString))),
connect(this, SIGNAL(newInstrumentConfiguration()), it->second, SIGNAL(newInstrumentConfiguration())),
it->second->setupTab();
}
}
Expand Down Expand Up @@ -188,7 +190,7 @@ void IndirectDataReduction::instrumentSetupChanged()
if(instrumentName != "" && analyser != "" && reflection != "")
{
loadInstrumentIfNotExist(instrumentName.toStdString(), analyser.toStdString(), reflection.toStdString());
emit newInstrumentConfiguration(instrumentName, analyser, reflection);
emit newInstrumentConfiguration();
}
}

Expand Down

0 comments on commit 2810681

Please sign in to comment.