diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h index fd4858acdea1345941737d7cd22f19f74c739ba8..5c4f2dba65bcd8cfe98cfdd5f0f267ba89a52a9b 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h @@ -11,6 +11,8 @@ #include <boost/scoped_ptr.hpp> +#include <Poco/Path.h> + #include <QObject> class QThread; @@ -176,7 +178,22 @@ private: Mantid::API::ITableWorkspace_sptr &vanIntegWS, Mantid::API::MatrixWorkspace_sptr &vanCurvesWS); - void plotFocusedWorkspace(std::string outWSName); + // plots workspace according to the user selection + void plotFocusedWorkspace(std::string outWSName, std::string bank); + + // 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); + + // generates the required file name of the output files + std::string outFileNameFactory(std::string inputWorkspace, std::string runNo, + std::string bank, std::string format); + + // generates a directory if not found and handles the path + Poco::Path outFilesDir(std::string runNo); /// string to use for ENGINX file names (as a prefix, etc.) const static std::string g_enginxStr; @@ -194,6 +211,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/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabCalib.ui b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabCalib.ui index cfd09d9f143835bce84f95d414ecd3e64cd86f96..6381604907d9e6602362cb87b8b9f8afccd1f7bc 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabCalib.ui +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabCalib.ui @@ -168,32 +168,30 @@ <bool>false</bool> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_new_vanadium_num"> - <property name="text"> - <string>Vanadium #:</string> - </property> - </widget> - </item> <item row="0" column="1" colspan="2"> - <widget class="QLineEdit" name="lineEdit_new_vanadium_num"> - <property name="text"> + <widget class="MantidQt::MantidWidgets::MWRunFiles" name="lineEdit_new_vanadium_num" native="true"> + <property name="text" stdset="0"> <string>236516</string> </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_new_ceria_num"> - <property name="text"> - <string>Calibration sample #:</string> + <property name="label" stdset="0"> + <string>Vanadium #:</string> + </property> + <property name="multipleFiles" stdset="0"> + <bool>true</bool> </property> </widget> </item> <item row="1" column="1" colspan="2"> - <widget class="QLineEdit" name="lineEdit_new_ceria_num"> - <property name="text"> + <widget class="MantidQt::MantidWidgets::MWRunFiles" name="lineEdit_new_ceria_num" native="true"> + <property name="text" stdset="0"> <string>241391</string> </property> + <property name="label" stdset="0"> + <string>Calibration sample #:</string> + </property> + <property name="multipleFiles" stdset="0"> + <bool>true</bool> + </property> </widget> </item> <item row="2" column="0" colspan="2"> @@ -216,6 +214,20 @@ </property> </widget> </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_new_ceria_num"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_new_vanadium_num"> + <property name="text"> + <string/> + </property> + </widget> + </item> </layout> </widget> </item> @@ -236,6 +248,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>MantidQt::MantidWidgets::MWRunFiles</class> + <extends>QWidget</extends> + <header>MantidQtMantidWidgets/MWRunFiles.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui index 76e0aa9e04571d14f1c1e5c9d4dc3fbe68065fd5..b6f46a4ab6b44f102950099e87f1ce59e34e8819 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>614</width> - <height>545</height> + <height>551</height> </rect> </property> <property name="windowTitle"> @@ -20,30 +20,6 @@ <string>Focus run</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>238</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_focus"> - <property name="text"> - <string>Focus</string> - </property> - </widget> - </item> - </layout> - </item> <item row="1" column="0"> <layout class="QHBoxLayout" name="horizontalLayout_5"> <item> @@ -113,12 +89,36 @@ </item> </layout> </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>238</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_focus"> + <property name="text"> + <string>Focus</string> + </property> + </widget> + </item> + </layout> + </item> <item row="0" column="0"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="label_run_num"> <property name="text"> - <string>Run #:</string> + <string/> </property> </widget> </item> @@ -136,13 +136,19 @@ </spacer> </item> <item> - <widget class="QLineEdit" name="lineEdit_run_num"> - <property name="text"> + <widget class="MantidQt::MantidWidgets::MWRunFiles" name="lineEdit_run_num" native="true"> + <property name="text" stdset="0"> <string/> </property> - <property name="readOnly"> + <property name="readOnly" stdset="0"> <bool>false</bool> </property> + <property name="label" stdset="0"> + <string>Run #:</string> + </property> + <property name="multipleFiles" stdset="0"> + <bool>true</bool> + </property> </widget> </item> </layout> @@ -161,7 +167,7 @@ <item> <widget class="QLabel" name="label_cropped_run_num"> <property name="text"> - <string>Run #:</string> + <string/> </property> </widget> </item> @@ -179,13 +185,19 @@ </spacer> </item> <item> - <widget class="QLineEdit" name="lineEdit_cropped_run_num"> - <property name="text"> + <widget class="MantidQt::MantidWidgets::MWRunFiles" name="lineEdit_cropped_run_num" native="true"> + <property name="text" stdset="0"> <string/> </property> - <property name="readOnly"> + <property name="readOnly" stdset="0"> <bool>false</bool> </property> + <property name="label" stdset="0"> + <string>Run #:</string> + </property> + <property name="multipleFiles" stdset="0"> + <bool>true</bool> + </property> </widget> </item> </layout> @@ -262,7 +274,7 @@ <item> <widget class="QLabel" name="label_texture_run_num"> <property name="text"> - <string>Run #:</string> + <string/> </property> </widget> </item> @@ -280,13 +292,19 @@ </spacer> </item> <item> - <widget class="QLineEdit" name="lineEdit_texture_run_num"> - <property name="text"> + <widget class="MantidQt::MantidWidgets::MWRunFiles" name="lineEdit_texture_run_num" native="true"> + <property name="text" stdset="0"> <string/> </property> - <property name="readOnly"> + <property name="readOnly" stdset="0"> <bool>false</bool> </property> + <property name="label" stdset="0"> + <string>Run #:</string> + </property> + <property name="multipleFiles" stdset="0"> + <bool>true</bool> + </property> </widget> </item> </layout> @@ -471,7 +489,7 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_22"> <item> - <widget class="QCheckBox" name="checkBox_OutputFiles_"> + <widget class="QCheckBox" name="checkBox_SaveOutputFiles"> <property name="text"> <string>Output Files</string> </property> @@ -521,6 +539,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>MantidQt::MantidWidgets::MWRunFiles</class> + <extends>QWidget</extends> + <header>MantidQtMantidWidgets/MWRunFiles.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h index ef099e716254d88448ed06d78aa0e5945b4b9b9e..f813d2b37cb5782b6d39ef2ed7e7ac013d330350 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h @@ -125,6 +125,8 @@ public: virtual void plotReplacingWindow(const std::string &wsName); + virtual bool saveOutputFiles() const; + int currentPlotType() const { return m_currentType; } private slots: @@ -197,7 +199,7 @@ private: std::string m_currentInst; // plot data representation type selected - int m_currentType; + int static m_currentType; /// current calibration produced in the 'Calibration' tab std::string m_currentCalibFilename; diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h index dda719b7a2caf327befc3207572a95b07500e5df..91cd94e0835b6f9da52f9896e98843f7d6f469d2 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h @@ -115,6 +115,14 @@ public: */ virtual std::string currentInstrument() const = 0; + /** + * Selected plot data representation will be applied, which will + * ran through python script + * + * @return which format should to applied for plotting data + */ + virtual int currentPlotType() const = 0; + /** * The Vanadium run number used in the current calibration * @@ -262,6 +270,14 @@ public: */ virtual void saveSettings() const = 0; + /** + * Saves the ouput files which are generated, this can be done + * via Output Files checkbox on the focus tab + * + * @return bool + */ + virtual bool saveOutputFiles() const = 0; + /** * Produces a single spectrum graph for focused output. Runs * plotSpectrum function via python. @@ -285,14 +301,6 @@ public: * @param wsName name of the workspace to plot (must be in the ADS) */ virtual void plotReplacingWindow(const std::string &wsName) = 0; - - /* - * Selected plot data representation will be applied, which will - * ran through python script - * - * @return which format should to applied for plotting data - */ - virtual int currentPlotType() const = 0; }; } // namespace CustomInterfaces diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp index 3eaf4ab45a93f469e62a7e1283be0559c0822a36..c2c32c4e2a7eb2f60de3a3a222bdf21b9fed3695 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -13,7 +13,6 @@ #include <boost/lexical_cast.hpp> #include <Poco/File.h> -#include <Poco/Path.h> #include <QThread> @@ -32,6 +31,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), @@ -1021,8 +1021,8 @@ void EnggDiffractionPresenter::focusingFinished() { * * @param bank instrument bank number to focus * - * @param specNos string specifying a list of spectra (for cropped - * focusing), only considered if not empty + * @param specNos string specifying a list of spectra (for "cropped" + * focusing or "texture" focusing), only considered if not empty * * @param dgFile detector grouping file name. If not empty implies * texture focusing @@ -1062,16 +1062,29 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, } std::string outWSName; + std::string specNumsOpenGenie; if (!dgFile.empty()) { + // doing focus "texture" outWSName = "engggui_focusing_output_ws_texture_bank_" + boost::lexical_cast<std::string>(bank); + specNumsOpenGenie = specNos; } else if (specNos.empty()) { + // doing focus "normal" / by banks outWSName = "engggui_focusing_output_ws_bank_" + boost::lexical_cast<std::string>(bank); + + // specnum for opengenie according to bank number + if (boost::lexical_cast<std::string>(bank) == "1") { + specNumsOpenGenie = "1 - 1200"; + } else if (boost::lexical_cast<std::string>(bank) == "2") { + specNumsOpenGenie = "1201 - 1400"; + } + } else { + // doing focus "cropped" outWSName = "engggui_focusing_output_ws_cropped"; + specNumsOpenGenie = specNos; } - try { auto alg = Algorithm::fromString("EnggFocus"); alg->initialize(); @@ -1088,8 +1101,8 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, // TODO: use detector positions (from calibrate full) when available // alg->setProperty(DetectorPositions, TableWorkspace) alg->execute(); - // plot Focused workspace according to the data type selected - plotFocusedWorkspace(outWSName); + // plot Focused workspace according to the data type selected + plotFocusedWorkspace(outWSName, boost::lexical_cast<std::string>(bank)); } catch (std::runtime_error &re) { g_log.error() << "Error in calibration. ", "Could not run the algorithm EnggCalibrate succesfully for bank " + @@ -1097,8 +1110,8 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, re.what() + " Please check also the log messages for details."; throw; } - g_log.notice() << "Produced focused workspace: " << outWSName << std::endl; + try { g_log.debug() << "Going to save focused output into nexus file: " << fullFilename << std::endl; @@ -1116,6 +1129,14 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, } g_log.notice() << "Saved focused workspace as file: " << fullFilename << std::endl; + + bool saveOutputFiles = m_view->saveOutputFiles(); + if (saveOutputFiles) { + 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); + } } /** @@ -1333,24 +1354,221 @@ void EnggDiffractionPresenter::calcVanadiumWorkspaces( * Checks the plot type selected and applies the appropriate * python function to apply during first bank and second bank * - * @param outWSName; title of the focused workspace + * @param outWSName title of the focused workspace + * @param bank the number of bank */ -void EnggDiffractionPresenter::plotFocusedWorkspace(std::string outWSName) { +void EnggDiffractionPresenter::plotFocusedWorkspace(std::string outWSName, + std::string bank) { const bool plotFocusedWS = m_view->focusedOutWorkspace(); int plotType = m_view->currentPlotType(); - if (plotFocusedWS == true && 0 == plotType) { - if (outWSName == "engggui_focusing_output_ws_bank_1") + if (plotFocusedWS) { + if (plotType == 0) { + if (bank == "1") + m_view->plotFocusedSpectrum(outWSName); + if (bank == "2") + m_view->plotReplacingWindow(outWSName); + } else if (1 == plotType) { + if (bank == "1") + m_view->plotFocusedSpectrum(outWSName); + if (bank == "2") + m_view->plotWaterfallSpectrum(outWSName); + } else if (2 == plotType) { m_view->plotFocusedSpectrum(outWSName); - if (outWSName == "engggui_focusing_output_ws_bank_2") - m_view->plotReplacingWindow(outWSName); - } else if (plotFocusedWS == true && 1 == plotType) { - if (outWSName == "engggui_focusing_output_ws_bank_1") - m_view->plotFocusedSpectrum(outWSName); - if (outWSName == "engggui_focusing_output_ws_bank_2") - m_view->plotWaterfallSpectrum(outWSName); - } else if (plotFocusedWS == true && 2 == plotType) { - m_view->plotFocusedSpectrum(outWSName); + } + } +} + +/** + * Convert the generated output files and saves them in + * FocusedXYE format + * + * @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 runNo) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runNo, bank, ".dat"); + + // Creates appropriate directory + Poco::Path saveDir = outFilesDir(runNo); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << std::endl; + auto alg = Algorithm::fromString("SaveFocusedXYE"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + 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 format file. ", + "Could not run the algorithm SaveFocusXYE succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << std::endl; +} + +/** + * Convert the generated output files and saves them in + * GSS format + * + * @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 runNo) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runNo, bank, ".gss"); + + // Creates appropriate directory + Poco::Path saveDir = outFilesDir(runNo); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << std::endl; + auto alg = Algorithm::fromString("SaveGSS"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + 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 format file. ", + "Could not run the algorithm saveGSS succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << std::endl; +} + +/** + * Convert the generated output files and saves them in + * OpenGenie format + * + * @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 bank, + std::string runNo) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runNo, bank, ".his"); + + // Creates appropriate directory + Poco::Path saveDir = outFilesDir(runNo); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << std::endl; + auto alg = Algorithm::fromString("SaveOpenGenieAscii"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setPropertyValue("SpecNumberField", specNums); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving OpenGenie format file. ", + "Could not run the algorithm SaveOpenGenieAscii succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << std::endl; +} + +/** + * Generates the required file name of the output files + * + * @param inputWorkspace title of the focused workspace + * @param runNo the run number as a string + * @param bank the number of the bank as a string + * @param format the format of the file to be saved as + */ +std::string EnggDiffractionPresenter::outFileNameFactory( + std::string inputWorkspace, std::string runNo, std::string bank, + std::string format) { + std::string fullFilename; + if (inputWorkspace.std::string::find("texture") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_texture_" + bank + format; + } + if (inputWorkspace.std::string::find("cropped") != std::string::npos) { + fullFilename = "ENGINX_" + runNo + "_cropped_" + + boost::lexical_cast<std::string>(g_croppedCounter) + format; + g_croppedCounter++; + } else { + fullFilename = "ENGINX_" + runNo + "_bank_" + bank + format; + } + return fullFilename; +} + +/** + * Generates a directory if not found and handles the path + * + * @param runNo the run number as a string + */ +Poco::Path EnggDiffractionPresenter::outFilesDir(std::string runNo) { + Poco::Path saveDir; + try { + +// takes to the root of directory according to the platform +// and appends the following string provided +#ifdef __unix__ + saveDir = Poco::Path().home(); + saveDir.append("EnginX_Mantid"); + saveDir.append("User"); + saveDir.append(runNo); + saveDir.append("Focus"); +#else + // else or for windows run this + saveDir = (saveDir).expand("C:/EnginX_Mantid/User/" + runNo + "/Focus/"); +#endif + + if (!Poco::File(saveDir.toString()).exists()) { + Poco::File(saveDir.toString()).createDirectories(); + } + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "error caused by file access/permission: " << e.what(); + } catch (std::runtime_error &re) { + g_log.error() << "Error while find/creating a path: " << re.what(); } + return saveDir; } } // namespace CustomInterfaces diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp index 281afa85eaff3569539a0a803ace7e433a59b7a4..ccd98974eb014d04e86557d598cd852ebdcbe4a4 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -25,6 +25,7 @@ namespace CustomInterfaces { DECLARE_SUBWINDOW(EnggDiffractionViewQtGUI) const double EnggDiffractionViewQtGUI::g_defaultRebinWidth = -0.0005; +int EnggDiffractionViewQtGUI::m_currentType = 0; const std::string EnggDiffractionViewQtGUI::g_iparmExtStr = "GSAS instrument parameters, IPARM file: PRM, PAR, IPAR, IPARAM " @@ -283,12 +284,13 @@ void EnggDiffractionViewQtGUI::saveSettings() const { m_uiTabCalib.lineEdit_current_calib_filename->text()); qs.setValue("user-params-new-vanadium-num", - m_uiTabCalib.lineEdit_new_vanadium_num->text()); + m_uiTabCalib.lineEdit_new_vanadium_num->getText()); qs.setValue("user-params-new-ceria-num", - m_uiTabCalib.lineEdit_new_ceria_num->text()); + m_uiTabCalib.lineEdit_new_ceria_num->getText()); // user params - focusing - qs.setValue("user-params-focus-runno", m_uiTabFocus.lineEdit_run_num->text()); + qs.setValue("user-params-focus-runno", + m_uiTabFocus.lineEdit_run_num->getText()); qs.beginWriteArray("user-params-focus-bank_i"); qs.setArrayIndex(0); @@ -298,17 +300,16 @@ void EnggDiffractionViewQtGUI::saveSettings() const { qs.endArray(); qs.setValue("user-params-focus-cropped-runno", - m_uiTabFocus.lineEdit_cropped_run_num->text()); + m_uiTabFocus.lineEdit_cropped_run_num->getText()); 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()); + m_uiTabFocus.lineEdit_texture_run_num->getText()); 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", @@ -385,11 +386,11 @@ std::string EnggDiffractionViewQtGUI::currentCeriaNo() const { } std::string EnggDiffractionViewQtGUI::newVanadiumNo() const { - return m_uiTabCalib.lineEdit_new_vanadium_num->text().toStdString(); + return m_uiTabCalib.lineEdit_new_vanadium_num->getText().toStdString(); } std::string EnggDiffractionViewQtGUI::newCeriaNo() const { - return m_uiTabCalib.lineEdit_new_ceria_num->text().toStdString(); + return m_uiTabCalib.lineEdit_new_ceria_num->getText().toStdString(); } std::string EnggDiffractionViewQtGUI::currentCalibFile() const { @@ -425,6 +426,7 @@ void EnggDiffractionViewQtGUI::enableCalibrateAndFocusActions(bool enable) { m_uiTabFocus.lineEdit_run_num->setEnabled(enable); m_uiTabFocus.pushButton_focus->setEnabled(enable); m_uiTabFocus.checkBox_FocusedWS->setEnabled(enable); + m_uiTabFocus.checkBox_SaveOutputFiles->setEnabled(enable); m_uiTabFocus.pushButton_focus->setEnabled(enable); m_uiTabFocus.pushButton_focus_cropped->setEnabled(enable); @@ -676,15 +678,15 @@ void EnggDiffractionViewQtGUI::browseTextureDetGroupingFile() { } std::string EnggDiffractionViewQtGUI::focusingRunNo() const { - return m_uiTabFocus.lineEdit_run_num->text().toStdString(); + return m_uiTabFocus.lineEdit_run_num->getText().toStdString(); } std::string EnggDiffractionViewQtGUI::focusingCroppedRunNo() const { - return m_uiTabFocus.lineEdit_cropped_run_num->text().toStdString(); + return m_uiTabFocus.lineEdit_cropped_run_num->getText().toStdString(); } std::string EnggDiffractionViewQtGUI::focusingTextureRunNo() const { - return m_uiTabFocus.lineEdit_texture_run_num->text().toStdString(); + return m_uiTabFocus.lineEdit_texture_run_num->getText().toStdString(); } std::string EnggDiffractionViewQtGUI::focusingDir() const { @@ -710,6 +712,10 @@ bool EnggDiffractionViewQtGUI::focusedOutWorkspace() const { return m_uiTabFocus.checkBox_FocusedWS->checkState(); } +bool EnggDiffractionViewQtGUI::saveOutputFiles() const { + return m_uiTabFocus.checkBox_SaveOutputFiles->checkState(); +} + void EnggDiffractionViewQtGUI::plotFocusStatus() { if (focusedOutWorkspace()) { m_uiTabFocus.comboBox_PlotData->setEnabled(true); @@ -719,10 +725,10 @@ void EnggDiffractionViewQtGUI::plotFocusStatus() { } void EnggDiffractionViewQtGUI::plotRepChanged(int /*idx*/) { - QComboBox *inst = m_uiTabFocus.comboBox_PlotData; - if (!inst) + QComboBox *plotType = m_uiTabFocus.comboBox_PlotData; + if (!plotType) return; - m_currentType = inst->currentIndex(); + m_currentType = plotType->currentIndex(); } void EnggDiffractionViewQtGUI::instrumentChanged(int /*idx*/) { diff --git a/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h b/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h index 90e5fc4a27d546725cd7160b03b6ee77588f55ce..3f099eb845d1bcddcc1e9ca3c33c41e3eece692e 100644 --- a/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h +++ b/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h @@ -50,6 +50,9 @@ public: // virtual std::string currentCalibFile() const; MOCK_CONST_METHOD0(currentCalibFile, std::string()); + // std::string currentPlotType + MOCK_CONST_METHOD0(currentPlotType, int()); + // virtual std::string newVanadiumNo() const; MOCK_CONST_METHOD0(newVanadiumNo, std::string()); @@ -104,6 +107,9 @@ public: // void saveSettings() const; MOCK_CONST_METHOD0(saveSettings, void()); + // std::string saveOutputFiles + MOCK_CONST_METHOD0(saveOutputFiles, bool()); + // virtual void plotFocusedSpectrum(); MOCK_METHOD1(plotFocusedSpectrum, void(const std::string &)); @@ -119,8 +125,7 @@ public: // virtual void plotReplacingWindow MOCK_METHOD1(plotReplacingWindow, void(const std::string &wsName)); - // std::string currentPlotType - MOCK_CONST_METHOD0(currentPlotType, int()); + }; #endif // MANTID_CUSTOMINTERFACES_ENGGDIFFRACTIONVIEWMOCK_H diff --git a/docs/source/interfaces/Engineering_Diffraction.rst b/docs/source/interfaces/Engineering_Diffraction.rst index fa92627075643a5f5df84bfa47f8633c0877e737..10c7cd263bfae9de07007325f2efb5606b076898 100644 --- a/docs/source/interfaces/Engineering_Diffraction.rst +++ b/docs/source/interfaces/Engineering_Diffraction.rst @@ -99,6 +99,24 @@ numbers. For example: 2, 100, 102, 107 3, 300, 310, 320-329, 350-370 +Output +^^^^^^ + +Under the output section, the user is provided with an option of +plotting data in three different formats. One Window - Replacing +Plots: will replace the previous graph and plot a new graph on top. +One Window - Waterfall: will plot all the generated focused +workspace graphs in one window which can be useful while comparing +various graphs. The Multiple Windows: will plot graph in +separate windows. + +The user also has an option of generated GSS, XYE and OpenGenie +formatted file by clicking the Output Files checkbox. This will +generated three different files for each focused output workspace +in Mantid. These files can be found with appropriate name at location: +C:\EnginX_Mantid\User\236516\Focus on Windows, the +EnginX_Mantid folder can be found on Desktop/Home on other platforms. + Settings --------