From 905f6a2a54023bf2f8c67efbc80e4923e33d5c62 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 7 Oct 2014 16:57:00 +0100 Subject: [PATCH 01/15] Added new IndirectTab class Refs #10277 --- .../MantidQt/CustomInterfaces/CMakeLists.txt | 3 + .../IndirectDataReductionTab.h | 89 +------ .../src/IndirectDataReductionTab.cpp | 248 +----------------- 3 files changed, 6 insertions(+), 334 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt b/Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt index 40265b835a28..e1615af4d6e2 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt +++ b/Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt @@ -28,6 +28,7 @@ set ( SRC_FILES src/IndirectSimulation.cpp src/IndirectSimulationTab.cpp src/IndirectSqw.cpp + src/IndirectTab.cpp src/IndirectTransmission.cpp src/JumpFit.cpp src/MSDFit.cpp @@ -108,6 +109,7 @@ set ( INC_FILES inc/MantidQtCustomInterfaces/IndirectSimulationTab.h inc/MantidQtCustomInterfaces/IndirectSqw.h inc/MantidQtCustomInterfaces/IndirectTransmission.h + inc/MantidQtCustomInterfaces/IndirectTab.h inc/MantidQtCustomInterfaces/IReflPresenter.h inc/MantidQtCustomInterfaces/JumpFit.h inc/MantidQtCustomInterfaces/MSDFit.h @@ -191,6 +193,7 @@ set ( MOC_FILES inc/MantidQtCustomInterfaces/Background.h inc/MantidQtCustomInterfaces/IndirectSimulationTab.h inc/MantidQtCustomInterfaces/IndirectSqw.h inc/MantidQtCustomInterfaces/IndirectTransmission.h + inc/MantidQtCustomInterfaces/IndirectTab.h inc/MantidQtCustomInterfaces/JumpFit.h inc/MantidQtCustomInterfaces/MSDFit.h inc/MantidQtCustomInterfaces/Muon/ALCBaselineModellingPresenter.h diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h index e5bed025214c..80533e1201db 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h @@ -9,6 +9,7 @@ #include "MantidQtAPI/PythonRunner.h" #include "MantidQtAPI/QwtWorkspaceSpectrumData.h" #include "MantidQtCustomInterfaces/IndirectDataReduction.h" +#include "MantidQtCustomInterfaces/IndirectTab.h" #include "MantidQtMantidWidgets/RangeSelector.h" #include @@ -66,7 +67,7 @@ namespace CustomInterfaces File change history is stored at: Code Documentation is available at: */ - class DLLExport IndirectDataReductionTab : public QObject + class DLLExport IndirectDataReductionTab : public IndirectTab { Q_OBJECT @@ -74,99 +75,13 @@ namespace CustomInterfaces IndirectDataReductionTab(Ui::IndirectDataReduction& uiForm, QObject * parent = 0); virtual ~IndirectDataReductionTab(); - public slots: - void runTab(); - void setupTab(); - void validateTab(); - - protected slots: - /// Slot to handle when an algorithm finishes running - virtual void algorithmFinished(bool error); - protected: - /// Run the load algorithm with the given file name, output name and spectrum range - bool loadFile(const QString& filename, const QString& outputName, const int specMin = -1, const int specMax = -1); - Mantid::API::MatrixWorkspace_sptr loadInstrumentIfNotExist(std::string instrumentName, std::string analyser="", std::string reflection=""); /// Get information about the operation modes of an indirect instrument std::vector > > getInstrumentModes(std::string instrumentName); /// Function to get details about the instrument configuration defined on C2E tab std::map getInstrumentDetails(); - /// Function to plot a workspace to the miniplot using a workspace name - void plotMiniPlot(const QString& workspace, size_t index, const QString& plotID, const QString& curveID = ""); - /// Function to plot a workspace to the miniplot using a workspace pointer - void plotMiniPlot(const Mantid::API::MatrixWorkspace_const_sptr & workspace, size_t wsIndex, const QString& plotID, const QString& curveID = ""); - /// Function to replot a miniplot - void replot(const QString& plotID); - - /// Function to get the range of the curve displayed on the mini plot - std::pair getCurveRange(const QString& plotID); - /// Function to set the range of an axis on a plot - void setAxisRange(const QString& plotID, QwtPlot::Axis axis, std::pair range); - /// Function to autoscale a given axis based on the data in a curve - void setXAxisToCurve(const QString& plotID, const QString& curveID); - - /// Function to set the range limits of the plot - void setPlotRange(const QString& rsID, QtProperty* min, QtProperty* max, const std::pair& bounds); - /// Function to set the range selector on the mini plot - void setMiniPlotGuides(const QString& rsID, QtProperty* lower, QtProperty* upper, const std::pair& bounds); - - /// Function to run an algorithm on a seperate thread - void runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm); - - /// Parent QWidget (if applicable) - QWidget *m_parentWidget; - - /// Plot of the input - std::map m_plots; - /// Curve on the plot - std::map m_curves; - /// Range selector widget for mini plot - std::map m_rangeSelectors; - /// Tree of the properties - std::map m_propTrees; - - /// Internal list of the properties - QMap m_properties; - - /// Double manager to create properties - QtDoublePropertyManager* m_dblManager; - /// Boolean manager to create properties - QtBoolPropertyManager* m_blnManager; - /// Group manager to create properties - QtGroupPropertyManager* m_grpManager; - - /// Double editor facotry for the properties browser - DoubleEditorFactory* m_dblEdFac; - - /// Algorithm runner object to execute chains algorithms on a seperate thread from the GUI - MantidQt::API::BatchAlgorithmRunner *m_batchAlgoRunner; - - /// Use a Python runner for when we need the output of a script - MantidQt::API::PythonRunner m_pythonRunner; - - /// Validator for int inputs - QIntValidator *m_valInt; - /// Validator for double inputs - QDoubleValidator *m_valDbl; - /// Validator for positive double inputs - QDoubleValidator *m_valPosDbl; - - signals: - /// Send signal to parent window to show a message box to user - void showMessageBox(const QString& message); - /// Run a python script - void runAsPythonScript(const QString & code, bool no_output); - - private: - /// Overidden by child class. - virtual void setup() = 0; - /// Overidden by child class. - virtual void run() = 0; - /// Overidden by child class. - virtual bool validate() = 0; - protected: Ui::IndirectDataReduction m_uiForm; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp index 437dd8812226..d496b7ccaed7 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp @@ -18,25 +18,9 @@ namespace CustomInterfaces //---------------------------------------------------------------------------------------------- /** Constructor */ - IndirectDataReductionTab::IndirectDataReductionTab(Ui::IndirectDataReduction& uiForm, QObject* parent) : QObject(parent), - m_plots(), m_curves(), m_rangeSelectors(), - m_properties(), - m_dblManager(new QtDoublePropertyManager()), m_blnManager(new QtBoolPropertyManager()), m_grpManager(new QtGroupPropertyManager()), - m_dblEdFac(new DoubleEditorFactory()), + IndirectDataReductionTab::IndirectDataReductionTab(Ui::IndirectDataReduction& uiForm, QObject* parent) : IndirectTab(parent), m_uiForm(uiForm) { - m_parentWidget = dynamic_cast(parent); - - m_batchAlgoRunner = new MantidQt::API::BatchAlgorithmRunner(m_parentWidget); - m_valInt = new QIntValidator(m_parentWidget); - m_valDbl = new QDoubleValidator(m_parentWidget); - m_valPosDbl = new QDoubleValidator(m_parentWidget); - - const double tolerance = 0.00001; - m_valPosDbl->setBottom(tolerance); - - connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmFinished(bool))); - connect(&m_pythonRunner, SIGNAL(runAsPythonScript(const QString&, bool)), this, SIGNAL(runAsPythonScript(const QString&, bool))); } //---------------------------------------------------------------------------------------------- @@ -46,54 +30,6 @@ namespace CustomInterfaces { } - void IndirectDataReductionTab::runTab() - { - if(validate()) - run(); - else - g_log.warning("Failed to validate indirect tab input!"); - } - - void IndirectDataReductionTab::setupTab() - { - setup(); - } - - void IndirectDataReductionTab::validateTab() - { - validate(); - } - - /** - * Run the load algorithm with the supplied filename and spectrum range - * - * @param filename :: The name of the file to load - * @param outputName :: The name of the output workspace - * @param specMin :: Lower spectra bound - * @param specMax :: Upper spectra bound - * @return If the algorithm was successful - */ - bool IndirectDataReductionTab::loadFile(const QString& filename, const QString& outputName, - const int specMin, const int specMax) - { - Algorithm_sptr load = AlgorithmManager::Instance().createUnmanaged("Load", -1); - load->initialize(); - - load->setProperty("Filename", filename.toStdString()); - load->setProperty("OutputWorkspace", outputName.toStdString()); - - if(specMin != -1) - load->setProperty("SpectrumMin", specMin); - - if(specMax != -1) - load->setProperty("SpectrumMax", specMax); - - load->execute(); - - //If reloading fails we're out of options - return load->isExecuted(); - } - /** * Loads an empty instrument into a workspace (__empty_INST) unless the workspace already exists. * @@ -230,187 +166,5 @@ namespace CustomInterfaces return instDetails; } - /** - * Gets the range of the curve plotted in the mini plot - * - * @param curveID :: The string index of the curve in the m_curves map - * @return A pair containing the maximum and minimum points of the curve - */ - std::pair IndirectDataReductionTab::getCurveRange(const QString& curveID) - { - size_t npts = m_curves[curveID]->data().size(); - - if( npts < 2 ) - throw std::invalid_argument("Too few points on data curve to determine range."); - - return std::make_pair(m_curves[curveID]->data().x(0), m_curves[curveID]->data().x(npts-1)); - } - - /** - * Set the range of an axis on a miniplot - * - * @param plotID :: Index of plot in m_plots map - * @param axis :: ID of axis to set range of - * @param range :: Pair of double values specifying range - */ - void IndirectDataReductionTab::setAxisRange(const QString& plotID, QwtPlot::Axis axis, - std::pair range) - { - m_plots[plotID]->setAxisScale(axis, range.first, range.second); - } - - /** - * Sets the X axis of a plot to match the range of x values on a curve - * - * @param plotID :: Index of plot in m_plots map - * @param curveID :: Index of curve in m_curves map - */ - void IndirectDataReductionTab::setXAxisToCurve(const QString& plotID, const QString& curveID) - { - auto range = getCurveRange(curveID); - setAxisRange(plotID, QwtPlot::xBottom, range); - } - - /** - * Plot a workspace to the miniplot given a workspace name and - * a specturm index. - * - * This method uses the analysis data service to retrieve the workspace. - * - * @param workspace :: The name of the workspace - * @param index :: The spectrum index of the workspace - * @param plotID :: String index of the plot in the m_plots map - * @param curveID :: String index of the curve in the m_curves map, defaults to plot ID - */ - void IndirectDataReductionTab::plotMiniPlot(const QString& workspace, size_t index, - const QString& plotID, const QString& curveID) - { - auto ws = AnalysisDataService::Instance().retrieveWS(workspace.toStdString()); - plotMiniPlot(ws, index, plotID, curveID); - } - - /** - * Replot a given mini plot - * - * @param plotID :: ID of plot in m_plots map - */ - void IndirectDataReductionTab::replot(const QString& plotID) - { - m_plots[plotID]->replot(); - } - - /** - * Plot a workspace to the miniplot given a workspace pointer and - * a specturm index. - * - * @param workspace :: Pointer to the workspace - * @param wsIndex :: The spectrum index of the workspace - * @param plotID :: String index of the plot in the m_plots map - * @param curveID :: String index of the curve in the m_curves map, defaults to plot ID - */ - void IndirectDataReductionTab::plotMiniPlot(const Mantid::API::MatrixWorkspace_const_sptr & workspace, size_t wsIndex, - const QString& plotID, const QString& curveID) - { - using Mantid::MantidVec; - - QString cID = curveID; - if(cID == "") - cID = plotID; - - //check if we can plot - if( wsIndex >= workspace->getNumberHistograms() || workspace->readX(0).size() < 2 ) - return; - - QwtWorkspaceSpectrumData wsData(*workspace, static_cast(wsIndex), false); - - if ( m_curves[cID] != NULL ) - { - m_curves[cID]->attach(0); - delete m_curves[cID]; - m_curves[cID] = NULL; - } - - size_t nhist = workspace->getNumberHistograms(); - if ( wsIndex >= nhist ) - { - emit showMessageBox("Error: Workspace index out of range."); - } - else - { - m_curves[cID] = new QwtPlotCurve(); - m_curves[cID]->setData(wsData); - m_curves[cID]->attach(m_plots[plotID]); - - m_plots[plotID]->replot(); - } - } - - /** - * Sets the edge bounds of plot to prevent the user inputting invalid values - * Also sets limits for range selector movement - * - * @param rsID :: The string index of the range selector in the map m_rangeSelectors - * @param min :: The lower bound property in the property browser - * @param max :: The upper bound property in the property browser - * @param bounds :: The upper and lower bounds to be set - */ - void IndirectDataReductionTab::setPlotRange(const QString& rsID, QtProperty* min, QtProperty* max, - const std::pair& bounds) - { - m_dblManager->setMinimum(min, bounds.first); - m_dblManager->setMaximum(min, bounds.second); - m_dblManager->setMinimum(max, bounds.first); - m_dblManager->setMaximum(max, bounds.second); - m_rangeSelectors[rsID]->setRange(bounds.first, bounds.second); - } - - /** - * Set the position of the guides on the mini plot - * - * @param rsID :: The string index of the range selector in the map m_rangeSelectors - * @param lower :: The lower bound property in the property browser - * @param upper :: The upper bound property in the property browser - * @param bounds :: The upper and lower bounds to be set - */ - void IndirectDataReductionTab::setMiniPlotGuides(const QString& rsID, QtProperty* lower, QtProperty* upper, - const std::pair& bounds) - { - m_dblManager->setValue(lower, bounds.first); - m_dblManager->setValue(upper, bounds.second); - m_rangeSelectors[rsID]->setMinimum(bounds.first); - m_rangeSelectors[rsID]->setMaximum(bounds.second); - } - - /** - * Runs an algorithm async - * - * @param algorithm :: The algorithm to be run - */ - void IndirectDataReductionTab::runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm) - { - algorithm->setRethrows(true); - - // There should never really be unexecuted algorithms in the queue, but it is worth warning in case of possible weirdness - size_t batchQueueLength = m_batchAlgoRunner->queueLength(); - if(batchQueueLength > 0) - g_log.warning() << "Batch queue already contains " << batchQueueLength << " algorithms!" << std::endl; - - m_batchAlgoRunner->addAlgorithm(algorithm); - m_batchAlgoRunner->executeBatchAsync(); - } - - /** - * Handles getting the results of an algorithm running async - * - * @param error :: True if execution failed, false otherwise - */ - void IndirectDataReductionTab::algorithmFinished(bool error) - { - if(error) - { - emit showMessageBox("Error running algorithm. \nSee results log for details."); - } - } - } // namespace CustomInterfaces } // namespace Mantid From d1a232a0ac8eff300409edf9d60a348d43581aa7 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 7 Oct 2014 17:00:06 +0100 Subject: [PATCH 02/15] Added missing new tab files refs #10277 --- .../MantidQtCustomInterfaces/IndirectTab.h | 167 +++++++++++ .../CustomInterfaces/src/IndirectTab.cpp | 279 ++++++++++++++++++ 2 files changed, 446 insertions(+) create mode 100644 Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h create mode 100644 Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h new file mode 100644 index 000000000000..1d457dc69f91 --- /dev/null +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h @@ -0,0 +1,167 @@ +#ifndef MANTID_CUSTOMINTERFACES_INDIRECTTAB_H_ +#define MANTID_CUSTOMINTERFACES_INDIRECTTAB_H_ + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidKernel/System.h" +#include "MantidQtAPI/AlgorithmRunner.h" +#include "MantidQtAPI/BatchAlgorithmRunner.h" +#include "MantidQtAPI/PythonRunner.h" +#include "MantidQtAPI/QwtWorkspaceSpectrumData.h" +#include "MantidQtMantidWidgets/RangeSelector.h" + +#include +#include +#include +#include + +#include +#include + +// Suppress a warning coming out of code that isn't ours +#if defined(__INTEL_COMPILER) + #pragma warning disable 1125 +#elif defined(__GNUC__) + #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6 ) + #pragma GCC diagnostic push + #endif + #pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif +#include "DoubleEditorFactory.h" +#if defined(__INTEL_COMPILER) + #pragma warning enable 1125 +#elif defined(__GNUC__) + #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6 ) + #pragma GCC diagnostic pop + #endif +#endif + +namespace MantidQt +{ +namespace CustomInterfaces +{ + /** IndirectTab : TODO: DESCRIPTION + + @author Dan Nixon + @date 13/08/2013 + + Copyright © 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + File change history is stored at: + Code Documentation is available at: + */ + class DLLExport IndirectTab : public QObject + { + Q_OBJECT + + public: + IndirectTab(QObject* parent = 0); + virtual ~IndirectTab(); + + public slots: + void runTab(); + void setupTab(); + void validateTab(); + + protected slots: + /// Slot to handle when an algorithm finishes running + virtual void algorithmFinished(bool error); + + protected: + /// Run the load algorithm with the given file name, output name and spectrum range + bool loadFile(const QString& filename, const QString& outputName, const int specMin = -1, const int specMax = -1); + + /// Function to plot a workspace to the miniplot using a workspace name + void plotMiniPlot(const QString& workspace, size_t index, const QString& plotID, const QString& curveID = ""); + /// Function to plot a workspace to the miniplot using a workspace pointer + void plotMiniPlot(const Mantid::API::MatrixWorkspace_const_sptr & workspace, size_t wsIndex, const QString& plotID, const QString& curveID = ""); + /// Function to replot a miniplot + void replot(const QString& plotID); + + /// Function to get the range of the curve displayed on the mini plot + std::pair getCurveRange(const QString& plotID); + /// Function to set the range of an axis on a plot + void setAxisRange(const QString& plotID, QwtPlot::Axis axis, std::pair range); + /// Function to autoscale a given axis based on the data in a curve + void setXAxisToCurve(const QString& plotID, const QString& curveID); + + /// Function to set the range limits of the plot + void setPlotRange(const QString& rsID, QtProperty* min, QtProperty* max, const std::pair& bounds); + /// Function to set the range selector on the mini plot + void setMiniPlotGuides(const QString& rsID, QtProperty* lower, QtProperty* upper, const std::pair& bounds); + + /// Function to run an algorithm on a seperate thread + void runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm); + + /// Parent QWidget (if applicable) + QWidget *m_parentWidget; + + /// Plot of the input + std::map m_plots; + /// Curve on the plot + std::map m_curves; + /// Range selector widget for mini plot + std::map m_rangeSelectors; + /// Tree of the properties + std::map m_propTrees; + + /// Internal list of the properties + QMap m_properties; + + /// Double manager to create properties + QtDoublePropertyManager* m_dblManager; + /// Boolean manager to create properties + QtBoolPropertyManager* m_blnManager; + /// Group manager to create properties + QtGroupPropertyManager* m_grpManager; + + /// Double editor facotry for the properties browser + DoubleEditorFactory* m_dblEdFac; + + /// Algorithm runner object to execute chains algorithms on a seperate thread from the GUI + MantidQt::API::BatchAlgorithmRunner *m_batchAlgoRunner; + + /// Use a Python runner for when we need the output of a script + MantidQt::API::PythonRunner m_pythonRunner; + + /// Validator for int inputs + QIntValidator *m_valInt; + /// Validator for double inputs + QDoubleValidator *m_valDbl; + /// Validator for positive double inputs + QDoubleValidator *m_valPosDbl; + + signals: + /// Send signal to parent window to show a message box to user + void showMessageBox(const QString& message); + /// Run a python script + void runAsPythonScript(const QString & code, bool no_output); + + private: + /// Overidden by child class. + virtual void setup() = 0; + /// Overidden by child class. + virtual void run() = 0; + /// Overidden by child class. + virtual bool validate() = 0; + + }; +} // namespace CustomInterfaces +} // namespace Mantid + +#endif /* MANTID_CUSTOMINTERFACES_INDIRECTTAB_H_ */ diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp new file mode 100644 index 000000000000..e976c9094652 --- /dev/null +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp @@ -0,0 +1,279 @@ +#include "MantidQtCustomInterfaces/IndirectTab.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidKernel/Logger.h" + +using namespace Mantid::API; +using namespace Mantid::Geometry; + +namespace +{ + Mantid::Kernel::Logger g_log("IndirectTab"); +} + +namespace MantidQt +{ +namespace CustomInterfaces +{ + //---------------------------------------------------------------------------------------------- + /** Constructor + */ + IndirectTab::IndirectTab(QObject* parent) : QObject(parent), + m_plots(), m_curves(), m_rangeSelectors(), + m_properties(), + m_dblManager(new QtDoublePropertyManager()), m_blnManager(new QtBoolPropertyManager()), m_grpManager(new QtGroupPropertyManager()), + m_dblEdFac(new DoubleEditorFactory()) + { + m_parentWidget = dynamic_cast(parent); + + m_batchAlgoRunner = new MantidQt::API::BatchAlgorithmRunner(m_parentWidget); + m_valInt = new QIntValidator(m_parentWidget); + m_valDbl = new QDoubleValidator(m_parentWidget); + m_valPosDbl = new QDoubleValidator(m_parentWidget); + + const double tolerance = 0.00001; + m_valPosDbl->setBottom(tolerance); + + connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(algorithmFinished(bool))); + connect(&m_pythonRunner, SIGNAL(runAsPythonScript(const QString&, bool)), this, SIGNAL(runAsPythonScript(const QString&, bool))); + } + + //---------------------------------------------------------------------------------------------- + /** Destructor + */ + IndirectTab::~IndirectTab() + { + } + + void IndirectTab::runTab() + { + if(validate()) + run(); + else + g_log.warning("Failed to validate indirect tab input!"); + } + + void IndirectTab::setupTab() + { + setup(); + } + + void IndirectTab::validateTab() + { + validate(); + } + + /** + * Run the load algorithm with the supplied filename and spectrum range + * + * @param filename :: The name of the file to load + * @param outputName :: The name of the output workspace + * @param specMin :: Lower spectra bound + * @param specMax :: Upper spectra bound + * @return If the algorithm was successful + */ + bool IndirectTab::loadFile(const QString& filename, const QString& outputName, + const int specMin, const int specMax) + { + Algorithm_sptr load = AlgorithmManager::Instance().createUnmanaged("Load", -1); + load->initialize(); + + load->setProperty("Filename", filename.toStdString()); + load->setProperty("OutputWorkspace", outputName.toStdString()); + + if(specMin != -1) + load->setProperty("SpectrumMin", specMin); + + if(specMax != -1) + load->setProperty("SpectrumMax", specMax); + + load->execute(); + + //If reloading fails we're out of options + return load->isExecuted(); + } + + /** + * Gets the range of the curve plotted in the mini plot + * + * @param curveID :: The string index of the curve in the m_curves map + * @return A pair containing the maximum and minimum points of the curve + */ + std::pair IndirectTab::getCurveRange(const QString& curveID) + { + size_t npts = m_curves[curveID]->data().size(); + + if( npts < 2 ) + throw std::invalid_argument("Too few points on data curve to determine range."); + + return std::make_pair(m_curves[curveID]->data().x(0), m_curves[curveID]->data().x(npts-1)); + } + + /** + * Set the range of an axis on a miniplot + * + * @param plotID :: Index of plot in m_plots map + * @param axis :: ID of axis to set range of + * @param range :: Pair of double values specifying range + */ + void IndirectTab::setAxisRange(const QString& plotID, QwtPlot::Axis axis, + std::pair range) + { + m_plots[plotID]->setAxisScale(axis, range.first, range.second); + } + + /** + * Sets the X axis of a plot to match the range of x values on a curve + * + * @param plotID :: Index of plot in m_plots map + * @param curveID :: Index of curve in m_curves map + */ + void IndirectTab::setXAxisToCurve(const QString& plotID, const QString& curveID) + { + auto range = getCurveRange(curveID); + setAxisRange(plotID, QwtPlot::xBottom, range); + } + + /** + * Plot a workspace to the miniplot given a workspace name and + * a specturm index. + * + * This method uses the analysis data service to retrieve the workspace. + * + * @param workspace :: The name of the workspace + * @param index :: The spectrum index of the workspace + * @param plotID :: String index of the plot in the m_plots map + * @param curveID :: String index of the curve in the m_curves map, defaults to plot ID + */ + void IndirectTab::plotMiniPlot(const QString& workspace, size_t index, + const QString& plotID, const QString& curveID) + { + auto ws = AnalysisDataService::Instance().retrieveWS(workspace.toStdString()); + plotMiniPlot(ws, index, plotID, curveID); + } + + /** + * Replot a given mini plot + * + * @param plotID :: ID of plot in m_plots map + */ + void IndirectTab::replot(const QString& plotID) + { + m_plots[plotID]->replot(); + } + + /** + * Plot a workspace to the miniplot given a workspace pointer and + * a specturm index. + * + * @param workspace :: Pointer to the workspace + * @param wsIndex :: The spectrum index of the workspace + * @param plotID :: String index of the plot in the m_plots map + * @param curveID :: String index of the curve in the m_curves map, defaults to plot ID + */ + void IndirectTab::plotMiniPlot(const Mantid::API::MatrixWorkspace_const_sptr & workspace, size_t wsIndex, + const QString& plotID, const QString& curveID) + { + using Mantid::MantidVec; + + QString cID = curveID; + if(cID == "") + cID = plotID; + + //check if we can plot + if( wsIndex >= workspace->getNumberHistograms() || workspace->readX(0).size() < 2 ) + return; + + QwtWorkspaceSpectrumData wsData(*workspace, static_cast(wsIndex), false); + + if ( m_curves[cID] != NULL ) + { + m_curves[cID]->attach(0); + delete m_curves[cID]; + m_curves[cID] = NULL; + } + + size_t nhist = workspace->getNumberHistograms(); + if ( wsIndex >= nhist ) + { + emit showMessageBox("Error: Workspace index out of range."); + } + else + { + m_curves[cID] = new QwtPlotCurve(); + m_curves[cID]->setData(wsData); + m_curves[cID]->attach(m_plots[plotID]); + + m_plots[plotID]->replot(); + } + } + + /** + * Sets the edge bounds of plot to prevent the user inputting invalid values + * Also sets limits for range selector movement + * + * @param rsID :: The string index of the range selector in the map m_rangeSelectors + * @param min :: The lower bound property in the property browser + * @param max :: The upper bound property in the property browser + * @param bounds :: The upper and lower bounds to be set + */ + void IndirectTab::setPlotRange(const QString& rsID, QtProperty* min, QtProperty* max, + const std::pair& bounds) + { + m_dblManager->setMinimum(min, bounds.first); + m_dblManager->setMaximum(min, bounds.second); + m_dblManager->setMinimum(max, bounds.first); + m_dblManager->setMaximum(max, bounds.second); + m_rangeSelectors[rsID]->setRange(bounds.first, bounds.second); + } + + /** + * Set the position of the guides on the mini plot + * + * @param rsID :: The string index of the range selector in the map m_rangeSelectors + * @param lower :: The lower bound property in the property browser + * @param upper :: The upper bound property in the property browser + * @param bounds :: The upper and lower bounds to be set + */ + void IndirectTab::setMiniPlotGuides(const QString& rsID, QtProperty* lower, QtProperty* upper, + const std::pair& bounds) + { + m_dblManager->setValue(lower, bounds.first); + m_dblManager->setValue(upper, bounds.second); + m_rangeSelectors[rsID]->setMinimum(bounds.first); + m_rangeSelectors[rsID]->setMaximum(bounds.second); + } + + /** + * Runs an algorithm async + * + * @param algorithm :: The algorithm to be run + */ + void IndirectTab::runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm) + { + algorithm->setRethrows(true); + + // There should never really be unexecuted algorithms in the queue, but it is worth warning in case of possible weirdness + size_t batchQueueLength = m_batchAlgoRunner->queueLength(); + if(batchQueueLength > 0) + g_log.warning() << "Batch queue already contains " << batchQueueLength << " algorithms!" << std::endl; + + m_batchAlgoRunner->addAlgorithm(algorithm); + m_batchAlgoRunner->executeBatchAsync(); + } + + /** + * Handles getting the results of an algorithm running async + * + * @param error :: True if execution failed, false otherwise + */ + void IndirectTab::algorithmFinished(bool error) + { + if(error) + { + emit showMessageBox("Error running algorithm. \nSee results log for details."); + } + } + +} // namespace CustomInterfaces +} // namespace Mantid From 6b594b2808065067f9da35573474f22e1f78eae4 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 8 Oct 2014 10:21:49 +0100 Subject: [PATCH 03/15] Work in progress, IndirectBayesTab inherit from IndirectTab Refs #10277 --- .../IndirectBayesTab.h | 41 +----- .../MantidQtCustomInterfaces/IndirectTab.h | 4 +- .../inc/MantidQtCustomInterfaces/JumpFit.h | 9 +- .../inc/MantidQtCustomInterfaces/Quasi.h | 5 +- .../inc/MantidQtCustomInterfaces/ResNorm.h | 5 +- .../inc/MantidQtCustomInterfaces/Stretch.h | 5 +- .../CustomInterfaces/src/IndirectBayes.cpp | 4 +- .../CustomInterfaces/src/IndirectBayesTab.cpp | 121 +----------------- .../CustomInterfaces/src/IndirectTab.cpp | 2 +- .../MantidQt/CustomInterfaces/src/JumpFit.cpp | 32 +++-- .../MantidQt/CustomInterfaces/src/Quasi.cpp | 29 +++-- .../MantidQt/CustomInterfaces/src/ResNorm.cpp | 31 +++-- .../MantidQt/CustomInterfaces/src/Stretch.cpp | 28 +++- 13 files changed, 119 insertions(+), 197 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h index 56a19bc98052..00cc6d7b66ff 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h @@ -2,6 +2,7 @@ #define MANTID_CUSTOMINTERFACES_INDIRECTBAYESTAB_H_ #include "MantidAPI/MatrixWorkspace.h" +#include "MantidQtCustomInterfaces/IndirectTab.h" #include "MantidQtMantidWidgets/RangeSelector.h" #include "MantidQtAPI/QwtWorkspaceSpectrumData.h" @@ -71,7 +72,7 @@ namespace MantidQt /// precision for integer properties in bayes tabs static const unsigned int INT_DECIMALS = 0; - class DLLExport IndirectBayesTab : public QWidget + class DLLExport IndirectBayesTab : public IndirectTab { Q_OBJECT @@ -84,8 +85,6 @@ namespace MantidQt /// Base methods implemented in derived classes virtual QString help() = 0; - virtual bool validate() = 0; - virtual void run() = 0; virtual void loadSettings(const QSettings& settings) = 0; signals: @@ -94,53 +93,27 @@ namespace MantidQt /// Send signal to parent window to show a message box to user void showMessageBox(const QString& message); - protected slots: - /// Slot for when the min range on the range selector changes - virtual void minValueChanged(double min) = 0; - /// Slot for when the min range on the range selector changes - virtual void maxValueChanged(double max) = 0; - /// Slot to handle when a user edits a property - virtual void updateProperties(QtProperty* prop, double val) = 0; + protected slots: + /// Slot to update the guides when the range properties change + void updateProperties(QtProperty* prop, double val); protected: - /// Function to plot a workspace to the miniplot using a workspace name - void plotMiniPlot(const QString& workspace, size_t index); - /// Function to plot a workspace to the miniplot using a workspace pointer - void plotMiniPlot(const Mantid::API::MatrixWorkspace_const_sptr & workspace, size_t wsIndex); - /// Function to set the range selector on the mini plot - void setMiniPlotGuides(QtProperty* lower, QtProperty* upper, const std::pair& bounds); /// Function to run a string as python code void runPythonScript(const QString& pyInput); /// Function to read an instrument's resolution from the IPF using a string bool getInstrumentResolution(const QString& filename, std::pair& res); /// Function to read an instrument's resolution from the IPF using a workspace pointer bool getInstrumentResolution(Mantid::API::MatrixWorkspace_const_sptr ws, std::pair& res); - /// Function to set the range limits of the plot - void setPlotRange(QtProperty* min, QtProperty* max, const std::pair& bounds); /// Function to set the position of the lower guide on the plot void updateLowerGuide(QtProperty* lower, QtProperty* upper, double value); /// Function to set the position of the upper guide on the plot void updateUpperGuide(QtProperty* lower, QtProperty* upper, double value); - /// Function to get the range of the curve displayed on the mini plot - std::pair getCurveRange(); - - /// Plot of the input - QwtPlot* m_plot; - /// Curve on the plot - QwtPlotCurve* m_curve; - /// Range selector widget for mini plot - MantidQt::MantidWidgets::RangeSelector* m_rangeSelector; + /// Tree of the properties QtTreePropertyBrowser* m_propTree; - /// Internal list of the properties - QMap m_properties; - /// Double manager to create properties - QtDoublePropertyManager* m_dblManager; - /// Double editor facotry for the properties browser - DoubleEditorFactory* m_dblEdFac; }; } // namespace CustomInterfaces } // namespace Mantid -#endif \ No newline at end of file +#endif diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h index 1d457dc69f91..a6481550d644 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h @@ -43,7 +43,7 @@ namespace CustomInterfaces /** IndirectTab : TODO: DESCRIPTION @author Dan Nixon - @date 13/08/2013 + @date 08/10/2014 Copyright © 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory @@ -76,7 +76,7 @@ namespace CustomInterfaces public slots: void runTab(); void setupTab(); - void validateTab(); + bool validateTab(); protected slots: /// Slot to handle when an algorithm finishes running diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h index 582079841a94..8b1ad5c6aab9 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h @@ -17,6 +17,7 @@ namespace MantidQt // Inherited methods from IndirectBayesTab QString help() { return "JumpFit"; }; + void setup(); bool validate(); void run(); /// Load default settings into the interface @@ -28,19 +29,19 @@ namespace MantidQt /// Slot to handle plotting a different spectrum of the workspace void handleWidthChange(const QString& text); /// Slot for when the min range on the range selector changes - virtual void minValueChanged(double min); + void minValueChanged(double min); /// Slot for when the min range on the range selector changes - virtual void maxValueChanged(double max); + void maxValueChanged(double max); /// Slot to update the guides when the range properties change void updateProperties(QtProperty* prop, double val); /// Find all spectra with width data in the workspace void findAllWidths(Mantid::API::MatrixWorkspace_const_sptr ws); private: - //The ui form + // The UI form Ui::JumpFit m_uiForm; // map of axis labels to spectrum number - std::map spectraList; + std::map spectraList; }; } // namespace CustomInterfaces diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Quasi.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Quasi.h index eefcaad95e9c..f574f325c3d6 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Quasi.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Quasi.h @@ -17,6 +17,7 @@ namespace MantidQt // Inherited methods from IndirectBayesTab QString help() { return "Quasi"; }; + void setup(); bool validate(); void run(); /// Load default settings into the interface @@ -24,9 +25,9 @@ namespace MantidQt private slots: /// Slot for when the min range on the range selector changes - virtual void minValueChanged(double min); + void minValueChanged(double min); /// Slot for when the min range on the range selector changes - virtual void maxValueChanged(double max); + void maxValueChanged(double max); /// Slot to update the guides when the range properties change void updateProperties(QtProperty* prop, double val); /// Slot to handle when a new sample file is available diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ResNorm.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ResNorm.h index d84a5506743a..1ed67276dacf 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ResNorm.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ResNorm.h @@ -17,6 +17,7 @@ namespace MantidQt // Inherited methods from IndirectBayesTab QString help() { return "ResNorm"; }; + void setup(); bool validate(); void run(); /// Load default settings into the interface @@ -26,9 +27,9 @@ namespace MantidQt /// Handle when the vanadium input is ready void handleVanadiumInputReady(const QString& filename); /// Slot for when the min range on the range selector changes - virtual void minValueChanged(double min); + void minValueChanged(double min); /// Slot for when the min range on the range selector changes - virtual void maxValueChanged(double max); + void maxValueChanged(double max); /// Slot to update the guides when the range properties change void updateProperties(QtProperty* prop, double val); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Stretch.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Stretch.h index 998ce12dc601..b35d2dec4adf 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Stretch.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Stretch.h @@ -17,6 +17,7 @@ namespace MantidQt // Inherited methods from IndirectBayesTab QString help() { return "Stretch"; }; + void setup(); bool validate(); void run(); /// Load default settings into the interface @@ -24,9 +25,9 @@ namespace MantidQt private slots: /// Slot for when the min range on the range selector changes - virtual void minValueChanged(double min); + void minValueChanged(double min); /// Slot for when the min range on the range selector changes - virtual void maxValueChanged(double max); + void maxValueChanged(double max); /// Slot to update the guides when the range properties change void updateProperties(QtProperty* prop, double val); /// Slot to handle when a new sample file is available diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayes.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayes.cpp index 8f791ef1f140..073f0c610255 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayes.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayes.cpp @@ -110,9 +110,9 @@ void IndirectBayes::runClicked() { int tabIndex = m_uiForm.indirectBayesTabs->currentIndex(); - if(m_bayesTabs[tabIndex]->validate()) + if(m_bayesTabs[tabIndex]->validateTab()) { - m_bayesTabs[tabIndex]->run(); + m_bayesTabs[tabIndex]->runTab(); } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp index 7139ae889bf1..d3f43bcae84e 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp @@ -12,22 +12,13 @@ namespace MantidQt //---------------------------------------------------------------------------------------------- /** Constructor */ - IndirectBayesTab::IndirectBayesTab(QWidget * parent) : QWidget(parent), - m_plot(new QwtPlot(parent)), m_curve(new QwtPlotCurve()), m_rangeSelector(new MantidWidgets::RangeSelector(m_plot)), - m_propTree(new QtTreePropertyBrowser()), m_properties(), m_dblManager(new QtDoublePropertyManager()), - m_dblEdFac(new DoubleEditorFactory()) + IndirectBayesTab::IndirectBayesTab(QWidget * parent) : IndirectTab(parent), + m_propTree(new QtTreePropertyBrowser()) { m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac); - m_rangeSelector->setInfoOnly(false); - connect(m_rangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); - connect(m_rangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + // Connect double maneger signals connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateProperties(QtProperty*, double))); - - // initilise plot - m_plot->setCanvasBackground(Qt::white); - m_plot->setAxisFont(QwtPlot::xBottom, parent->font()); - m_plot->setAxisFont(QwtPlot::yLeft, parent->font()); } //---------------------------------------------------------------------------------------------- @@ -58,62 +49,6 @@ namespace MantidQt emit executePythonScript(pyInput, true); } - /** - * Plot a workspace to the miniplot given a workspace name and - * a specturm index. - * - * This method uses the analysis data service to retrieve the workspace. - * - * @param workspace :: The name of the workspace - * @param index :: The spectrum index of the workspace - */ - void IndirectBayesTab::plotMiniPlot(const QString& workspace, size_t index) - { - auto ws = Mantid::API::AnalysisDataService::Instance().retrieveWS(workspace.toStdString()); - plotMiniPlot(ws, index); - } - - /** - * Plot a workspace to the miniplot given a workspace pointer and - * a specturm index. - * - * @param workspace :: Pointer to the workspace - * @param wsIndex :: The spectrum index of the workspace - */ - void IndirectBayesTab::plotMiniPlot(const Mantid::API::MatrixWorkspace_const_sptr & workspace, size_t wsIndex) - { - using Mantid::MantidVec; - - //check if we can plot - if( wsIndex >= workspace->getNumberHistograms() || workspace->readX(0).size() < 2 ) - { - return; - } - - QwtWorkspaceSpectrumData wsData(*workspace, static_cast(wsIndex), false); - - if ( m_curve != NULL ) - { - m_curve->attach(0); - delete m_curve; - m_curve = NULL; - } - - size_t nhist = workspace->getNumberHistograms(); - if ( wsIndex >= nhist ) - { - emit showMessageBox("Error: Workspace index out of range."); - } - else - { - m_curve = new QwtPlotCurve(); - m_curve->setData(wsData); - m_curve->attach(m_plot); - - m_plot->replot(); - } - } - /** * Checks the workspace's intrument for a resolution parameter to use as * a default for the energy range on the mini plot @@ -155,52 +90,6 @@ namespace MantidQt return false; } - /** - * Gets the range of the curve plotted in the mini plot - * - * @return A pair containing the maximum and minimum points of the curve - */ - std::pair IndirectBayesTab::getCurveRange() - { - size_t npts = m_curve->data().size(); - - if( npts < 2 ) - throw std::invalid_argument("Too few points on data curve to determine range."); - - return std::make_pair(m_curve->data().x(0), m_curve->data().x(npts-1)); - } - - /** - * Sets the edge bounds of plot to prevent the user inputting invalid values - * - * @param min :: The lower bound property in the property browser - * @param max :: The upper bound property in the property browser - * @param bounds :: The upper and lower bounds to be set - */ - void IndirectBayesTab::setPlotRange(QtProperty* min, QtProperty* max, const std::pair& bounds) - { - m_dblManager->setMinimum(min, bounds.first); - m_dblManager->setMaximum(min, bounds.second); - m_dblManager->setMinimum(max, bounds.first); - m_dblManager->setMaximum(max, bounds.second); - m_rangeSelector->setRange(bounds.first, bounds.second); - } - - /** - * Set the position of the guides on the mini plot - * - * @param lower :: The lower bound property in the property browser - * @param upper :: The upper bound property in the property browser - * @param bounds :: The upper and lower bounds to be set - */ - void IndirectBayesTab::setMiniPlotGuides(QtProperty* lower, QtProperty* upper, const std::pair& bounds) - { - m_dblManager->setValue(lower, bounds.first); - m_dblManager->setValue(upper, bounds.second); - m_rangeSelector->setMinimum(bounds.first); - m_rangeSelector->setMaximum(bounds.second); - } - /** * Set the position of the lower guide on the mini plot * @@ -217,7 +106,7 @@ namespace MantidQt } else { - m_rangeSelector->setMinimum(value); + m_rangeSelectors["BayesRS"]->setMinimum(value); } } @@ -237,7 +126,7 @@ namespace MantidQt } else { - m_rangeSelector->setMaximum(value); + m_rangeSelectors["BayesRS"]->setMaximum(value); } } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp index e976c9094652..04886e6c4a14 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp @@ -58,7 +58,7 @@ namespace CustomInterfaces setup(); } - void IndirectTab::validateTab() + bool IndirectTab::validateTab() { validate(); } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp index d6492b4c0293..c1f9d4544d53 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp @@ -15,9 +15,19 @@ namespace MantidQt { m_uiForm.setupUi(parent); - //add the plot to the ui form - m_uiForm.plotSpace->addWidget(m_plot); - //add the properties browser to the ui form + // Create the plot + m_plots["JumpFitPlot"] = new QwtPlot(m_parentWidget); + m_plots["JumpFitPlot"]->setCanvasBackground(Qt::white); + m_plots["JumpFitPlot"]->setAxisFont(QwtPlot::xBottom, parent->font()); + m_plots["JumpFitPlot"]->setAxisFont(QwtPlot::yLeft, parent->font()); + m_uiForm.plotSpace->addWidget(m_plots["JumpFitPlot"]); + + // Create range selector + m_rangeSelectors["JumpFitQ"] = new MantidWidgets::RangeSelector(m_plots["JumpFitPlot"]); + connect(m_rangeSelectors["JumpFitQ"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(m_rangeSelectors["JumpFitQ"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + + // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); m_properties["QMin"] = m_dblManager->addProperty("QMin"); @@ -37,6 +47,10 @@ namespace MantidQt connect(m_uiForm.cbWidth, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(handleWidthChange(const QString&))); } + void JumpFit::setup() + { + } + /** * Validate the form to check the program can be run * @@ -145,21 +159,21 @@ namespace MantidQt m_uiForm.cbWidth->setEnabled(true); std::string currentWidth = m_uiForm.cbWidth->currentText().toStdString(); - plotMiniPlot(filename, spectraList[currentWidth]); + plotMiniPlot(filename, spectraList[currentWidth], "JumpFitPlot", "RawPlotCurve"); std::pair res; - std::pair range = getCurveRange(); + std::pair range = getCurveRange("JumpFitPlot"); //Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) { - setMiniPlotGuides(m_properties["QMin"], m_properties["QMax"], res); + setMiniPlotGuides("JumpFitQ", m_properties["QMin"], m_properties["QMax"], res); } else { - setMiniPlotGuides(m_properties["QMin"], m_properties["QMax"], range); + setMiniPlotGuides("JumpFitQ", m_properties["QMin"], m_properties["QMax"], range); } - setPlotRange(m_properties["QMin"], m_properties["QMax"], range); + setPlotRange("JumpFitQ", m_properties["QMin"], m_properties["QMax"], range); } else { @@ -232,7 +246,7 @@ namespace MantidQt { if(validate()) { - plotMiniPlot(sampleName, spectraList[text.toStdString()]); + plotMiniPlot(sampleName, spectraList[text.toStdString()], "JumpFitPlot", "RawPlotCurve"); } } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp index f8384fb0cec5..6bdfb0d0aeb9 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp @@ -10,10 +10,19 @@ namespace MantidQt { m_uiForm.setupUi(parent); - //add the plot to the ui form - m_uiForm.plotSpace->addWidget(m_plot); - - //add the properties browser to the ui form + // Create the plot + m_plots["QuasiPlot"] = new QwtPlot(m_parentWidget); + m_plots["QuasiPlot"]->setCanvasBackground(Qt::white); + m_plots["QuasiPlot"]->setAxisFont(QwtPlot::xBottom, parent->font()); + m_plots["QuasiPlot"]->setAxisFont(QwtPlot::yLeft, parent->font()); + m_uiForm.plotSpace->addWidget(m_plots["QuasiPlot"]); + + // Create range selector + m_rangeSelectors["QuasiERange"] = new MantidWidgets::RangeSelector(m_plots["QuasiPlot"]); + connect(m_rangeSelectors["QuasiERange"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(m_rangeSelectors["QuasiERange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + + // Add the properties browser to the UI form m_uiForm.treeSpace->addWidget(m_propTree); m_properties["EMin"] = m_dblManager->addProperty("EMin"); @@ -61,6 +70,10 @@ namespace MantidQt m_uiForm.mwFixWidthDat->readSettings(settings.group()); } + void Quasi::setup() + { + } + /** * Validate the form to check the program can be run * @@ -180,10 +193,10 @@ namespace MantidQt */ void Quasi::handleSampleInputReady(const QString& filename) { - plotMiniPlot(filename, 0); - std::pair range = getCurveRange(); - setMiniPlotGuides(m_properties["EMin"], m_properties["EMax"], range); - setPlotRange(m_properties["EMin"], m_properties["EMax"], range); + plotMiniPlot(filename, 0, "QuasiPlot", "RawPlotCurve"); + std::pair range = getCurveRange("QuasiPlot"); + setMiniPlotGuides("QuasiERange", m_properties["EMin"], m_properties["EMax"], range); + setPlotRange("QuasiERange", m_properties["EMin"], m_properties["EMax"], range); } /** diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp index 5ab1d38bd4f2..f86eb5bad8d4 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp @@ -10,10 +10,21 @@ namespace MantidQt { m_uiForm.setupUi(parent); - //add the plot to the ui form - m_uiForm.plotSpace->addWidget(m_plot); - //add the properties browser to the ui form + // Create the plot + m_plots["ResNormPlot"] = new QwtPlot(m_parentWidget); + m_plots["ResNormPlot"]->setCanvasBackground(Qt::white); + m_plots["ResNormPlot"]->setAxisFont(QwtPlot::xBottom, parent->font()); + m_plots["ResNormPlot"]->setAxisFont(QwtPlot::yLeft, parent->font()); + m_uiForm.plotSpace->addWidget(m_plots["ResNormPlot"]); + + // Create range selector + m_rangeSelectors["ResNormERange"] = new MantidWidgets::RangeSelector(m_plots["ResNormPlot"]); + connect(m_rangeSelectors["ResNormERange"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(m_rangeSelectors["ResNormERange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + + // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); + m_properties["EMin"] = m_dblManager->addProperty("EMin"); m_properties["EMax"] = m_dblManager->addProperty("EMax"); m_properties["VanBinning"] = m_dblManager->addProperty("Van Binning"); @@ -34,6 +45,10 @@ namespace MantidQt connect(m_uiForm.dsVanadium, SIGNAL(dataReady(const QString&)), this, SLOT(handleVanadiumInputReady(const QString&))); } + void ResNorm::setup() + { + } + /** * Validate the form to check the program can be run * @@ -110,9 +125,9 @@ namespace MantidQt */ void ResNorm::handleVanadiumInputReady(const QString& filename) { - plotMiniPlot(filename, 0); + plotMiniPlot(filename, 0, "ResNormPlot", "RawPlotCurve"); std::pair res; - std::pair range = getCurveRange(); + std::pair range = getCurveRange("ResNormPlot"); //Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) @@ -121,14 +136,14 @@ namespace MantidQt res.first = res.first * 10; res.second = res.second * 10; - setMiniPlotGuides(m_properties["EMin"], m_properties["EMax"], res); + setMiniPlotGuides("ResNormERange", m_properties["EMin"], m_properties["EMax"], res); } else { - setMiniPlotGuides(m_properties["EMin"], m_properties["EMax"], range); + setMiniPlotGuides("ResNormERange", m_properties["EMin"], m_properties["EMax"], range); } - setPlotRange(m_properties["EMin"], m_properties["EMax"], range); + setPlotRange("ResNormERange", m_properties["EMin"], m_properties["EMax"], range); } /** diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp index e75822650e92..b6784bb29f9e 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp @@ -10,9 +10,19 @@ namespace MantidQt { m_uiForm.setupUi(parent); - //add the plot to the ui form - m_uiForm.plotSpace->addWidget(m_plot); - //add the properties browser to the ui form + // Create the plot + m_plots["StretchPlot"] = new QwtPlot(m_parentWidget); + m_plots["StretchPlot"]->setCanvasBackground(Qt::white); + m_plots["StretchPlot"]->setAxisFont(QwtPlot::xBottom, parent->font()); + m_plots["StretchPlot"]->setAxisFont(QwtPlot::yLeft, parent->font()); + m_uiForm.plotSpace->addWidget(m_plots["StretchPlot"]); + + // Create range selector + m_rangeSelectors["StretchERange"] = new MantidWidgets::RangeSelector(m_plots["StretchPlot"]); + connect(m_rangeSelectors["StretchERange"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(m_rangeSelectors["StretchERange"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + + // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); m_properties["EMin"] = m_dblManager->addProperty("EMin"); @@ -48,6 +58,10 @@ namespace MantidQt connect(m_uiForm.chkSequentialFit, SIGNAL(toggled(bool)), m_uiForm.cbPlot, SLOT(setEnabled(bool))); } + void Stretch::setup() + { + } + /** * Validate the form to check the program can be run * @@ -138,10 +152,10 @@ namespace MantidQt */ void Stretch::handleSampleInputReady(const QString& filename) { - plotMiniPlot(filename, 0); - std::pair range = getCurveRange(); - setMiniPlotGuides(m_properties["EMin"], m_properties["EMax"], range); - setPlotRange(m_properties["EMin"], m_properties["EMax"], range); + plotMiniPlot(filename, 0, "StretchPlot", "RawPlotCurve"); + std::pair range = getCurveRange("StretchPlot"); + setMiniPlotGuides("StretchERange", m_properties["EMin"], m_properties["EMax"], range); + setPlotRange("StretchERange", m_properties["EMin"], m_properties["EMax"], range); } /** From 9c5a6a9819c1ee44a743b1f52f2cee62f07700fb Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 8 Oct 2014 11:31:46 +0100 Subject: [PATCH 04/15] Indirect Bayes working once again Refs #10277 --- .../IndirectBayesTab.h | 10 +++--- .../IndirectDataReductionTab.h | 4 ++- .../CustomInterfaces/src/IndirectBayesTab.cpp | 35 +++++++++---------- .../MantidQt/CustomInterfaces/src/JumpFit.cpp | 6 ++-- .../MantidQt/CustomInterfaces/src/Quasi.cpp | 6 ++-- .../MantidQt/CustomInterfaces/src/ResNorm.cpp | 6 ++-- .../MantidQt/CustomInterfaces/src/Stretch.cpp | 6 ++-- 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h index 00cc6d7b66ff..6d8d614baffe 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectBayesTab.h @@ -43,7 +43,7 @@ namespace MantidQt This class defines a abstract base class for the different tabs of the Indirect Bayes interface. Any joint functionality shared between each of the tabs should be implemented here as well as defining shared member functions. - + @author Samuel Jackson, STFC Copyright © 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory @@ -83,7 +83,7 @@ namespace MantidQt /// Returns a URL for the wiki help page for this interface QString tabHelpURL(); - /// Base methods implemented in derived classes + /// Base methods implemented in derived classes virtual QString help() = 0; virtual void loadSettings(const QSettings& settings) = 0; @@ -95,7 +95,7 @@ namespace MantidQt protected slots: /// Slot to update the guides when the range properties change - void updateProperties(QtProperty* prop, double val); + virtual void updateProperties(QtProperty* prop, double val) = 0; protected: /// Function to run a string as python code @@ -105,9 +105,9 @@ namespace MantidQt /// Function to read an instrument's resolution from the IPF using a workspace pointer bool getInstrumentResolution(Mantid::API::MatrixWorkspace_const_sptr ws, std::pair& res); /// Function to set the position of the lower guide on the plot - void updateLowerGuide(QtProperty* lower, QtProperty* upper, double value); + void updateLowerGuide(MantidQt::MantidWidgets::RangeSelector* rs, QtProperty* lower, QtProperty* upper, double value); /// Function to set the position of the upper guide on the plot - void updateUpperGuide(QtProperty* lower, QtProperty* upper, double value); + void updateUpperGuide(MantidQt::MantidWidgets::RangeSelector* rs, QtProperty* lower, QtProperty* upper, double value); /// Tree of the properties QtTreePropertyBrowser* m_propTree; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h index 80533e1201db..8d7dcf61945e 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h @@ -42,7 +42,9 @@ namespace MantidQt { namespace CustomInterfaces { - /** IndirectDataReductionTab : TODO: DESCRIPTION + /** IndirectDataReductionTab + + This class defines common functionality of tabs used in the Indirect Data Reduction interface. @author Samuel Jackson @date 13/08/2013 diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp index d3f43bcae84e..0e3a0cbdfe8f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectBayesTab.cpp @@ -4,6 +4,8 @@ #include "MantidQtAPI/UserSubWindow.h" #include "MantidQtCustomInterfaces/IndirectBayesTab.h" +using MantidQt::MantidWidgets::RangeSelector; + namespace MantidQt { namespace CustomInterfaces @@ -30,18 +32,18 @@ namespace MantidQt /** * Method to build a URL to the appropriate page on the wiki for this tab. - * + * * @return The URL to the wiki page */ QString IndirectBayesTab::tabHelpURL() - { + { return "http://www.mantidproject.org/IndirectBayes:" + help(); } /** * Emits a signal to run a python script using the method in the parent * UserSubWindow - * + * * @param pyInput :: A string of python code to execute */ void IndirectBayesTab::runPythonScript(const QString& pyInput) @@ -50,7 +52,7 @@ namespace MantidQt } /** - * Checks the workspace's intrument for a resolution parameter to use as + * Checks the workspace's intrument for a resolution parameter to use as * a default for the energy range on the mini plot * * @param workspace :: Name of the workspace to use @@ -63,7 +65,7 @@ namespace MantidQt } /** - * Checks the workspace's intrument for a resolution parameter to use as + * Checks the workspace's intrument for a resolution parameter to use as * a default for the energy range on the mini plot * * @param ws :: Pointer to the workspace to use @@ -92,42 +94,37 @@ namespace MantidQt /** * Set the position of the lower guide on the mini plot - * + * + * @param rs :: Range selector to update * @param lower :: The lower guide property in the property browser * @param upper :: The upper guide property in the property browser * @param value :: The value of the lower guide */ - void IndirectBayesTab::updateLowerGuide(QtProperty* lower, QtProperty* upper, double value) + void IndirectBayesTab::updateLowerGuide(RangeSelector* rs, QtProperty* lower, QtProperty* upper, double value) { // Check if the user is setting the max less than the min if(value > m_dblManager->value(upper)) - { m_dblManager->setValue(lower, m_dblManager->value(upper)); - } else - { - m_rangeSelectors["BayesRS"]->setMinimum(value); - } + rs->setMinimum(value); } /** * Set the position of the upper guide on the mini plot - * + * + * @param rs :: Range selector to update * @param lower :: The lower guide property in the property browser * @param upper :: The upper guide property in the property browser * @param value :: The value of the upper guide */ - void IndirectBayesTab::updateUpperGuide(QtProperty* lower, QtProperty* upper, double value) + void IndirectBayesTab::updateUpperGuide(RangeSelector* rs, QtProperty* lower, QtProperty* upper, double value) { // Check if the user is setting the min greater than the max if(value < m_dblManager->value(lower)) - { m_dblManager->setValue(upper, m_dblManager->value(lower)); - } else - { - m_rangeSelectors["BayesRS"]->setMaximum(value); - } + rs->setMaximum(value); } + } } // namespace MantidQt diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp index c1f9d4544d53..fb98fcac13a1 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp @@ -161,7 +161,7 @@ namespace MantidQt std::string currentWidth = m_uiForm.cbWidth->currentText().toStdString(); plotMiniPlot(filename, spectraList[currentWidth], "JumpFitPlot", "RawPlotCurve"); std::pair res; - std::pair range = getCurveRange("JumpFitPlot"); + std::pair range = getCurveRange("RawPlotCurve"); //Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) @@ -281,11 +281,11 @@ namespace MantidQt { if(prop == m_properties["QMin"]) { - updateLowerGuide(m_properties["QMin"], m_properties["QMax"], val); + updateLowerGuide(m_rangeSelectors["JumpFitQ"], m_properties["QMin"], m_properties["QMax"], val); } else if (prop == m_properties["QMax"]) { - updateUpperGuide(m_properties["QMin"], m_properties["QMax"], val); + updateUpperGuide(m_rangeSelectors["JumpFitQ"], m_properties["QMin"], m_properties["QMax"], val); } } } // namespace CustomInterfaces diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp index 6bdfb0d0aeb9..31b2c792f0ea 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp @@ -194,7 +194,7 @@ namespace MantidQt void Quasi::handleSampleInputReady(const QString& filename) { plotMiniPlot(filename, 0, "QuasiPlot", "RawPlotCurve"); - std::pair range = getCurveRange("QuasiPlot"); + std::pair range = getCurveRange("RawPlotCurve"); setMiniPlotGuides("QuasiERange", m_properties["EMin"], m_properties["EMax"], range); setPlotRange("QuasiERange", m_properties["EMin"], m_properties["EMax"], range); } @@ -229,11 +229,11 @@ namespace MantidQt { if(prop == m_properties["EMin"]) { - updateLowerGuide(m_properties["EMin"], m_properties["EMax"], val); + updateLowerGuide(m_rangeSelectors["QuasiERange"], m_properties["EMin"], m_properties["EMax"], val); } else if (prop == m_properties["EMax"]) { - updateUpperGuide(m_properties["EMin"], m_properties["EMax"], val); + updateUpperGuide(m_rangeSelectors["QuasiERange"], m_properties["EMin"], m_properties["EMax"], val); } } diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp index f86eb5bad8d4..7665cb062e51 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp @@ -127,7 +127,7 @@ namespace MantidQt { plotMiniPlot(filename, 0, "ResNormPlot", "RawPlotCurve"); std::pair res; - std::pair range = getCurveRange("ResNormPlot"); + std::pair range = getCurveRange("RawPlotCurve"); //Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) @@ -176,11 +176,11 @@ namespace MantidQt { if(prop == m_properties["EMin"]) { - updateLowerGuide(m_properties["EMin"], m_properties["EMax"], val); + updateLowerGuide(m_rangeSelectors["ResNormERange"], m_properties["EMin"], m_properties["EMax"], val); } else if (prop == m_properties["EMax"]) { - updateUpperGuide(m_properties["EMin"], m_properties["EMax"], val); + updateUpperGuide(m_rangeSelectors["ResNormERange"], m_properties["EMin"], m_properties["EMax"], val); } } } // namespace CustomInterfaces diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp index b6784bb29f9e..bf2190d813de 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp @@ -153,7 +153,7 @@ namespace MantidQt void Stretch::handleSampleInputReady(const QString& filename) { plotMiniPlot(filename, 0, "StretchPlot", "RawPlotCurve"); - std::pair range = getCurveRange("StretchPlot"); + std::pair range = getCurveRange("RawPlotCurve"); setMiniPlotGuides("StretchERange", m_properties["EMin"], m_properties["EMax"], range); setPlotRange("StretchERange", m_properties["EMin"], m_properties["EMax"], range); } @@ -188,11 +188,11 @@ namespace MantidQt { if(prop == m_properties["EMin"]) { - updateLowerGuide(m_properties["EMin"], m_properties["EMax"], val); + updateLowerGuide(m_rangeSelectors["StretchERange"], m_properties["EMin"], m_properties["EMax"], val); } else if (prop == m_properties["EMax"]) { - updateUpperGuide(m_properties["EMin"], m_properties["EMax"], val); + updateUpperGuide(m_rangeSelectors["StretchERange"], m_properties["EMin"], m_properties["EMax"], val); } } From 3af232b389fd912bbb3be9b4e5bc8537df7d4f22 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Thu, 9 Oct 2014 10:26:57 +0100 Subject: [PATCH 05/15] Added plotting to Quasi and Stretch Refs #10277 --- .../CustomInterfaces/src/IndirectTab.cpp | 2 +- .../MantidQt/CustomInterfaces/src/Quasi.cpp | 27 +++++++++++++++++++ .../MantidQt/CustomInterfaces/src/Stretch.cpp | 22 +++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp index 04886e6c4a14..037feb9d98df 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectTab.cpp @@ -60,7 +60,7 @@ namespace CustomInterfaces bool IndirectTab::validateTab() { - validate(); + return validate(); } /** diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp index 31b2c792f0ea..3d0efe63cc0b 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp @@ -1,3 +1,4 @@ +#include "MantidAPI/TextAxis.h" #include "MantidQtCustomInterfaces/Quasi.h" #include "MantidQtCustomInterfaces/UserInputValidator.h" @@ -114,6 +115,8 @@ namespace MantidQt */ void Quasi::run() { + using namespace Mantid::API; + // Using 1/0 instead of True/False for compatibility with underlying Fortran code // in some places QString verbose("False"); @@ -183,6 +186,30 @@ namespace MantidQt " Save="+save+", Plot='"+plot+"', Verbose="+verbose+")\n"; runPythonScript(pyInput); + + //Update mini plot + QString outWsName = sampleName.left(sampleName.size() - 3) + "QLr_Workspace_0"; + MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS(outWsName.toStdString()); + TextAxis* axis = dynamic_cast(outputWorkspace->getAxis(1)); + + for(int histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++) + { + QString specName = QString::fromStdString(axis->label(histIndex)); + + if(specName.contains("fit")) + { + plotMiniPlot(outputWorkspace, histIndex, "QuasiPlot", specName); + m_curves[specName]->setPen(QColor(Qt::red)); + } + + if(specName.contains("diff")) + { + plotMiniPlot(outputWorkspace, histIndex, "QuasiPlot", specName); + m_curves[specName]->setPen(QColor(Qt::green)); + } + } + + replot("QuasiPlot"); } /** diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp index bf2190d813de..98ac5d309a75 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp @@ -1,6 +1,11 @@ #include "MantidQtCustomInterfaces/Stretch.h" #include "MantidQtCustomInterfaces/UserInputValidator.h" +namespace +{ + Mantid::Kernel::Logger g_log("Stretch"); +} + namespace MantidQt { namespace CustomInterfaces @@ -89,6 +94,8 @@ namespace MantidQt */ void Stretch::run() { + using namespace Mantid::API; + QString save("False"); QString verbose("False"); @@ -130,6 +137,21 @@ namespace MantidQt " Save="+save+", Plot='"+plot+"', Verbose="+verbose+")\n"; runPythonScript(pyInput); + + //Update mini plot + QString sigmaWsName = sampleName.left(sampleName.size() - 3) + "Qst_Sigma"; + QString betaWsName = sampleName.left(sampleName.size() - 3) + "Qst_Beta"; + + MatrixWorkspace_sptr sigmaWs = AnalysisDataService::Instance().retrieveWS(sigmaWsName.toStdString()); + MatrixWorkspace_sptr betaWs = AnalysisDataService::Instance().retrieveWS(betaWsName.toStdString()); + + plotMiniPlot(sigmaWs, 0, "StretchPlot", "SigmaCurve"); + plotMiniPlot(betaWs, 0, "StretchPlot", "BetaCurve"); + + m_curves["SigmaCurve"]->setPen(QColor(Qt::red)); + m_curves["BetaCurve"]->setPen(QColor(Qt::green)); + + replot("StretchPlot"); } /** From bf9252c9496724f19940b29d691f7ab3e6978561 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 15 Oct 2014 09:15:49 +0100 Subject: [PATCH 06/15] Added preview plotting to JumpFit Refs #10277 --- .../inc/MantidQtCustomInterfaces/JumpFit.h | 4 ++ .../MantidQt/CustomInterfaces/src/JumpFit.cpp | 44 +++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h index e1d33a2ccd88..4ee683ab9c9f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h @@ -36,6 +36,8 @@ namespace MantidQt void updateProperties(QtProperty* prop, double val); /// Find all spectra with width data in the workspace void findAllWidths(Mantid::API::MatrixWorkspace_const_sptr ws); + /// Handles plotting results of algorithm on miniplot + void fitAlgDone(bool error); private: // The UI form @@ -44,6 +46,8 @@ namespace MantidQt // Map of axis labels to spectrum number std::map m_spectraList; + Mantid::API::IAlgorithm_sptr fitAlg; + }; } // namespace CustomInterfaces } // namespace MantidQt diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp index fc3c5bc39689..515f39600f08 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp @@ -7,6 +7,8 @@ #include #include +using namespace Mantid::API; + namespace MantidQt { namespace CustomInterfaces @@ -46,6 +48,9 @@ namespace MantidQt connect(m_uiForm.dsSample, SIGNAL(dataReady(const QString&)), this, SLOT(handleSampleInputReady(const QString&))); // Connect width selector to handler method connect(m_uiForm.cbWidth, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(handleWidthChange(const QString&))); + + // Connect algorithm runner to completion handler function + connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(fitAlgDone(bool))); } void JumpFit::setup() @@ -84,8 +89,6 @@ namespace MantidQt */ void JumpFit::run() { - using namespace Mantid::API; - // Fit function to use QString fitFunction("ChudleyElliot"); switch(m_uiForm.cbFunction->currentIndex()) @@ -111,7 +114,7 @@ namespace MantidQt std::string widthText = m_uiForm.cbWidth->currentText().toStdString(); long width = m_spectraList[widthText]; - IAlgorithm_sptr fitAlg = AlgorithmManager::Instance().create("JumpFit"); + fitAlg = AlgorithmManager::Instance().create("JumpFit"); fitAlg->initialize(); fitAlg->setProperty("InputWorkspace", ws); @@ -131,6 +134,41 @@ namespace MantidQt runAlgorithm(fitAlg); } + /** + * Handles the JumpFit algorithm finishing, used to plot fit in miniplot. + * + * @param error True if the algorithm failed, false otherwise + */ + void JumpFit::fitAlgDone(bool error) + { + // Ignore errors + if(error) + return; + + std::string outWsName = fitAlg->getPropertyValue("Output") + "_Workspace"; + MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS(outWsName); + TextAxis* axis = dynamic_cast(outputWorkspace->getAxis(1)); + + for(int histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++) + { + QString specName = QString::fromStdString(axis->label(histIndex)); + + if(specName == "Calc") + { + plotMiniPlot(outputWorkspace, histIndex, "JumpFitPlot", specName); + m_curves[specName]->setPen(QColor(Qt::red)); + } + + if(specName == "Diff") + { + plotMiniPlot(outputWorkspace, histIndex, "JumpFitPlot", specName); + m_curves[specName]->setPen(QColor(Qt::green)); + } + } + + replot("JumpFitPlot"); + } + /** * Set the data selectors to use the default save directory * when browsing for input files. From 77538e24924aaa486426588d3cc326af01db7847 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 15 Oct 2014 09:37:36 +0100 Subject: [PATCH 07/15] Added auto updating of JumpFit plot Refs #10277 --- .../inc/MantidQtCustomInterfaces/JumpFit.h | 9 +-- .../MantidQt/CustomInterfaces/src/JumpFit.cpp | 72 +++++++++++++------ 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h index 4ee683ab9c9f..fbde3aabb082 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.h @@ -20,6 +20,7 @@ namespace MantidQt void setup(); bool validate(); void run(); + void runImpl(bool verbose = false, bool plot = false, bool save = false); /// Load default settings into the interface void loadSettings(const QSettings& settings); @@ -28,16 +29,16 @@ namespace MantidQt void handleSampleInputReady(const QString& filename); /// Slot to handle plotting a different spectrum of the workspace void handleWidthChange(const QString& text); - /// Slot for when the min range on the range selector changes - void minValueChanged(double min); - /// Slot for when the min range on the range selector changes - void maxValueChanged(double max); + /// Slot for when the range on the range selector changes + void qRangeChanged(double min, double max); /// Slot to update the guides when the range properties change void updateProperties(QtProperty* prop, double val); /// Find all spectra with width data in the workspace void findAllWidths(Mantid::API::MatrixWorkspace_const_sptr ws); /// Handles plotting results of algorithm on miniplot void fitAlgDone(bool error); + /// Handles running preview algorithm + void runPreviewAlgorithm(); private: // The UI form diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp index 515f39600f08..0f187bf1e5c7 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp @@ -27,8 +27,7 @@ namespace MantidQt // Create range selector m_rangeSelectors["JumpFitQ"] = new MantidWidgets::RangeSelector(m_plots["JumpFitPlot"]); - connect(m_rangeSelectors["JumpFitQ"], SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); - connect(m_rangeSelectors["JumpFitQ"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); + connect(m_rangeSelectors["JumpFitQ"], SIGNAL(selectionChangedLazy(double, double)), this, SLOT(qRangeChanged(double, double))); // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); @@ -89,6 +88,34 @@ namespace MantidQt */ void JumpFit::run() { + bool verbose = m_uiForm.chkVerbose->isChecked(); + bool save = m_uiForm.chkSave->isChecked(); + bool plot = m_uiForm.chkPlot->isChecked(); + + runImpl(verbose, plot, save); + } + + /** + * Runs the JumpFit algorithm with preview parameters to update the preview plot. + */ + void JumpFit::runPreviewAlgorithm() + { + runImpl(); + } + + /** + * Runs algorithm. + * + * @param verbose Enable/disable verbose option + * @param plot Enable/disable plotting + * @param save Enable/disable saving + */ + void JumpFit::runImpl(bool verbose, bool plot, bool save) + { + // Do noting with invalid data + if(!m_uiForm.dsSample->isValid()) + return; + // Fit function to use QString fitFunction("ChudleyElliot"); switch(m_uiForm.cbFunction->currentIndex()) @@ -124,15 +151,13 @@ namespace MantidQt fitAlg->setProperty("QMin", m_dblManager->value(m_properties["QMin"])); fitAlg->setProperty("QMax", m_dblManager->value(m_properties["QMax"])); - bool verbose = m_uiForm.chkVerbose->isChecked(); - bool save = m_uiForm.chkSave->isChecked(); - bool plot = m_uiForm.chkPlot->isChecked(); - fitAlg->setProperty("Plot", plot); fitAlg->setProperty("Verbose", verbose); + fitAlg->setProperty("Plot", plot); fitAlg->setProperty("Save", save); - runAlgorithm(fitAlg); - } + if(m_batchAlgoRunner->queueLength() < 1) + runAlgorithm(fitAlg); + } /** * Handles the JumpFit algorithm finishing, used to plot fit in miniplot. @@ -149,7 +174,7 @@ namespace MantidQt MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS(outWsName); TextAxis* axis = dynamic_cast(outputWorkspace->getAxis(1)); - for(int histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++) + for(unsigned int histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++) { QString specName = QString::fromStdString(axis->label(histIndex)); @@ -188,6 +213,11 @@ namespace MantidQt */ void JumpFit::handleSampleInputReady(const QString& filename) { + // Disable things that run the preview algorithm + disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(runPreviewAlgorithm())); + disconnect(m_uiForm.cbFunction, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(runPreviewAlgorithm())); + disconnect(m_uiForm.cbWidth, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(runPreviewAlgorithm())); + auto ws = Mantid::API::AnalysisDataService::Instance().retrieve(filename.toStdString()); auto mws = boost::dynamic_pointer_cast(ws); @@ -219,6 +249,14 @@ namespace MantidQt m_uiForm.cbWidth->setEnabled(false); emit showMessageBox("Workspace doesn't appear to contain any width data"); } + + // Update preview plot + runPreviewAlgorithm(); + + // Re-enable things that run the preview algorithm + connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(runPreviewAlgorithm())); + connect(m_uiForm.cbFunction, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(runPreviewAlgorithm())); + connect(m_uiForm.cbWidth, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(runPreviewAlgorithm())); } /** @@ -291,23 +329,15 @@ namespace MantidQt } /** - * Updates the property manager when the lower guide is moved on the mini plot + * Updates the property manager when the range selector is moved on the mini plot. * * @param min :: The new value of the lower guide - */ - void JumpFit::minValueChanged(double min) - { - m_dblManager->setValue(m_properties["QMin"], min); - } - - /** - * Updates the property manager when the upper guide is moved on the mini plot - * * @param max :: The new value of the upper guide */ - void JumpFit::maxValueChanged(double max) + void JumpFit::qRangeChanged(double min, double max) { - m_dblManager->setValue(m_properties["QMax"], max); + m_dblManager->setValue(m_properties["QMin"], min); + m_dblManager->setValue(m_properties["QMax"], max); } /** From fa72b4778efd9a85193173b54b1a58b6ae6fdc9c Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Mon, 3 Nov 2014 10:16:46 +0000 Subject: [PATCH 08/15] Correct error in merge Refs #10277 --- .../IndirectDataReductionTab.h | 2 + .../src/IndirectDataReductionTab.cpp | 108 ++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h index 8d7dcf61945e..3e9c62a69ea6 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h @@ -84,6 +84,8 @@ namespace CustomInterfaces /// Function to get details about the instrument configuration defined on C2E tab std::map getInstrumentDetails(); + std::map getRangesFromInstrument(QString instName = "", QString analyser = "", QString reflection = ""); + protected: Ui::IndirectDataReduction m_uiForm; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp index 7473b4e80836..f80f6f62971d 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp @@ -172,5 +172,113 @@ namespace CustomInterfaces return instDetails; } + /** + * Gets default peak and background ranges for an instrument in time of flight. + * + * @param instName Name of instrument + * @param analyser Analyser component + * @param reflection Reflection used + * + * @returns A map of range ID to value + */ + std::map IndirectDataReductionTab::getRangesFromInstrument( + QString instName, QString analyser, QString reflection) + { + // Get any unset parameters + if(instName.isEmpty()) + instName = m_uiForm.cbInst->currentText(); + if(analyser.isEmpty()) + analyser = m_uiForm.cbAnalyser->currentText(); + if(reflection.isEmpty()) + reflection = m_uiForm.cbReflection->currentText(); + + std::map ranges; + + // Get the instrument + auto instWs = loadInstrumentIfNotExist(instName.toStdString(), analyser.toStdString(), reflection.toStdString()); + auto inst = instWs->getInstrument(); + + // Get the analyser component + auto comp = inst->getComponentByName(analyser.toStdString()); + if(!comp) + return ranges; + + // Get the resolution of the analyser + auto resParams = comp->getNumberParameter("resolution", true); + if(resParams.size() < 1) + return ranges; + double resolution = resParams[0]; + + std::vector x; + x.push_back(-6 * resolution); + x.push_back(-5 * resolution); + x.push_back(-2 * resolution); + x.push_back(0); + x.push_back(2 * resolution); + std::vector y; + y.push_back(1); + y.push_back(2); + y.push_back(3); + y.push_back(4); + std::vector e(4, 0); + + IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("CreateWorkspace"); + createWsAlg->initialize(); + createWsAlg->setProperty("OutputWorkspace", "__energy"); + createWsAlg->setProperty("DataX", x); + createWsAlg->setProperty("DataY", y); + createWsAlg->setProperty("DataE", e); + createWsAlg->setProperty("Nspec", 1); + createWsAlg->setProperty("UnitX", "DeltaE"); + createWsAlg->execute(); + + IAlgorithm_sptr convertHistAlg = AlgorithmManager::Instance().create("ConvertToHistogram"); + convertHistAlg->initialize(); + convertHistAlg->setProperty("InputWorkspace", "__energy"); + convertHistAlg->setProperty("OutputWorkspace", "__energy"); + convertHistAlg->execute(); + + IAlgorithm_sptr loadInstAlg = AlgorithmManager::Instance().create("LoadInstrument"); + loadInstAlg->initialize(); + loadInstAlg->setProperty("Workspace", "__energy"); + loadInstAlg->setProperty("InstrumentName", instName.toStdString()); + loadInstAlg->execute(); + + QString ipfFilename = instName + "_" + analyser + "_" + reflection + "_Parameters.xml"; + + IAlgorithm_sptr loadParamAlg = AlgorithmManager::Instance().create("LoadParameterFile"); + loadParamAlg->initialize(); + loadParamAlg->setProperty("Workspace", "__energy"); + loadParamAlg->setProperty("Filename", ipfFilename.toStdString()); + loadParamAlg->execute(); + + auto energyWs = AnalysisDataService::Instance().retrieveWS("__energy"); + double efixed = energyWs->getInstrument()->getNumberParameter("efixed-val")[0]; + + auto spectrum = energyWs->getSpectrum(0); + spectrum->setSpectrumNo(3); + spectrum->clearDetectorIDs(); + spectrum->addDetectorID(3); + + IAlgorithm_sptr convUnitsAlg = AlgorithmManager::Instance().create("ConvertUnits"); + convUnitsAlg->initialize(); + convUnitsAlg->setProperty("InputWorkspace", "__energy"); + convUnitsAlg->setProperty("OutputWorkspace", "__tof"); + convUnitsAlg->setProperty("Target", "TOF"); + convUnitsAlg->setProperty("EMode", "Indirect"); + convUnitsAlg->setProperty("EFixed", efixed); + convUnitsAlg->execute(); + + auto tofWs = AnalysisDataService::Instance().retrieveWS("__tof"); + + std::vector tofData = tofWs->readX(0); + ranges["peak-start-tof"] = tofData[0]; + ranges["peak-end-tof"] = tofData[2]; + ranges["back-start-tof"] = tofData[3]; + ranges["back-end-tof"] = tofData[4]; + + return ranges; + } + } // namespace CustomInterfaces } // namespace Mantid From 55e3fad6301c54d84a126582cb34260cb19b7f65 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Mon, 3 Nov 2014 11:39:40 +0000 Subject: [PATCH 09/15] Corrected merge errors and compiler warnings Refs #10277 --- .../IndirectDataReductionTab.h | 4 +++- .../inc/MantidQtCustomInterfaces/IndirectTab.h | 2 +- .../src/IndirectDataReductionTab.cpp | 15 +++++++++++++++ .../MantidQt/CustomInterfaces/src/Quasi.cpp | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h index b7aaae18964e..d6c2812eac1d 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectDataReductionTab.h @@ -89,13 +89,15 @@ namespace CustomInterfaces std::map getRangesFromInstrument(QString instName = "", QString analyser = "", QString reflection = ""); - protected: Ui::IndirectDataReduction m_uiForm; signals: /// Update the Run button on the IDR main window void updateRunButton(bool enabled = true, QString message = "Run", QString tooltip = ""); + private: + bool m_tabRunning; + private slots: void tabExecutionComplete(bool error); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h index a6481550d644..68ba60cde341 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h @@ -152,7 +152,7 @@ namespace CustomInterfaces /// Run a python script void runAsPythonScript(const QString & code, bool no_output); - private: + protected: /// Overidden by child class. virtual void setup() = 0; /// Overidden by child class. diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp index fbf1f38415b0..827ef8cea00a 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/IndirectDataReductionTab.cpp @@ -45,6 +45,21 @@ namespace CustomInterfaces } } + /** + * Slot used to update the run button when an algorithm that was strted by the Run button complete. + * + * @param error Unused + */ + void IndirectDataReductionTab::tabExecutionComplete(bool error) + { + UNUSED_ARG(error); + if(m_tabRunning) + { + m_tabRunning = false; + emit updateRunButton(); + } + } + /** * Loads an empty instrument into a workspace (__empty_INST) unless the workspace already exists. * diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp index 3d0efe63cc0b..f374a559681a 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp @@ -192,7 +192,7 @@ namespace MantidQt MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS(outWsName.toStdString()); TextAxis* axis = dynamic_cast(outputWorkspace->getAxis(1)); - for(int histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++) + for(size_t histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++) { QString specName = QString::fromStdString(axis->label(histIndex)); From 9a2f3a63911bf938480f0f8ac20fd1abeca00499 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 4 Nov 2014 15:00:04 +0000 Subject: [PATCH 10/15] Correct JumpFit naming, imporve JumpFit preview plot Refs #10277 --- .../algorithms/WorkflowAlgorithms/JumpFit.py | 4 +- .../inc/MantidQtCustomInterfaces/JumpFit.ui | 62 ++++++++++++++++++- .../MantidQt/CustomInterfaces/src/JumpFit.cpp | 14 +++-- 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py index eac83b7e2b43..a696515a9875 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py @@ -105,7 +105,7 @@ def PyExec(self): # Run fit function if self._out_name is "": - self._out_name = self._in_ws[:-10] + '_' + self._jump_function + 'fit' + self._out_name = self._in_ws[:-7] + '_' + self._jump_function + '_fit' Fit(Function=function, InputWorkspace=spectrum_ws, CreateOutput=True, Output=self._out_name, StartX=self._q_min, EndX=self._q_max) @@ -142,6 +142,7 @@ def _setup(self): self._plot = self.getProperty('Plot').value self._save = self.getProperty('Save').value + def _process_output(self, workspace): if self._save: from mantid.simpleapi import SaveNexusProcessed @@ -158,5 +159,6 @@ def _process_output(self, workspace): mtd_plot = import_mantidplot() mtd_plot.plotSpectrum(workspace, [0, 1, 2], True) + # Register algorithm with Mantid AlgorithmFactory.subscribe(JumpFit) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui index 7ba4749fa6f7..92bd9544a68f 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui @@ -24,7 +24,7 @@ - + 0 @@ -110,7 +110,65 @@ - + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + color: rgb(0, 255, 255); + + + Raw + + + + + + + Data + + + + + + + color: rgb(255, 0, 0); + + + Fit + + + + + + + color: rgb(0, 255, 0); + + + Diff + + + + + + diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp index 0f187bf1e5c7..12ad3a2780f0 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp @@ -178,6 +178,11 @@ namespace MantidQt { QString specName = QString::fromStdString(axis->label(histIndex)); + if(specName == "Data") + { + plotMiniPlot(outputWorkspace, histIndex, "JumpFitPlot", specName); + } + if(specName == "Calc") { plotMiniPlot(outputWorkspace, histIndex, "JumpFitPlot", specName); @@ -229,18 +234,16 @@ namespace MantidQt std::string currentWidth = m_uiForm.cbWidth->currentText().toStdString(); plotMiniPlot(filename, m_spectraList[currentWidth], "JumpFitPlot", "RawPlotCurve"); + m_curves["RawPlotCurve"]->setPen(QColor(Qt::cyan)); + std::pair res; std::pair range = getCurveRange("RawPlotCurve"); - //Use the values from the instrument parameter file if we can + // Use the values from the instrument parameter file if we can if(getInstrumentResolution(filename, res)) - { setMiniPlotGuides("JumpFitQ", m_properties["QMin"], m_properties["QMax"], res); - } else - { setMiniPlotGuides("JumpFitQ", m_properties["QMin"], m_properties["QMax"], range); - } setPlotRange("JumpFitQ", m_properties["QMin"], m_properties["QMax"], range); } @@ -324,6 +327,7 @@ namespace MantidQt if(validate()) { plotMiniPlot(sampleName, m_spectraList[text.toStdString()], "JumpFitPlot", "RawPlotCurve"); + m_curves["RawPlotCurve"]->setPen(QColor(Qt::cyan)); } } } From 8f37f36cbdcfa3782c6108b4c40961ecde4ed6c2 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 5 Nov 2014 08:54:20 +0000 Subject: [PATCH 11/15] Fix JumpFit output naming Refs #10277 --- .../plugins/algorithms/WorkflowAlgorithms/JumpFit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py index a696515a9875..0682dc76d34c 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py @@ -105,7 +105,8 @@ def PyExec(self): # Run fit function if self._out_name is "": - self._out_name = self._in_ws[:-7] + '_' + self._jump_function + '_fit' + ws_suffix_index = self._in_ws.rfind('_') + self._out_name = self._in_ws[:ws_suffix_index] + '_' + self._jump_function + '_fit' Fit(Function=function, InputWorkspace=spectrum_ws, CreateOutput=True, Output=self._out_name, StartX=self._q_min, EndX=self._q_max) From 370a80a6d7f24f46ada5fc1bc73a312e3de4c504 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 5 Nov 2014 11:23:54 +0000 Subject: [PATCH 12/15] Only plot the HWHM raw plot on JumpFit Refs #10277 --- .../algorithms/WorkflowAlgorithms/JumpFit.py | 5 +-- .../inc/MantidQtCustomInterfaces/JumpFit.ui | 10 ----- .../MantidQt/CustomInterfaces/src/JumpFit.cpp | 43 ++++++++++--------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py index 0682dc76d34c..92a6ebdad781 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py @@ -12,7 +12,7 @@ def category(self): def PyInit(self): self.declareProperty(WorkspaceProperty('InputWorkspace', '', direction=Direction.Input), - doc='Input workspace') + doc='Input workspace in HWHM') valid_functions = ['ChudleyElliot', 'HallRoss', 'FickDiffusion', 'TeixeiraWater'] self.declareProperty(name='Function', defaultValue=valid_functions[0], @@ -51,9 +51,6 @@ def PyExec(self): spectrum_ws = "__" + self._in_ws ExtractSingleSpectrum(InputWorkspace=self._in_ws, OutputWorkspace=spectrum_ws, WorkspaceIndex=self._width) - # Convert to HWHM - Scale(InputWorkspace=spectrum_ws, Factor=0.5, OutputWorkspace=spectrum_ws) - if self._verbose: logger.notice('Cropping from Q= ' + str(self._q_min) + ' to ' + str(self._q_max)) in_run = mtd[self._in_ws].getRun() diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui index 92bd9544a68f..ae6a514a585d 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/JumpFit.ui @@ -129,16 +129,6 @@ - - - - color: rgb(0, 255, 255); - - - Raw - - - diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp index 12ad3a2780f0..5f50250b1995 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp @@ -13,7 +13,7 @@ namespace MantidQt { namespace CustomInterfaces { - JumpFit::JumpFit(QWidget * parent) : + JumpFit::JumpFit(QWidget * parent) : IndirectBayesTab(parent) { m_uiForm.setupUi(parent); @@ -34,7 +34,7 @@ namespace MantidQt m_properties["QMin"] = m_dblManager->addProperty("QMin"); m_properties["QMax"] = m_dblManager->addProperty("QMax"); - + m_dblManager->setDecimals(m_properties["QMin"], NUM_DECIMALS); m_dblManager->setDecimals(m_properties["QMax"], NUM_DECIMALS); @@ -58,7 +58,7 @@ namespace MantidQt /** * Validate the form to check the program can be run - * + * * @return :: Whether the form was valid */ bool JumpFit::validate() @@ -86,7 +86,7 @@ namespace MantidQt * Collect the settings on the GUI and build a python * script that runs JumpFit */ - void JumpFit::run() + void JumpFit::run() { bool verbose = m_uiForm.chkVerbose->isChecked(); bool save = m_uiForm.chkSave->isChecked(); @@ -178,11 +178,6 @@ namespace MantidQt { QString specName = QString::fromStdString(axis->label(histIndex)); - if(specName == "Data") - { - plotMiniPlot(outputWorkspace, histIndex, "JumpFitPlot", specName); - } - if(specName == "Calc") { plotMiniPlot(outputWorkspace, histIndex, "JumpFitPlot", specName); @@ -195,14 +190,14 @@ namespace MantidQt m_curves[specName]->setPen(QColor(Qt::green)); } } - + replot("JumpFitPlot"); } /** * Set the data selectors to use the default save directory * when browsing for input files. - * + * * @param settings :: The current settings */ void JumpFit::loadSettings(const QSettings& settings) @@ -213,7 +208,7 @@ namespace MantidQt /** * Plots the loaded file to the miniplot and sets the guides * and the range - * + * * @param filename :: The name of the workspace to plot */ void JumpFit::handleSampleInputReady(const QString& filename) @@ -223,18 +218,25 @@ namespace MantidQt disconnect(m_uiForm.cbFunction, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(runPreviewAlgorithm())); disconnect(m_uiForm.cbWidth, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(runPreviewAlgorithm())); + // Scale to convert to HWHM + IAlgorithm_sptr scaleAlg = AlgorithmManager::Instance().create("Scale"); + scaleAlg->initialize(); + scaleAlg->setProperty("InputWorkspace", filename.toStdString()); + scaleAlg->setProperty("OutputWorkspace", filename.toStdString()); + scaleAlg->setProperty("Factor", 0.5); + scaleAlg->execute(); + auto ws = Mantid::API::AnalysisDataService::Instance().retrieve(filename.toStdString()); auto mws = boost::dynamic_pointer_cast(ws); findAllWidths(mws); - + if(m_spectraList.size() > 0) { m_uiForm.cbWidth->setEnabled(true); std::string currentWidth = m_uiForm.cbWidth->currentText().toStdString(); plotMiniPlot(filename, m_spectraList[currentWidth], "JumpFitPlot", "RawPlotCurve"); - m_curves["RawPlotCurve"]->setPen(QColor(Qt::cyan)); std::pair res; std::pair range = getCurveRange("RawPlotCurve"); @@ -263,8 +265,8 @@ namespace MantidQt } /** - * Find all of the spectra in the workspace that have width data - * + * Find all of the spectra in the workspace that have width data + * * @param ws :: The workspace to search */ void JumpFit::findAllWidths(Mantid::API::MatrixWorkspace_const_sptr ws) @@ -277,7 +279,7 @@ namespace MantidQt auto axis = dynamic_cast(ws->getAxis(1)); std::string title = axis->label(i); - //check if the axis labels indicate this spectrum is width data + //check if the axis labels indicate this spectrum is width data size_t qLinesWidthIndex = title.find(".Width"); size_t convFitWidthIndex = title.find(".FWHM"); @@ -289,7 +291,7 @@ namespace MantidQt { std::string cbItemName = ""; size_t substrIndex = 0; - + if (qLinesWidth) { substrIndex = qLinesWidthIndex; @@ -302,7 +304,7 @@ namespace MantidQt cbItemName = title.substr(0, substrIndex); m_spectraList[cbItemName] = static_cast(i); m_uiForm.cbWidth->addItem(QString(cbItemName.c_str())); - + //display widths f1.f1, f2.f1 and f2.f2 if (m_uiForm.cbWidth->count() == 3) { @@ -314,7 +316,7 @@ namespace MantidQt /** * Plots the loaded file to the miniplot when the selected spectrum changes - * + * * @param text :: The name spectrum index to plot */ void JumpFit::handleWidthChange(const QString& text) @@ -327,7 +329,6 @@ namespace MantidQt if(validate()) { plotMiniPlot(sampleName, m_spectraList[text.toStdString()], "JumpFitPlot", "RawPlotCurve"); - m_curves["RawPlotCurve"]->setPen(QColor(Qt::cyan)); } } } From a69d958e95fb89470e73a8777beb9e2e306af0c8 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 5 Nov 2014 11:49:05 +0000 Subject: [PATCH 13/15] Remove plotting form Stretch Refs #10277 --- .../MantidQt/CustomInterfaces/src/Stretch.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp index 98ac5d309a75..83f8217d2830 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp @@ -137,21 +137,6 @@ namespace MantidQt " Save="+save+", Plot='"+plot+"', Verbose="+verbose+")\n"; runPythonScript(pyInput); - - //Update mini plot - QString sigmaWsName = sampleName.left(sampleName.size() - 3) + "Qst_Sigma"; - QString betaWsName = sampleName.left(sampleName.size() - 3) + "Qst_Beta"; - - MatrixWorkspace_sptr sigmaWs = AnalysisDataService::Instance().retrieveWS(sigmaWsName.toStdString()); - MatrixWorkspace_sptr betaWs = AnalysisDataService::Instance().retrieveWS(betaWsName.toStdString()); - - plotMiniPlot(sigmaWs, 0, "StretchPlot", "SigmaCurve"); - plotMiniPlot(betaWs, 0, "StretchPlot", "BetaCurve"); - - m_curves["SigmaCurve"]->setPen(QColor(Qt::red)); - m_curves["BetaCurve"]->setPen(QColor(Qt::green)); - - replot("StretchPlot"); } /** From 31de5a1ba574ca14bda8fa000b6eefb2e031ddf7 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 5 Nov 2014 11:55:46 +0000 Subject: [PATCH 14/15] Plot the correct Quasi workspace Refs #10277 --- Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp index f374a559681a..dcffe3a5f647 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp @@ -137,14 +137,17 @@ namespace MantidQt QString resName = m_uiForm.dsResolution->getCurrentDataName(); QString program = m_uiForm.cbProgram->currentText(); + QString plotWsPorgramName; if(program == "Lorentzians") { program = "QL"; + plotWsPorgramName = "QLr"; } else { program = "QSe"; + plotWsPorgramName = "QSe"; } // Collect input from fit options section @@ -188,7 +191,7 @@ namespace MantidQt runPythonScript(pyInput); //Update mini plot - QString outWsName = sampleName.left(sampleName.size() - 3) + "QLr_Workspace_0"; + QString outWsName = sampleName.left(sampleName.size() - 3) + plotWsPorgramName + "_Workspace_0"; MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS(outWsName.toStdString()); TextAxis* axis = dynamic_cast(outputWorkspace->getAxis(1)); From e8fffc1b5954771e24901f64ae5a77a79a537656 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Wed, 5 Nov 2014 14:22:05 +0000 Subject: [PATCH 15/15] Use correct Quasi workspace for plotting when using red Refs #10277 --- .../MantidQt/CustomInterfaces/src/Quasi.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp index dcffe3a5f647..f66a6cd58f53 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp @@ -136,18 +136,18 @@ namespace MantidQt QString sampleName = m_uiForm.dsSample->getCurrentDataName(); QString resName = m_uiForm.dsResolution->getCurrentDataName(); + // Should be either "red", "sqw" or "res" + QString resType = resName.right(3); + QString program = m_uiForm.cbProgram->currentText(); - QString plotWsPorgramName; if(program == "Lorentzians") { program = "QL"; - plotWsPorgramName = "QLr"; } else { program = "QSe"; - plotWsPorgramName = "QSe"; } // Collect input from fit options section @@ -170,7 +170,7 @@ namespace MantidQt QString fitOps = "[" + elasticPeak + ", '" + background + "', " + fixedWidth + ", " + useResNorm + "]"; - //Collect input from the properties browser + // Collect input from the properties browser QString eMin = m_properties["EMin"]->valueText(); QString eMax = m_properties["EMax"]->valueText(); QString eRange = "[" + eMin + "," + eMax + "]"; @@ -179,7 +179,7 @@ namespace MantidQt QString resBins = m_properties["ResBinning"]->valueText(); QString nBins = "[" + sampleBins + "," + resBins + "]"; - //Output options + // Output options if(m_uiForm.chkVerbose->isChecked()) { verbose = "True"; } if(m_uiForm.chkSave->isChecked()) { save = "True"; } QString plot = m_uiForm.cbPlot->currentText(); @@ -190,8 +190,17 @@ namespace MantidQt runPythonScript(pyInput); - //Update mini plot - QString outWsName = sampleName.left(sampleName.size() - 3) + plotWsPorgramName + "_Workspace_0"; + // Get the correct workspace name based on the type of resolution file + if(program == "QL") + { + if(resType == "res") + program += "r"; + else + program += "d"; + } + + // Update mini plot + QString outWsName = sampleName.left(sampleName.size() - 3) + program + "_Workspace_0"; MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS(outWsName.toStdString()); TextAxis* axis = dynamic_cast(outputWorkspace->getAxis(1));