diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h index 109ddb5b7c220f1686df700ed9fc4a0e4cd487bc..ab2cb4672c86bae2b479c406c6ba8a9076e5fe9b 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h @@ -67,7 +67,7 @@ public: void doFocusRun(const std::string &dir, const std::vector<std::string> &outFilenames, const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs, const std::string &dgFile); + const std::string &specNos, const std::string &dgFile); protected: void initialize(); @@ -118,21 +118,21 @@ private: //@{ /// this may also need to be mocked up in tests void startFocusing(const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs = "", + const std::string &specNos = "", const std::string &dgFile = ""); void startAsyncFocusWorker(const std::string &dir, const std::vector<std::string> &outFilenames, const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs, + const std::string &specNos, const std::string &dgFile); void inputChecksBeforeFocusBasic(const std::string &runNo, const std::vector<bool> &banks); void inputChecksBeforeFocusCropped(const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs); + const std::string &specNos); void inputChecksBeforeFocusTexture(const std::string &runNo, const std::string &dgfile); void inputChecksBeforeFocus(); @@ -153,7 +153,7 @@ private: void doFocusing(const EnggDiffCalibSettings &cs, const std::string &fullFilename, const std::string &runNo, - size_t bank, const std::string &specIDs, + size_t bank, const std::string &specNos, const std::string &dgFile); void loadOrCalcVanadiumWorkspaces( diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp index f4134c7285d5e4b84e704e402c4a768e32d0b644..bdac115379cf6dca1611e465c9bfbbfe18a748d5 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -175,10 +175,10 @@ void EnggDiffractionPresenter::processFocusBasic() { void EnggDiffractionPresenter::processFocusCropped() { const std::string runNo = m_view->focusingCroppedRunNo(); const std::vector<bool> banks = m_view->focusingBanks(); - const std::string specIDs = m_view->focusingCroppedSpectrumIDs(); + const std::string specNos = m_view->focusingCroppedSpectrumIDs(); try { - inputChecksBeforeFocusCropped(runNo, banks, specIDs); + inputChecksBeforeFocusCropped(runNo, banks, specNos); } catch (std::invalid_argument &ia) { m_view->userWarning( "Error in the inputs required to focus a run (in cropped mode)", @@ -186,7 +186,7 @@ void EnggDiffractionPresenter::processFocusCropped() { return; } - startFocusing(runNo, banks, specIDs, ""); + startFocusing(runNo, banks, specNos, ""); } void EnggDiffractionPresenter::processFocusTexture() { @@ -214,7 +214,7 @@ void EnggDiffractionPresenter::processFocusTexture() { * @param runNo run/file number to focus * @param banks banks to include in the focusing, processed one at a time * - * @param specIDs list of spectra to use when focusing. If not empty + * @param specNos list of spectra to use when focusing. If not empty * this implies focusing in cropped mode. * * @param dgFile detector grouping file to define banks (texture). If @@ -222,11 +222,11 @@ void EnggDiffractionPresenter::processFocusTexture() { */ void EnggDiffractionPresenter::startFocusing(const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs, + const std::string &specNos, const std::string &dgFile) { std::string optMsg = ""; - if (!specIDs.empty()) { + if (!specNos.empty()) { optMsg = " (cropped)"; } else if (!dgFile.empty()) { optMsg = " (texture)"; @@ -240,9 +240,9 @@ void EnggDiffractionPresenter::startFocusing(const std::string &runNo, m_view->enableCalibrateAndFocusActions(false); // GUI-blocking alternative: - // doFocusRun(focusDir, outFilenames, runNo, banks, specIDs, dgFile) + // doFocusRun(focusDir, outFilenames, runNo, banks, specNos, dgFile) // focusingFinished() - startAsyncFocusWorker(focusDir, outFilenames, runNo, banks, specIDs, dgFile); + startAsyncFocusWorker(focusDir, outFilenames, runNo, banks, specNos, dgFile); } void EnggDiffractionPresenter::processResetFocus() { m_view->resetFocus(); } @@ -656,19 +656,19 @@ void EnggDiffractionPresenter::inputChecksBeforeFocusBasic( * * @param runNo run number to focus * @param banks which banks to consider in the focusing - * @param specIDs list of spectra (as usual csv list of spectra in Mantid) + * @param specNos list of spectra (as usual csv list of spectra in Mantid) * * @throws std::invalid_argument with an informative message. */ void EnggDiffractionPresenter::inputChecksBeforeFocusCropped( const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs) { + const std::string &specNos) { if (runNo.empty()) { throw std::invalid_argument("To focus cropped the sample run number cannot " "be empty and must be an integer number."); } - if (specIDs.empty()) { + if (specNos.empty()) { throw std::invalid_argument("The list of spectrum IDs cannot be empty when " "focusing in 'cropped' mode."); } @@ -805,12 +805,12 @@ std::vector<std::string> EnggDiffractionPresenter::outputFocusTextureFilenames( void EnggDiffractionPresenter::startAsyncFocusWorker( const std::string &dir, const std::vector<std::string> &outFilenames, const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs, const std::string &dgFile) { + const std::string &specNos, const std::string &dgFile) { delete m_workerThread; m_workerThread = new QThread(this); EnggDiffWorker *worker = new EnggDiffWorker(this, dir, outFilenames, runNo, - banks, specIDs, dgFile); + banks, specNos, dgFile); worker->moveToThread(m_workerThread); connect(m_workerThread, SIGNAL(started()), worker, SLOT(focus())); @@ -831,7 +831,7 @@ void EnggDiffractionPresenter::startAsyncFocusWorker( * @param outFilenames names for the output focused files (one per bank) * @param runNo input run number * - * @param specIDs list of spectra to use when focusing. Not empty + * @param specNos list of spectra to use when focusing. Not empty * implies focusing in cropped mode. * * @param dgFile detector grouping file to define banks (texture). Not @@ -843,7 +843,7 @@ void EnggDiffractionPresenter::startAsyncFocusWorker( void EnggDiffractionPresenter::doFocusRun( const std::string &dir, const std::vector<std::string> &outFilenames, const std::string &runNo, const std::vector<bool> &banks, - const std::string &specIDs, const std::string &dgFile) { + const std::string &specNos, const std::string &dgFile) { g_log.notice() << "Generating new focusing workspace(s) and file(s) into " "this directory: " << dir << std::endl; @@ -866,10 +866,10 @@ void EnggDiffractionPresenter::doFocusRun( std::vector<size_t> bankIDs; std::vector<std::string> effectiveFilenames; std::vector<std::string> specs; - if (!specIDs.empty()) { + if (!specNos.empty()) { // just to iterate once, but there's no real bank here bankIDs.push_back(0); - specs.push_back(specIDs); // one spectrum IDs list given by the user + specs.push_back(specNos); // one spectrum IDs list given by the user effectiveFilenames.push_back(outputFocusCroppedFilename(runNo)); } else { if (dgFile.empty()) { @@ -1013,13 +1013,13 @@ void EnggDiffractionPresenter::focusingFinished() { * * @param bank instrument bank number to focus * - * @param specIDs string specifying a list of spectra (for cropped + * @param specNos string specifying a list of spectra (for cropped * focusing) */ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, const std::string &fullFilename, const std::string &runNo, size_t bank, - const std::string &specIDs, + const std::string &specNos, const std::string &dgFile) { ITableWorkspace_sptr vanIntegWS; MatrixWorkspace_sptr vanCurvesWS; @@ -1054,7 +1054,7 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, if (!dgFile.empty()) { outWSName = "engggui_focusing_output_ws_texture_bank_" + boost::lexical_cast<std::string>(bank); - } else if (specIDs.empty()) { + } else if (specNos.empty()) { outWSName = "engggui_focusing_output_ws_bank_" + boost::lexical_cast<std::string>(bank); } else { @@ -1069,10 +1069,10 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, alg->setProperty("VanIntegrationWorkspace", vanIntegWS); alg->setProperty("VanCurvesWorkspace", vanCurvesWS); // cropped / normal focusing - if (specIDs.empty()) { + if (specNos.empty()) { alg->setPropertyValue("Bank", boost::lexical_cast<std::string>(bank)); } else { - alg->setPropertyValue("SpectrumNumbers", specIDs); + alg->setPropertyValue("SpectrumNumbers", specNos); } // TODO: use detector positions (from calibrate full) when available // alg->setProperty(DetectorPositions, TableWorkspace) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp index 7c3ab738e3716f1ca63507942152225d2c639988..c594b5b2732fcbf545042214fcd30a80cc6dc117 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -197,9 +197,43 @@ void EnggDiffractionViewQtGUI::readSettings() { m_uiTabCalib.lineEdit_new_ceria_num->setText( qs.value("user-params-new-ceria-num", "").toString()); + m_uiTabCalib.lineEdit_new_vanadium_num->setText( + qs.value("user-params-new-vanadium-num", "").toString()); + + m_uiTabCalib.lineEdit_new_ceria_num->setText( + qs.value("user-params-new-ceria-num", "").toString()); + + // user params - focusing + m_uiTabFocus.lineEdit_run_num->setText( + qs.value("user-params-focus-runno", "").toString()); + + qs.beginReadArray("user-params-focus-bank_i"); + qs.setArrayIndex(0); + m_uiTabFocus.checkBox_focus_bank1->setChecked(qs.value("value", true).toBool()); + qs.setArrayIndex(1); + m_uiTabFocus.checkBox_focus_bank2->setChecked(qs.value("value", true).toBool()); + qs.endArray(); + + m_uiTabFocus.lineEdit_cropped_run_num->setText( + qs.value("user-params-focus-cropped-runno", "").toString()); + + m_uiTabFocus.lineEdit_cropped_spec_ids->setText( + qs.value("user-params-focus-cropped-spectrum-nos", "").toString()); + + m_uiTabFocus.lineEdit_texture_run_num->setText( + qs.value("user-params-focus-texture-runno", "").toString()); + + m_uiTabFocus.lineEdit_texture_grouping_file->setText( + qs.value("user-params-focus-texture-detector-grouping-file", "") + .toString()); + + m_uiTabFocus.checkBox_FocusedWS->setChecked( + qs.value("user-params-focus-plot-ws", true).toBool()); + QString lastPath = MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); - // TODO: this should become << >> operators on EnggDiffCalibSettings + // TODO: this should become << >> operators on + // EnggDiffCalibSettings m_calibSettings.m_inputDirCalib = qs.value("input-dir-calib-files", lastPath).toString().toStdString(); m_calibSettings.m_inputDirRaw = @@ -242,6 +276,29 @@ void EnggDiffractionViewQtGUI::saveSettings() const { qs.setValue("user-params-new-ceria-num", m_uiTabCalib.lineEdit_new_ceria_num->text()); + // user params - focusing + qs.setValue("user-params-focus-runno", m_uiTabFocus.lineEdit_run_num->text()); + + qs.beginWriteArray("user-params-focus-bank_i"); + qs.setArrayIndex(0); + qs.setValue("value", m_uiTabFocus.checkBox_focus_bank1->isChecked()); + qs.setArrayIndex(1); + qs.setValue("value", m_uiTabFocus.checkBox_focus_bank2->isChecked()); + qs.endArray(); + + qs.setValue("user-params-focus-cropped-runno", + m_uiTabFocus.lineEdit_cropped_run_num->text()); + qs.setValue("user-params-focus-cropped-spectrum-nos", + m_uiTabFocus.lineEdit_cropped_spec_ids->text()); + + qs.setValue("user-params-focus-texture-runno", + m_uiTabFocus.lineEdit_texture_run_num->text()); + qs.setValue("user-params-focus-texture-detector-grouping-file", + m_uiTabFocus.lineEdit_texture_grouping_file->text()); + + qs.setValue("user-params-focus-plot-ws", + m_uiTabFocus.checkBox_FocusedWS->checkState()); + // TODO: this should become << >> operators on EnggDiffCalibSettings qs.setValue("input-dir-calib-files", QString::fromStdString(m_calibSettings.m_inputDirCalib)); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h b/Code/Mantid/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h index f81d81bfcabecf5f1af1df9bd0b9ee14d5b6e38a..043aba68ed970e70f14f1dd292e947a3ddcf03a6 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h @@ -287,6 +287,8 @@ public: EXPECT_CALL(mockView, focusingCroppedRunNo()).Times(0); EXPECT_CALL(mockView, focusingCroppedSpectrumIDs()).Times(0); EXPECT_CALL(mockView, focusingTextureGroupingFile()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); // should not get that far that it tries to get these parameters EXPECT_CALL(mockView, currentInstrument()).Times(0); @@ -316,6 +318,8 @@ public: // should not get that far that it tries to get these parameters EXPECT_CALL(mockView, currentInstrument()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); // 1 warning pop-up to user, 0 errors EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); @@ -349,6 +353,8 @@ public: EXPECT_CALL(mockView, focusingTextureRunNo()).Times(0); EXPECT_CALL(mockView, focusingCroppedSpectrumIDs()).Times(0); EXPECT_CALL(mockView, focusingTextureGroupingFile()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); // it should not get there EXPECT_CALL(mockView, enableCalibrateAndFocusActions(false)).Times(0); @@ -376,6 +382,10 @@ public: EXPECT_CALL(mockView, currentCalibSettings()).Times(1).WillOnce( Return(calibSettings)); + // check automatic plotting + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(1).WillOnce(Return(true)); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(1); + // Should not try to use options for other types of focusing EXPECT_CALL(mockView, focusingCroppedRunNo()).Times(0); EXPECT_CALL(mockView, focusingTextureRunNo()).Times(0); @@ -405,6 +415,9 @@ public: EXPECT_CALL(mockView, currentCalibSettings()).Times(1).WillOnce( Return(calibSettings)); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); + // No errors/warnings EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); @@ -431,6 +444,8 @@ public: // should not get that far that it tries to get these parameters EXPECT_CALL(mockView, currentInstrument()).Times(0); EXPECT_CALL(mockView, currentCalibSettings()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); // 1 warning pop-up to user, 0 errors EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); @@ -455,6 +470,8 @@ public: EXPECT_CALL(mockView, focusingRunNo()).Times(0); EXPECT_CALL(mockView, focusingTextureRunNo()).Times(0); EXPECT_CALL(mockView, focusingTextureGroupingFile()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); // should not get that far that it tries to get these parameters EXPECT_CALL(mockView, currentInstrument()).Times(0); @@ -483,6 +500,8 @@ public: EXPECT_CALL(mockView, focusingRunNo()).Times(0); EXPECT_CALL(mockView, focusingTextureRunNo()).Times(0); EXPECT_CALL(mockView, focusingTextureGroupingFile()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); // should not get that far that it tries to get these parameters EXPECT_CALL(mockView, currentInstrument()).Times(0); @@ -511,6 +530,9 @@ public: EXPECT_CALL(mockView, focusingCroppedRunNo()).Times(0); EXPECT_CALL(mockView, focusingCroppedSpectrumIDs()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); + // 1 warning pop-up to user, 0 errors EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); @@ -535,6 +557,9 @@ public: EXPECT_CALL(mockView, focusingCroppedRunNo()).Times(0); EXPECT_CALL(mockView, focusingCroppedSpectrumIDs()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); + // 1 warning pop-up to user, 0 errors EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); @@ -559,6 +584,9 @@ public: EXPECT_CALL(mockView, focusingCroppedRunNo()).Times(0); EXPECT_CALL(mockView, focusingCroppedSpectrumIDs()).Times(0); + EXPECT_CALL(mockView, focusedOutWorkspace()).Times(0); + EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(0); + // 1 warning pop-up to user, 0 errors EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); diff --git a/Code/Mantid/docs/source/interfaces/Engineering_Diffraction.rst b/Code/Mantid/docs/source/interfaces/Engineering_Diffraction.rst index 628bf263cdd8e6ad6c0aaa8a293e1e3f1f2a0561..fa92627075643a5f5df84bfa47f8633c0877e737 100644 --- a/Code/Mantid/docs/source/interfaces/Engineering_Diffraction.rst +++ b/Code/Mantid/docs/source/interfaces/Engineering_Diffraction.rst @@ -8,10 +8,10 @@ Overview -------- This custom interface integrates several tasks related to engineeering -diffraction. The interface is under heavy development, and at the -moment it only provides calibration related functionality. The -following sections will describe the different sections or tabs of the -interface. +diffraction. It provides calibration and focusing functionality which +can be expected to expand for next releases as it is under active +development. The following sections describe the different tabs or +functionality areas of the interface. .. interface:: Engineering Diffraction :align: center @@ -63,8 +63,8 @@ The interface will also create workspaces that can be inspected in the workspaces window: 1. The *engg_focusing_input_ws workspace* for the data being focused -2. The *engg_focusing_input_ws workspace* for the corresponding - focused data +2. The *engg_focusing_output_ws... workspace* for the corresponding + focused data (where the ... denotes a suffix explained below). Three focusing alternatives are provided: @@ -75,11 +75,18 @@ Three focusing alternatives are provided: in a Detector Gropuing File. Depending on the alternative chosen, the focusing operation will -include all the selected banks and all the spectra present in the -input runs (first alternative: normal focusing), all the banks but -only a list of spectra provided manually (second alternative: cropped -focusing), or a user-defined list of banks provided in a file (third -alternative: texture focusing) +include different banks and/or combinations of spectra (detectors). In +the firs option, normal focusing, all the selected banks and all the +spectra present in the input runs are considered. In the second +alternative, cropped focusing, all the banks are considered in +principle but only a list of spectra provided manually are +processed. In the third option, *texture focusing*, the banks are +defined by a user-defined list of banks and corresponding spectrum IDs +provided in a file. For these alternatives, the output focused +workspace will take different suffixes: *_bank_1, _bank_2*, and so on +for normal focusing, *_cropped* for cropped focusing, and +*_texture_bank_1, _texture_bank_2*, and so on for texture focusing +(using the bank IDs given in the detector grouping file). For texture focusing, the detector grouping file is a text (csv) file with one line per bank. Each line must contain at least two numeric