diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h index ab2cb4672c86bae2b479c406c6ba8a9076e5fe9b..fd4858acdea1345941737d7cd22f19f74c739ba8 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionPresenter.h @@ -176,6 +176,8 @@ private: Mantid::API::ITableWorkspace_sptr &vanIntegWS, Mantid::API::MatrixWorkspace_sptr &vanCurvesWS); + void plotFocusedWorkspace(std::string outWSName); + /// string to use for ENGINX file names (as a prefix, etc.) const static std::string g_enginxStr; diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui index da4954af8627faf0c93a9d1c3268b22d655fb790..76e0aa9e04571d14f1c1e5c9d4dc3fbe68065fd5 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionQtTabFocus.ui @@ -7,30 +7,123 @@ <x>0</x> <y>0</y> <width>614</width> - <height>533</height> + <height>545</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="6" column="0"> - <widget class="QGroupBox" name="groupBox_focus_2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_focus"> <property name="title"> - <string>Output</string> + <string>Focus run</string> </property> - <layout class="QGridLayout" name="gridLayout_2"> + <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> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="label_banks_sel"> + <property name="text"> + <string>Banks:</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>298</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>18</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QCheckBox" name="checkBox_focus_bank1"> + <property name="text"> + <string>1</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_focus_bank2"> + <property name="text"> + <string>2</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QCheckBox" name="checkBox_FocusedWS"> + <widget class="QLabel" name="label_run_num"> <property name="text"> - <string>Plot Focused Workspace</string> + <string>Run #:</string> </property> </widget> </item> <item> - <spacer name="horizontalSpacer_4"> + <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -42,12 +135,22 @@ </property> </spacer> </item> + <item> + <widget class="QLineEdit" name="lineEdit_run_num"> + <property name="text"> + <string/> + </property> + <property name="readOnly"> + <bool>false</bool> + </property> + </widget> + </item> </layout> </item> </layout> </widget> </item> - <item row="2" column="0"> + <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Focus Cropped</string> @@ -148,147 +251,96 @@ </layout> </widget> </item> - <item row="4" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>388</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox_focus"> + <item> + <widget class="QGroupBox" name="groupBox_2"> <property name="title"> - <string>Focus run</string> + <string>Focus Texture</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_7"> <item> - <spacer name="horizontalSpacer_3"> + <widget class="QLabel" name="label_texture_run_num"> + <property name="text"> + <string>Run #:</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_6"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>238</width> + <width>98</width> <height>20</height> </size> </property> </spacer> </item> <item> - <widget class="QPushButton" name="pushButton_focus"> + <widget class="QLineEdit" name="lineEdit_texture_run_num"> <property name="text"> - <string>Focus</string> + <string/> + </property> + <property name="readOnly"> + <bool>false</bool> </property> </widget> </item> </layout> </item> <item row="1" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_5"> + <layout class="QHBoxLayout" name="horizontalLayout_8"> <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_banks_sel"> - <property name="text"> - <string>Banks:</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>298</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>18</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Detector Grouping File:</string> + </property> + </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QCheckBox" name="checkBox_focus_bank1"> - <property name="text"> - <string>1</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBox_focus_bank2"> - <property name="text"> - <string>2</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> + <widget class="QLineEdit" name="lineEdit_texture_grouping_file"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> </item> - </layout> - </item> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QLabel" name="label_run_num"> + <widget class="QPushButton" name="pushButton_texture_browse_grouping_file"> <property name="text"> - <string>Run #:</string> + <string>Browse</string> </property> </widget> </item> + </layout> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_11"> <item> - <spacer name="horizontalSpacer"> + <spacer name="horizontalSpacer_9"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>98</width> + <width>40</width> <height>20</height> </size> </property> </spacer> </item> <item> - <widget class="QLineEdit" name="lineEdit_run_num"> + <widget class="QPushButton" name="pushButton_focus_texture"> <property name="text"> - <string/> - </property> - <property name="readOnly"> - <bool>false</bool> + <string>Focus</string> </property> </widget> </item> @@ -297,23 +349,42 @@ </layout> </widget> </item> - <item row="3" column="0"> - <widget class="QGroupBox" name="groupBox_2"> + <item> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QGroupBox" name="groupBox_focus_3"> + <property name="minimumSize"> + <size> + <width>596</width> + <height>111</height> + </size> + </property> <property name="title"> - <string>Focus Texture</string> + <string>Output</string> </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_7"> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_20"> <item> - <widget class="QLabel" name="label_texture_run_num"> + <widget class="QCheckBox" name="checkBox_FocusedWS"> <property name="text"> - <string>Run #:</string> + <string>Plot Focused Workspace</string> </property> </widget> </item> <item> - <spacer name="horizontalSpacer_6"> + <spacer name="horizontalSpacer_18"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -325,77 +396,106 @@ </property> </spacer> </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_21"> <item> - <widget class="QLineEdit" name="lineEdit_texture_run_num"> - <property name="text"> - <string/> + <spacer name="horizontalSpacer_19"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="readOnly"> - <bool>false</bool> + <property name="sizeHint" stdset="0"> + <size> + <width>98</width> + <height>20</height> + </size> </property> - </widget> + </spacer> </item> - </layout> - </item> - <item row="1" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_8"> <item> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="label_4"> <property name="text"> - <string>Detector Grouping File:</string> + <string>Plot Data Representation:</string> </property> </widget> </item> <item> - <widget class="QLineEdit" name="lineEdit_texture_grouping_file"> + <widget class="QComboBox" name="comboBox_PlotData"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>1</horstretch> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="readOnly"> - <bool>true</bool> + <property name="minimumSize"> + <size> + <width>175</width> + <height>10</height> + </size> </property> + <property name="sizeIncrement"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="baseSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <item> + <property name="text"> + <string>One Window - Replacing Plots</string> + </property> + </item> + <item> + <property name="text"> + <string>One Window - Waterfall</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiple Windows</string> + </property> + </item> </widget> </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_22"> <item> - <widget class="QPushButton" name="pushButton_texture_browse_grouping_file"> + <widget class="QCheckBox" name="checkBox_OutputFiles_"> <property name="text"> - <string>Browse</string> + <string>Output Files</string> </property> </widget> </item> - </layout> - </item> - <item row="2" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_11"> <item> - <spacer name="horizontalSpacer_9"> + <spacer name="horizontalSpacer_20"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>40</width> + <width>98</width> <height>20</height> </size> </property> </spacer> </item> - <item> - <widget class="QPushButton" name="pushButton_focus_texture"> - <property name="text"> - <string>Focus</string> - </property> - </widget> - </item> </layout> </item> </layout> </widget> </item> - <item row="5" column="0"> + <item> <layout class="QHBoxLayout" name="horizontalLayout_13"> <item> <spacer name="horizontalSpacer_11"> diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h index baed981c8f15aa12f32c87aa18132004d4e24ec8..ef099e716254d88448ed06d78aa0e5945b4b9b9e 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h @@ -121,6 +121,12 @@ public: virtual void plotFocusedSpectrum(const std::string &wsName); + virtual void plotWaterfallSpectrum(const std::string &wsName); + + virtual void plotReplacingWindow(const std::string &wsName); + + int currentPlotType() const { return m_currentType; } + private slots: /// for buttons, do calibrate, focus and similar void loadCalibrationClicked(); @@ -145,6 +151,12 @@ private slots: // slots of the general part of the interface void instrumentChanged(int idx); + // slots of the focus part of the interface + void plotRepChanged(int idx); + + // slots of plot spectrum check box status + void plotFocusStatus(); + // show the standard Mantid help window with this interface's help void openHelpWin(); @@ -183,6 +195,10 @@ private: /// instrument selected (ENGIN-X, etc.) std::string m_currentInst; + + // plot data representation type selected + int m_currentType; + /// current calibration produced in the 'Calibration' tab std::string m_currentCalibFilename; /// calibration settings - from/to the 'settings' tab diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionPresenter.h index a2c0240d4cefb1d2befa48388c9bb25ab47bfc01..01fcbcaa76dce48d4ff93578b350e60faef98845 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionPresenter.h @@ -38,16 +38,16 @@ public: /// These are user actions, triggered from the (passive) view, that need /// handling by the presenter enum Notification { - Start, ///< Start and setup interface - LoadExistingCalib, ///< Load a calibration already availble on disk - CalcCalib, ///< Calculate a (new) calibration - FocusRun, ///< Focus one or more run files - FocusCropped, ///< Focus one or more run files, cropped variant - FocusTexture, ///< Focus one or more run files, texture variant - ResetFocus, ///< Re-set / clear all focus inputs and options - LogMsg, ///< need to send a message to the Mantid log system - InstrumentChange, ///< Instrument selection updated - ShutDown ///< closing the interface + Start, ///< Start and setup interface + LoadExistingCalib, ///< Load a calibration already availble on disk + CalcCalib, ///< Calculate a (new) calibration + FocusRun, ///< Focus one or more run files + FocusCropped, ///< Focus one or more run files, cropped variant + FocusTexture, ///< Focus one or more run files, texture variant + ResetFocus, ///< Re-set / clear all focus inputs and options + LogMsg, ///< need to send a message to the Mantid log system + InstrumentChange, ///< Instrument selection updated + ShutDown ///< closing the interface }; /** diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h index e701764dac3f0d11fa716a65cde8b98fd4ea1e00..dda719b7a2caf327befc3207572a95b07500e5df 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/EnggDiffraction/IEnggDiffractionView.h @@ -269,6 +269,30 @@ public: * @param wsName name of the workspace to plot (must be in the ADS) */ virtual void plotFocusedSpectrum(const std::string &wsName) = 0; + + /** + * Produces a waterfall spectrum graph for focused output. Runs + * plotSpectrum function via python. + * + * @param wsName name of the workspace to plot (must be in the ADS) + */ + virtual void plotWaterfallSpectrum(const std::string &wsName) = 0; + + /** + * Produces a replaceable spectrum graph for focused output. Runs + * plotSpectrum function via python. + * + * @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 0b0be67c9f4055f395f0eedcd8b963851a9b1b64..3eaf4ab45a93f469e62a7e1283be0559c0822a36 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -57,7 +57,8 @@ void EnggDiffractionPresenter::cleanup() { if (m_workerThread) { if (m_workerThread->isRunning()) { g_log.notice() << "A calibration process is currently running, shutting " - "it down immediately..." << std::endl; + "it down immediately..." + << std::endl; m_workerThread->wait(10); } delete m_workerThread; @@ -146,7 +147,8 @@ void EnggDiffractionPresenter::processCalcCalib() { return; } g_log.notice() << "EnggDiffraction GUI: starting new calibration. This may " - "take a few seconds... " << std::endl; + "take a few seconds... " + << std::endl; const std::string outFilename = outputCalibFilename(vanNo, ceriaNo); @@ -414,10 +416,9 @@ void EnggDiffractionPresenter::parseCalibrateFilename(const std::string &path, * @param vanNo vanadium run number * @param ceriaNo ceria run number */ -void -EnggDiffractionPresenter::startAsyncCalibWorker(const std::string &outFilename, - const std::string &vanNo, - const std::string &ceriaNo) { +void EnggDiffractionPresenter::startAsyncCalibWorker( + const std::string &outFilename, const std::string &vanNo, + const std::string &ceriaNo) { delete m_workerThread; m_workerThread = new QThread(this); EnggDiffWorker *worker = @@ -466,11 +467,13 @@ void EnggDiffractionPresenter::doNewCalibration(const std::string &outFilename, } catch (std::runtime_error &) { g_log.error() << "The calibration calculations failed. One of the " "algorithms did not execute correctly. See log messages " - "for details. " << std::endl; + "for details. " + << std::endl; } catch (std::invalid_argument &) { g_log.error() << "The calibration calculations failed. Some input properties " - "were not valid. See log messages for details. " << std::endl; + "were not valid. See log messages for details. " + << std::endl; } // restore normal data search paths conf.setDataSearchDirs(tmpDirs); @@ -710,8 +713,8 @@ void EnggDiffractionPresenter::inputChecksBeforeFocusTexture( inputChecksBeforeFocus(); } -void -EnggDiffractionPresenter::inputChecksBanks(const std::vector<bool> &banks) { +void EnggDiffractionPresenter::inputChecksBanks( + const std::vector<bool> &banks) { if (0 == banks.size()) { const std::string msg = "Error in specification of banks found when starting the " @@ -848,7 +851,8 @@ void EnggDiffractionPresenter::doFocusRun( 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; + "this directory: " + << dir << std::endl; // TODO: this is almost 100% common with doNewCalibrate() - refactor EnggDiffCalibSettings cs = m_view->currentCalibSettings(); @@ -887,7 +891,8 @@ void EnggDiffractionPresenter::doFocusRun( loadDetectorGroupingCSV(dgFile, bankIDs, specs); } catch (std::runtime_error &re) { g_log.error() << "Error loading detector grouping file: " + dgFile + - ". Detailed error: " + re.what() << std::endl; + ". Detailed error: " + re.what() + << std::endl; bankIDs.clear(); specs.clear(); } @@ -903,8 +908,8 @@ void EnggDiffractionPresenter::doFocusRun( fpath.append(effectiveFilenames[idx]).toString(); g_log.notice() << "Generating new focused file (bank " + boost::lexical_cast<std::string>(bankIDs[idx]) + - ") for run " + runNo + - " into: " << effectiveFilenames[idx] << std::endl; + ") for run " + runNo + " into: " + << effectiveFilenames[idx] << std::endl; try { doFocusing(cs, fullFilename, runNo, bankIDs[idx], specs[idx], dgFile); m_focusFinishedOK = true; @@ -916,7 +921,8 @@ void EnggDiffractionPresenter::doFocusRun( } catch (std::invalid_argument &ia) { g_log.error() << "The focusing failed. Some input properties were not valid. " - "See log messages for details. Error: " << ia.what() << std::endl; + "See log messages for details. Error: " + << ia.what() << std::endl; } } @@ -1082,12 +1088,8 @@ void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, // TODO: use detector positions (from calibrate full) when available // alg->setProperty(DetectorPositions, TableWorkspace) alg->execute(); - - const bool plotFocusedWS = m_view->focusedOutWorkspace(); - if (plotFocusedWS == true) { - m_view->plotFocusedSpectrum(outWSName); - } - + // plot Focused workspace according to the data type selected + plotFocusedWorkspace(outWSName); } catch (std::runtime_error &re) { g_log.error() << "Error in calibration. ", "Could not run the algorithm EnggCalibrate succesfully for bank " + @@ -1160,7 +1162,8 @@ void EnggDiffractionPresenter::loadOrCalcVanadiumWorkspaces( "This is possibly because some of the settings are not " "consistent. Please check the log messages for " "details. Details: " + - std::string(ia.what()) << std::endl; + std::string(ia.what()) + << std::endl; throw; } catch (std::runtime_error &re) { g_log.error() << "Failed to calculate Vanadium corrections. " @@ -1169,7 +1172,8 @@ void EnggDiffractionPresenter::loadOrCalcVanadiumWorkspaces( "There was no obvious error in the input properties " "but the algorithm failed. Please check the log " "messages for details." + - std::string(re.what()) << std::endl; + std::string(re.what()) + << std::endl; throw; } } else { @@ -1325,5 +1329,29 @@ void EnggDiffractionPresenter::calcVanadiumWorkspaces( vanCurvesWS = ADS.retrieveWS<MatrixWorkspace>(curvesName); } +/** + * 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 + */ +void EnggDiffractionPresenter::plotFocusedWorkspace(std::string outWSName) { + const bool plotFocusedWS = m_view->focusedOutWorkspace(); + int plotType = m_view->currentPlotType(); + if (plotFocusedWS == true && 0 == plotType) { + if (outWSName == "engggui_focusing_output_ws_bank_1") + 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); + } +} + } // namespace CustomInterfaces } // namespace MantidQt diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp index c594b5b2732fcbf545042214fcd30a80cc6dc117..281afa85eaff3569539a0a803ace7e433a59b7a4 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -149,6 +149,7 @@ void EnggDiffractionViewQtGUI::doSetupTabSettings() { } void EnggDiffractionViewQtGUI::doSetupTabFocus() { + connect(m_uiTabFocus.pushButton_focus, SIGNAL(released()), this, SLOT(focusClicked())); @@ -163,6 +164,12 @@ void EnggDiffractionViewQtGUI::doSetupTabFocus() { connect(m_uiTabFocus.pushButton_reset, SIGNAL(released()), this, SLOT(focusResetClicked())); + + connect(m_uiTabFocus.comboBox_PlotData, SIGNAL(currentIndexChanged(int)), + this, SLOT(plotRepChanged(int))); + + connect(m_uiTabFocus.checkBox_FocusedWS, SIGNAL(clicked()), this, + SLOT(plotFocusStatus())); } void EnggDiffractionViewQtGUI::doSetupGeneralWidgets() { @@ -209,9 +216,11 @@ void EnggDiffractionViewQtGUI::readSettings() { qs.beginReadArray("user-params-focus-bank_i"); qs.setArrayIndex(0); - m_uiTabFocus.checkBox_focus_bank1->setChecked(qs.value("value", true).toBool()); + 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()); + m_uiTabFocus.checkBox_focus_bank2->setChecked( + qs.value("value", true).toBool()); qs.endArray(); m_uiTabFocus.lineEdit_cropped_run_num->setText( @@ -230,6 +239,8 @@ void EnggDiffractionViewQtGUI::readSettings() { m_uiTabFocus.checkBox_FocusedWS->setChecked( qs.value("user-params-focus-plot-ws", true).toBool()); + m_uiTabFocus.comboBox_PlotData->setCurrentIndex(0); + QString lastPath = MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); // TODO: this should become << >> operators on @@ -421,8 +432,20 @@ void EnggDiffractionViewQtGUI::enableCalibrateAndFocusActions(bool enable) { } void EnggDiffractionViewQtGUI::plotFocusedSpectrum(const std::string &wsName) { - std::string pyCode = "plotSpectrum('" + wsName + "', 0)"; + std::string pyCode = "win = plotSpectrum('" + wsName + "', 0)"; + + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + m_logMsgs.push_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} +void EnggDiffractionViewQtGUI::plotWaterfallSpectrum( + const std::string &wsName) { + // parameter of list ? + std::string pyCode = + "plotSpectrum('" + wsName + "', 0, waterfall = True, window = win)"; std::string status = runPythonCode(QString::fromStdString(pyCode), false).toStdString(); m_logMsgs.push_back("Plotted output focused data, with status string " + @@ -430,6 +453,17 @@ void EnggDiffractionViewQtGUI::plotFocusedSpectrum(const std::string &wsName) { m_presenter->notify(IEnggDiffractionPresenter::LogMsg); } +void EnggDiffractionViewQtGUI::plotReplacingWindow(const std::string &wsName) { + std::string pyCode = + "plotSpectrum('" + wsName + "', 0, window = win, clearWindow = True)"; + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + m_logMsgs.push_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + void EnggDiffractionViewQtGUI::resetFocus() { m_uiTabFocus.lineEdit_run_num->setText(""); m_uiTabFocus.checkBox_focus_bank1->setChecked(true); @@ -442,10 +476,9 @@ void EnggDiffractionViewQtGUI::resetFocus() { m_uiTabFocus.lineEdit_texture_grouping_file->setText(""); } -void -EnggDiffractionViewQtGUI::writeOutCalibFile(const std::string &outFilename, - const std::vector<double> &difc, - const std::vector<double> &tzero) { +void EnggDiffractionViewQtGUI::writeOutCalibFile( + const std::string &outFilename, const std::vector<double> &difc, + const std::vector<double> &tzero) { // TODO: this is horrible and should not last much here. // Avoid running Python code // Update this as soon as we have a more stable way of generating IPARM @@ -677,6 +710,21 @@ bool EnggDiffractionViewQtGUI::focusedOutWorkspace() const { return m_uiTabFocus.checkBox_FocusedWS->checkState(); } +void EnggDiffractionViewQtGUI::plotFocusStatus() { + if (focusedOutWorkspace()) { + m_uiTabFocus.comboBox_PlotData->setEnabled(true); + } else { + m_uiTabFocus.comboBox_PlotData->setEnabled(false); + } +} + +void EnggDiffractionViewQtGUI::plotRepChanged(int /*idx*/) { + QComboBox *inst = m_uiTabFocus.comboBox_PlotData; + if (!inst) + return; + m_currentType = inst->currentIndex(); +} + void EnggDiffractionViewQtGUI::instrumentChanged(int /*idx*/) { QComboBox *inst = m_ui.comboBox_instrument; if (!inst) diff --git a/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h b/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h index 043aba68ed970e70f14f1dd292e947a3ddcf03a6..6a83147a7069e733967abf8766e7cce520a39664 100644 --- a/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h +++ b/MantidQt/CustomInterfaces/test/EnggDiffractionPresenterTest.h @@ -385,6 +385,8 @@ public: // check automatic plotting EXPECT_CALL(mockView, focusedOutWorkspace()).Times(1).WillOnce(Return(true)); EXPECT_CALL(mockView, plotFocusedSpectrum(testing::_)).Times(1); + // There are two/three other tests that have the disabled_ prefix so they + // normally run // Should not try to use options for other types of focusing EXPECT_CALL(mockView, focusingCroppedRunNo()).Times(0); diff --git a/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h b/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h index 36c5bdd0a65a6a4d027c6a2f19146fc64ec9bf73..90e5fc4a27d546725cd7160b03b6ee77588f55ce 100644 --- a/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h +++ b/MantidQt/CustomInterfaces/test/EnggDiffractionViewMock.h @@ -105,7 +105,22 @@ public: MOCK_CONST_METHOD0(saveSettings, void()); // virtual void plotFocusedSpectrum(); - MOCK_METHOD1(plotFocusedSpectrum, void(const std::string&)); + MOCK_METHOD1(plotFocusedSpectrum, void(const std::string &)); + + // void plotFocusStatus(); + MOCK_METHOD0(plotFocusStatus, void()); + + // void plotRepChanged(); + MOCK_METHOD1(plotRepChanged, void(int idx)); + + // virtual void plotWaterfallSpectrum + MOCK_METHOD1(plotWaterfallSpectrum, void(const std::string &wsName)); + + // virtual void plotReplacingWindow + MOCK_METHOD1(plotReplacingWindow, void(const std::string &wsName)); + + // std::string currentPlotType + MOCK_CONST_METHOD0(currentPlotType, int()); }; #endif // MANTID_CUSTOMINTERFACES_ENGGDIFFRACTIONVIEWMOCK_H