diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h index a78a578d80f7b4041b9a7c8f6d879efbac56f94f..b8f7e8ef358457c101ef86df062e386ff52ca265 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h @@ -178,10 +178,12 @@ private: void plotFocusedWorkspace(std::string outWSName); - // Algorithms to save the generate workspace - void saveGSS(std::string inputWorkspace, std::string bank); - void saveFocusedXYE(std::string inputWorkspace, std::string bank); - void saveOpenGenie(std::string inputWorkspace, std::string specNums); + // Algorithms to save the generated workspace + void saveGSS(std::string inputWorkspace, std::string bank, std::string runNo); + void saveFocusedXYE(std::string inputWorkspace, std::string bank, + std::string runNo); + void saveOpenGenie(std::string inputWorkspace, std::string specNums, + std::string bank, std::string runNo); /// string to use for ENGINX file names (as a prefix, etc.) const static std::string g_enginxStr; @@ -199,6 +201,9 @@ private: /// true if the last focusing completed successfully bool m_focusFinishedOK; + /// Counter for the cropped output files + static int g_croppedCounter; + /// Associated view for this presenter (MVP pattern) IEnggDiffractionView *const m_view; diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp index 294434cbb6c10b71f0ad38788688e9e1549702f6..7c91b8212e116fb5977f24d9e8974bc3f8ad6ef6 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -32,6 +32,7 @@ const std::string EnggDiffractionPresenter::g_enginxStr = "ENGINX"; const bool EnggDiffractionPresenter::g_askUserCalibFilename = false; const std::string EnggDiffractionPresenter::g_vanIntegrationWSName = "engggui_vanadium_integration_ws"; +int EnggDiffractionPresenter::g_croppedCounter = 0; EnggDiffractionPresenter::EnggDiffractionPresenter(IEnggDiffractionView *view) : m_workerThread(NULL), m_calibFinishedOK(false), m_focusFinishedOK(false), @@ -1132,9 +1133,10 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, bool saveOutputFiles = m_view->saveOutputFiles(); if (saveOutputFiles) { - saveFocusedXYE(outWSName, boost::lexical_cast<std::string>(bank)); - saveGSS(outWSName, boost::lexical_cast<std::string>(bank)); - saveOpenGenie(outWSName, specNumsOpenGenie); + saveFocusedXYE(outWSName, boost::lexical_cast<std::string>(bank), runNo); + saveGSS(outWSName, boost::lexical_cast<std::string>(bank), runNo); + saveOpenGenie(outWSName, specNumsOpenGenie, + boost::lexical_cast<std::string>(bank), runNo); } } @@ -1379,25 +1381,47 @@ void EnggDiffractionPresenter::plotFocusedWorkspace(std::string outWSName) { * * @param inputWorkspace title of the focused workspace * @param bank the number of the bank as a string + * @param runNo the run number as a string */ void EnggDiffractionPresenter::saveFocusedXYE(const std::string inputWorkspace, - std::string bank) { + std::string bank, + std::string runNo) { auto alg = Algorithm::fromString("SaveFocusedXYE"); - std::string fullFilename = inputWorkspace + ".dat"; - + std::string fullFilename; + if (inputWorkspace.std::string::find("texture") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_texture_" + bank + ".dat"; + } + if (inputWorkspace.std::string::find("cropped") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_cropped_" + + boost::lexical_cast<std::string>(g_croppedCounter) + ".dat"; + g_croppedCounter++; + } else { + fullFilename = "ENGINX_" + runNo + "_bank_" + bank + ".dat"; + } + std::string saveDir; + try { + // takes to the root of directory according to the platform + // and appends the following string provided + saveDir = + Poco::Path(saveDir).expand("/EnginX_Mantid/User/" + runNo + "/Focus/"); + if (!Poco::File(saveDir).exists()) { + Poco::File(saveDir).createDirectories(); + } + } catch (std::runtime_error &re) { + g_log.error() << "Error while using Poco: " << re.what(); + } try { g_log.debug() << "Going to save focused output into OpenGenie file: " << fullFilename << std::endl; alg->initialize(); alg->setProperty("InputWorkspace", inputWorkspace); - - std::string filename(fullFilename); + std::string filename(saveDir + fullFilename); alg->setPropertyValue("Filename", filename); alg->setProperty("SplitFiles", false); alg->setPropertyValue("StartAtBankNumber", bank); alg->execute(); } catch (std::runtime_error &re) { - g_log.error() << "Error in saving FocusedXYE file. ", + g_log.error() << "Error in saving FocusedXYE format file. ", "Could not run the algorithm SaveFocusXYE succesfully for " "workspace " + inputWorkspace + ". Error description: " + re.what() + @@ -1414,23 +1438,48 @@ void EnggDiffractionPresenter::saveFocusedXYE(const std::string inputWorkspace, * * @param inputWorkspace title of the focused workspace * @param bank the number of the bank as a string + * @param runNo the run number as a string */ void EnggDiffractionPresenter::saveGSS(const std::string inputWorkspace, - std::string bank) { + std::string bank, std::string runNo) { auto alg = Algorithm::fromString("SaveGSS"); - std::string fullFilename = inputWorkspace + ".gss"; + std::string fullFilename; + if (inputWorkspace.std::string::find("texture") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_texture_" + bank + ".gss"; + } + if (inputWorkspace.std::string::find("cropped") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_cropped_" + + boost::lexical_cast<std::string>(g_croppedCounter) + ".gss"; + g_croppedCounter++; + } else { + fullFilename = "ENGINX_" + runNo + "_bank_" + bank + ".gss"; + } + + std::string saveDir; + try { + // takes to the root of directory according to the platform + // and appends the following string provided + saveDir = + Poco::Path(saveDir).expand("/EnginX_Mantid/User/" + runNo + "/Focus/"); + if (!Poco::File(saveDir).exists()) { + Poco::File(saveDir).createDirectories(); + } + } catch (std::runtime_error &re) { + g_log.error() << "Error while using Poco: " << re.what(); + } try { g_log.debug() << "Going to save focused output into OpenGenie file: " << fullFilename << std::endl; alg->initialize(); alg->setProperty("InputWorkspace", inputWorkspace); - std::string filename(fullFilename); + std::string filename(saveDir + fullFilename); alg->setPropertyValue("Filename", filename); + alg->setProperty("SplitFiles", false); alg->setPropertyValue("Bank", bank); alg->execute(); } catch (std::runtime_error &re) { - g_log.error() << "Error in saving GSS file. ", + g_log.error() << "Error in saving GSS format file. ", "Could not run the algorithm saveGSS succesfully for " "workspace " + inputWorkspace + ". Error description: " + re.what() + @@ -1447,22 +1496,51 @@ void EnggDiffractionPresenter::saveGSS(const std::string inputWorkspace, * * @param inputWorkspace title of the focused workspace * @param specNums number of spectrum to display + * @param bank the number of the bank as a string + * @param runNo the run number as a string */ void EnggDiffractionPresenter::saveOpenGenie(const std::string inputWorkspace, - std::string specNums) { + std::string specNums, + std::string bank, + std::string runNo) { auto alg = Algorithm::fromString("SaveOpenGenieAscii"); - std::string fullFilename = inputWorkspace + ".his"; + std::string fullFilename; + if (inputWorkspace.std::string::find("texture") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_texture_" + bank + ".his"; + } + if (inputWorkspace.std::string::find("cropped") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_cropped_" + + boost::lexical_cast<std::string>(g_croppedCounter) + ".his"; + g_croppedCounter++; + } else { + fullFilename = "ENGINX_" + runNo + "_bank_" + bank + ".his"; + } + + std::string saveDir; + try { + // takes to the root of directory according to the platform + // and appends the following string provided + saveDir = + Poco::Path(saveDir).expand("/EnginX_Mantid/User/" + runNo + "/Focus/"); + + if (!Poco::File(saveDir).exists()) { + Poco::File(saveDir).createDirectories(); + } + } catch (std::runtime_error &re) { + g_log.error() << "Error while using Poco: " << re.what(); + } + try { g_log.debug() << "Going to save focused output into OpenGenie file: " << fullFilename << std::endl; alg->initialize(); alg->setProperty("InputWorkspace", inputWorkspace); - std::string filename(fullFilename); + std::string filename(saveDir + fullFilename); alg->setPropertyValue("Filename", filename); alg->setPropertyValue("SpecNumberField", specNums); alg->execute(); } catch (std::runtime_error &re) { - g_log.error() << "Error in saving Open Genie file. ", + g_log.error() << "Error in saving OpenGenie format file. ", "Could not run the algorithm SaveOpenGenieAscii succesfully for " "workspace " + inputWorkspace + ". Error description: " + re.what() + diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp index 6884089f5681d071ab910042a884b76ca6a63658..a84231fdd79d721aa35ba3dd6a0a8fb472146a72 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -307,8 +307,7 @@ void EnggDiffractionViewQtGUI::saveSettings() const { 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()); + qs.setValue("value", m_uiTabFocus.checkBox_FocusedWS->isChecked()); // TODO: this should become << >> operators on EnggDiffCalibSettings qs.setValue("input-dir-calib-files",