Skip to content

Commit

Permalink
Moved inst loading and UI code to IndirectDataReduction
Browse files Browse the repository at this point in the history
Refs #10266
  • Loading branch information
DanNixon committed Nov 4, 2014
1 parent 25485a5 commit 22ad3e6
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 165 deletions.
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,45 +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);

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

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

void instrumentChanged();
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:
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();

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 @@ -82,8 +82,6 @@ namespace CustomInterfaces
protected slots:
/// Slot to handle when an algorithm finishes running
virtual void algorithmFinished(bool error);
/// Emitted when the instrument setup is changed
void newInstrumentConfiguration(QString instrumentName, QString analyser, QString reflection);

protected:
/// Run the load algorithm with the given file name, output name and spectrum range
Expand Down Expand Up @@ -169,6 +167,8 @@ namespace CustomInterfaces
void runAsPythonScript(const QString & code, bool no_output);
/// 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);

private:
/// Overidden by child class.
Expand Down
Expand Up @@ -477,31 +477,6 @@ namespace CustomInterfaces
scaleMultiplierCheck(m_uiForm.ckScaleMultiplier->isChecked());

QString instName = m_uiForm.cbInst->currentText();
auto instModes = getInstrumentModes(instName.toStdString());

for(auto modesIt = instModes.begin(); modesIt != instModes.end(); ++modesIt)
{
QString analyser = QString::fromStdString(modesIt->first);
std::vector<std::string> reflections = modesIt->second;

if(analyser != "diffraction") // Do not put diffraction into the analyser list
{
if(reflections.size() > 0)
{
QStringList reflectionsList;
for(auto reflIt = reflections.begin(); reflIt != reflections.end(); ++reflIt)
reflectionsList.push_back(QString::fromStdString(*reflIt));
QVariant data = QVariant(reflectionsList);
m_uiForm.cbAnalyser->addItem(analyser, data);
}
else
{
m_uiForm.cbAnalyser->addItem(analyser);
}
}
}

analyserSelected(m_uiForm.cbAnalyser->currentIndex());
}

/**
Expand Down

0 comments on commit 22ad3e6

Please sign in to comment.