From 22ad3e6deb0a2db2ddbde8886a995109bb44bba3 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 4 Nov 2014 10:17:57 +0000 Subject: [PATCH] Moved inst loading and UI code to IndirectDataReduction Refs #10266 --- .../IndirectDataReduction.h | 51 +-- .../IndirectDataReductionTab.h | 4 +- .../src/IndirectConvertToEnergy.cpp | 25 -- .../src/IndirectDataReduction.cpp | 313 +++++++++++------- 4 files changed, 228 insertions(+), 165 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReduction.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReduction.h index f8649f84703e..6afa0e559c37 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReduction.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReduction.h @@ -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 @@ -48,7 +48,7 @@ namespace MantidQt along with this program. If not, see . File change history is stored at: - Code Documentation is available at: + Code Documentation is available at: */ class IndirectDataReduction : public MantidQt::API::UserSubWindow @@ -67,37 +67,50 @@ 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 > > 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); @@ -105,7 +118,7 @@ namespace MantidQt /// 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 diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h index a1bd9a348ecd..4680d760cde0 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h @@ -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 @@ -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. diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectConvertToEnergy.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectConvertToEnergy.cpp index 7cf597b1e8d4..c7503d68e497 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectConvertToEnergy.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectConvertToEnergy.cpp @@ -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 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()); } /** diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReduction.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReduction.cpp index a8b010173bc7..c817f78fea2f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReduction.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReduction.cpp @@ -21,6 +21,7 @@ #include #include + //Add this class to the list of specialised dialogs in this namespace namespace MantidQt { @@ -30,16 +31,18 @@ namespace MantidQt } } + namespace { Mantid::Kernel::Logger g_log("IndirectDataReduction"); } + +using namespace Mantid::API; +using namespace Mantid::Geometry; using namespace MantidQt::CustomInterfaces; using namespace MantidQt; -//---------------------- -// Public member functions -//---------------------- + /** * Default constructor for class. Initialises interface pointers to NULL values. @@ -47,26 +50,28 @@ using namespace MantidQt; */ IndirectDataReduction::IndirectDataReduction(QWidget *parent) : UserSubWindow(parent), - m_curInterfaceSetup(""), + m_instrument(""), m_settingsGroup("CustomInterfaces/IndirectDataReduction"), m_algRunner(new MantidQt::API::AlgorithmRunner(this)), m_changeObserver(*this, &IndirectDataReduction::handleDirectoryChange) { - //Signals to report load instrument algo result + // Signals to report load instrument algo result connect(m_algRunner, SIGNAL(algorithmComplete(bool)), this, SLOT(instrumentLoadingDone(bool))); } + /** * Destructor */ IndirectDataReduction::~IndirectDataReduction() { - //Make sure no algos are running after the window has been closed + // Make sure no algos are running after the window has been closed m_algRunner->cancelRunningAlgorithm(); saveSettings(); } + /** * On user clicking the "help" button on the interface, directs their request to the relevant * interface's helpClicked() function. @@ -94,6 +99,7 @@ void IndirectDataReduction::helpClicked() QDesktopServices::openUrl(QUrl(url)); } + /** * This is the function called when the "Run" button is clicked. It will call the relevent function * in the subclass. @@ -104,6 +110,7 @@ void IndirectDataReduction::runClicked() m_tabs[tabName]->runTab(); } + /** * Sets up Qt UI file and connects signals, slots. */ @@ -114,17 +121,24 @@ void IndirectDataReduction::initLayout() // Do not allow running until setup and instrument laoding are done updateRunButton(false, "Loading UI", "Initialising user interface components..."); - // Create the tabs - 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); - m_tabs["Symmetrise"] = new IndirectSymmetrise(m_uiForm, this); - m_tabs["S(Q, w)"] = new IndirectSqw(m_uiForm, this); - m_tabs["Moments"] = new IndirectMoments(m_uiForm, this); + if(m_instrument == "") + instrumentSelected(m_uiForm.cbInst->currentText()); - // Signal/slot connections to respond to changes in instrument selection combo boxes - connect(m_uiForm.cbInst, SIGNAL(instrumentSelectionChanged(const QString&)), this, SLOT(userSelectInstrument(const QString&))); + // Create the tabs + /* 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); */ + /* m_tabs["Symmetrise"] = new IndirectSymmetrise(m_uiForm, this); */ + /* m_tabs["S(Q, w)"] = new IndirectSqw(m_uiForm, this); */ + /* m_tabs["Moments"] = new IndirectMoments(m_uiForm, this); */ + + // Handle the instrument being changed + connect(m_uiForm.cbInst, SIGNAL(instrumentSelectionChanged(const QString&)), this, SLOT(instrumentSelected(const QString&))); + // Handle the analyser being changed + connect(m_uiForm.cbAnalyser, SIGNAL(currentIndexChanged(int)), this, SLOT(analyserSelected(int))); + // Handle the reflection being changed + connect(m_uiForm.cbReflection, SIGNAL(currentIndexChanged(int)), this, SLOT(instrumentSetupChanged())); // Connect "?" (Help) Button connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(helpClicked())); @@ -136,17 +150,19 @@ void IndirectDataReduction::initLayout() // Reset the Run button state when the tab is changed connect(m_uiForm.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateRunButton())); + // Connect tab signals and run any setup code for(auto it = m_tabs.begin(); it != m_tabs.end(); ++it) { 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(instrumentSelectionChanged(QString, QString, QString)), it->second, SIGNAL(instrumentSelectionChanged(QString, QString, QString))), + connect(this, SIGNAL(newInstrumentConfiguration(QString, QString, QString)), it->second, SIGNAL(newInstrumentConfiguration(QString, QString, QString))), it->second->setupTab(); } } + /** * This function is ran after initLayout(), and runPythonCode is unavailable before this function * has run (because of the setup of the base class). For this reason, "setup" functions that require @@ -156,73 +172,138 @@ void IndirectDataReduction::initLocalPython() { // select starting instrument readSettings(); - - if(m_curInterfaceSetup == "") - userSelectInstrument(m_uiForm.cbInst->currentText()); } + /** * Called when any of the instrument configuration options are changed. * * Used to notify tabs that rely on the instrument config when the config changes. */ -void IndirectDataReduction::instrumentChanged() +void IndirectDataReduction::instrumentSetupChanged() { QString instrumentName = m_uiForm.cbInst->currentText(); QString analyser = m_uiForm.cbAnalyser->currentText(); QString reflection = m_uiForm.cbReflection->currentText(); - emit newInstrumentConfiguration(instrumentName, analyser, reflection); + if(instrumentName != "" && analyser != "" && reflection != "") + { + loadInstrumentIfNotExist(instrumentName.toStdString(), analyser.toStdString(), reflection.toStdString()); + emit newInstrumentConfiguration(instrumentName, analyser, reflection); + } } + /** - * Sets up the initial instrument for the interface. This value is taken from the users' - * settings in the menu View -> Preferences -> Mantid -> Instrument - * @param name :: The name of the default instrument + * Loads an empty instrument into a workspace (__empty_INST) unless the workspace already exists. + * + * If an analyser and reflection are supplied then the corresponding IPF is also loaded. + * + * @param instrumentName Name of the instrument to load + * @param analyser Analyser being used (optional) + * @param reflection Relection being used (optional) + * @returns Pointer to instrument workspace */ -void IndirectDataReduction::setDefaultInstrument(const QString & name) +Mantid::API::MatrixWorkspace_sptr IndirectDataReduction::loadInstrumentIfNotExist(std::string instrumentName, + std::string analyser, std::string reflection) { - if( name.isEmpty() ) return; + std::string instWorkspaceName = "__empty_" + instrumentName; + std::string idfDirectory = Mantid::Kernel::ConfigService::Instance().getString("instrumentDefinition.directory"); - int index = m_uiForm.cbInst->findText(name); - if( index >= 0 ) + // If the workspace does not exist in ADS then load an empty instrument + if(!AnalysisDataService::Instance().doesExist(instWorkspaceName)) { - m_uiForm.cbInst->setCurrentIndex(index); + std::string parameterFilename = idfDirectory + instrumentName + "_Definition.xml"; + IAlgorithm_sptr loadAlg = AlgorithmManager::Instance().create("LoadEmptyInstrument"); + loadAlg->initialize(); + loadAlg->setProperty("Filename", parameterFilename); + loadAlg->setProperty("OutputWorkspace", instWorkspaceName); + loadAlg->execute(); + } + + // Load the IPF if given an analyser and reflection + if(!analyser.empty() && !reflection.empty()) + { + std::string ipfFilename = idfDirectory + instrumentName + "_" + analyser + "_" + reflection + "_Parameters.xml"; + IAlgorithm_sptr loadParamAlg = AlgorithmManager::Instance().create("LoadParameterFile"); + loadParamAlg->initialize(); + loadParamAlg->setProperty("Filename", ipfFilename); + loadParamAlg->setProperty("Workspace", instWorkspaceName); + loadParamAlg->execute(); } + + // Get the workspace, which should exist now + MatrixWorkspace_sptr instWorkspace = AnalysisDataService::Instance().retrieveWS(instWorkspaceName); + + return instWorkspace; } + /** - * This function: 1. loads the instrument and gets the value of deltaE-mode parameter - * 2. Based on this value, makes the necessary changes to the form setup (direct or indirect). - * @param name :: name of the instrument from the QComboBox + * Gets the operation modes for the current instrument as defined in it's parameter file. + * + * @returns A list of analysers and a vector of reflections that can be used with each */ -void IndirectDataReduction::instrumentSelectChanged(const QString& name) +std::vector > > IndirectDataReduction::getInstrumentModes() { - QString defFile = (Mantid::API::ExperimentInfo::getInstrumentFilename(name.toStdString())).c_str(); - if((defFile == "") || !m_uiForm.cbInst->isVisible()) + std::vector > > modes; + MatrixWorkspace_sptr instWorkspace = loadInstrumentIfNotExist(m_instrument.toStdString()); + Instrument_const_sptr instrument = instWorkspace->getInstrument(); + + std::vector analysers; + boost::split(analysers, instrument->getStringParameter("analysers")[0], boost::is_any_of(",")); + + for(auto it = analysers.begin(); it != analysers.end(); ++it) { - g_log.error("Instument loading failed!"); - m_uiForm.cbInst->setEnabled(true); - updateRunButton(false, "No Instrument", "No instrument is currently loaded."); - return; + std::string analyser = *it; + std::string ipfReflections = instrument->getStringParameter("refl-" + analyser)[0]; + + std::vector reflections; + boost::split(reflections, ipfReflections, boost::is_any_of(","), boost::token_compress_on); + + std::pair > data(analyser, reflections); + modes.push_back(data); } - QString outWS = "__empty_" + m_uiForm.cbInst->currentText(); + return modes; +} - m_curInterfaceSetup = name; - //Load the empty instrument into the workspace __empty_[name] - //This used to be done in Python - Mantid::API::IAlgorithm_sptr instLoader = Mantid::API::AlgorithmManager::Instance().create("LoadEmptyInstrument", -1); - instLoader->initialize(); - instLoader->setProperty("Filename", defFile.toStdString()); - instLoader->setProperty("OutputWorkspace", outWS.toStdString()); +/** + * Updated the list of analysers based on the current instrument. + */ +void IndirectDataReduction::updateAnalyserList() +{ + auto instModes = getInstrumentModes(); - //Ensure no other algorithm is running - m_algRunner->cancelRunningAlgorithm(); - m_algRunner->startAlgorithm(instLoader); + m_uiForm.cbAnalyser->clear(); + + for(auto modesIt = instModes.begin(); modesIt != instModes.end(); ++modesIt) + { + QString analyser = QString::fromStdString(modesIt->first); + std::vector 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()); } + /** * Tasks to be carried out after an empty instument has finished loading */ @@ -237,97 +318,70 @@ void IndirectDataReduction::instrumentLoadingDone(bool error) return; } - performInstSpecific(); - setIDFValues(curInstPrefix); - + updateAnalyserList(); updateRunButton(); m_uiForm.cbInst->setEnabled(true); } + /** - * If the instrument selection has changed, calls instrumentSelectChanged - * @param prefix :: instrument name from QComboBox object + * Handled loading thebase instrument when it is selected form the instrument combo box. + * + * @param instName Instrument name from QComboBox object */ -void IndirectDataReduction::userSelectInstrument(const QString& prefix) +void IndirectDataReduction::instrumentSelected(const QString& instName) { - if(prefix != m_curInterfaceSetup) + if(instName != m_instrument) { // Remove the old empty instrument workspace if it is there - std::string ws_name = "__empty_" + m_curInterfaceSetup.toStdString(); + std::string wsName = "__empty_" + m_instrument.toStdString(); Mantid::API::AnalysisDataServiceImpl& dataStore = Mantid::API::AnalysisDataService::Instance(); - if( dataStore.doesExist(ws_name) ) - { - dataStore.remove(ws_name); - } + if(dataStore.doesExist(wsName)) + dataStore.remove(wsName); updateRunButton(false, "Loading Inst.", "Loading the selected instrument..."); m_uiForm.cbInst->setEnabled(false); - instrumentSelectChanged(prefix); - } -} - -void IndirectDataReduction::openDirectoryDialog() -{ - MantidQt::API::ManageUserDirectories *ad = new MantidQt::API::ManageUserDirectories(this); - ad->show(); - ad->setFocus(); -} + loadInstrumentIfNotExist(instName.toStdString()); + m_instrument = instName; -/** - * 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 IndirectDataReduction::setIDFValues(const QString & prefix) -{ - dynamic_cast(m_tabs["Energy Transfer"])->setIDFValues(prefix); + //TODO + instrumentLoadingDone(false); + } } -/** - * This function holds any steps that must be performed on the layout that are specific - * to the currently selected instrument. - */ -void IndirectDataReduction::performInstSpecific() -{ - setInstSpecificWidget("cm-1-convert-choice", m_uiForm.ckCm1Units, QCheckBox::Off); - setInstSpecificWidget("save-aclimax-choice", m_uiForm.save_ckAclimax, QCheckBox::Off); -} /** - * This function either shows or hides the given QCheckBox, based on the named property - * inside the instrument param file. When hidden, the default state will be used to - * reset to the "unused" state of the checkbox. + * Updates the list of reflections in the reflection combo box when the analyser is changed. * - * @param parameterName :: The name of the property to look for inside the current inst param file. - * @param checkBox :: The checkbox to set the state of, and to either hide or show based on the current inst. - * @param defaultState :: The state to which the checkbox will be set upon hiding it. + * @param index Index of analyser in combo box */ -void IndirectDataReduction::setInstSpecificWidget(const std::string & parameterName, QCheckBox * checkBox, QCheckBox::ToggleState defaultState) +void IndirectDataReduction::analyserSelected(int index) { - // Get access to instrument specific parameters via the loaded empty workspace. - std::string instName = m_uiForm.cbInst->currentText().toStdString(); - Mantid::API::MatrixWorkspace_sptr input = boost::dynamic_pointer_cast(Mantid::API::AnalysisDataService::Instance().retrieve("__empty_" + instName)); - if(input == NULL) - return; - - Mantid::Geometry::Instrument_const_sptr instr = input->getInstrument(); - - // See if the instrument params file requests that the checkbox be shown to the user. - std::vector showParams = instr->getStringParameter(parameterName); - - std::string show = ""; - if(!showParams.empty()) - show = showParams[0]; + // Populate Reflection combobox with correct values for Analyser selected. + m_uiForm.cbReflection->clear(); - if(show == "Show") - checkBox->setHidden(false); + QVariant currentData = m_uiForm.cbAnalyser->itemData(index); + if ( currentData == QVariant::Invalid ) + { + m_uiForm.lbReflection->setEnabled(false); + m_uiForm.cbReflection->setEnabled(false); + return; + } else { - checkBox->setHidden(true); - checkBox->setState(defaultState); + 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]); + } } + + emit instrumentSetupChanged(); } + /** * Remove the Poco observer on the config service when the interfaces is closed. * @@ -339,6 +393,7 @@ void IndirectDataReduction::closeEvent(QCloseEvent* close) Mantid::Kernel::ConfigService::Instance().removeObserver(m_changeObserver); } + /** * Reloads settings if the default sata search or save directories have been changed. */ @@ -350,6 +405,7 @@ void IndirectDataReduction::handleDirectoryChange(Mantid::Kernel::ConfigValChang readSettings(); } + /** * Read Qt settings for the interface. */ @@ -383,14 +439,20 @@ void IndirectDataReduction::readSettings() // Load the last used instrument settings.beginGroup(m_settingsGroup); - QString instrName = settings.value("instrument-name", "").toString(); + QString instName = settings.value("instrument-name", "").toString(); settings.endGroup(); - setDefaultInstrument(instrName); + if(instName.isEmpty()) + return; + + int index = m_uiForm.cbInst->findText(instName); + if(index >= 0) + m_uiForm.cbInst->setCurrentIndex(index); } + /** - * Save settings to a persistent storage + * Save settings to a persistent storage. */ void IndirectDataReduction::saveSettings() { @@ -404,17 +466,30 @@ void IndirectDataReduction::saveSettings() settings.endGroup(); } + +/** + * Handles showing the manage directory dialog box. + */ +void IndirectDataReduction::openDirectoryDialog() +{ + MantidQt::API::ManageUserDirectories *ad = new MantidQt::API::ManageUserDirectories(this); + ad->show(); + ad->setFocus(); +} + + /** * Slot to wrap the protected showInformationBox method defined * in UserSubWindow and provide access to composed tabs. * - * @param message :: The message to display in the message box + * @param message The message to display in the message box */ void IndirectDataReduction::showMessageBox(const QString& message) { showInformationBox(message); } + /** * Slot to allow setting the state of the Run button. *