From 771516c0380e7bd2a8aedc02a9b17a4b2645f6c5 Mon Sep 17 00:00:00 2001
From: Elliot Oram <Elliot.Oram@stfc.ac.uk>
Date: Tue, 20 Oct 2015 11:23:06 +0100
Subject: [PATCH] Ammend QLRun algorithm to have multiple outputs

Refs #13826
---
 .../algorithms/WorkflowAlgorithms/QLRun.py    | 19 +++++++++++++++++--
 .../MantidQtCustomInterfaces/Indirect/Quasi.h |  2 ++
 .../CustomInterfaces/src/Indirect/Quasi.cpp   |  4 ++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/QLRun.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/QLRun.py
index 93bba345ccd..a058e40059b 100644
--- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/QLRun.py
+++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/QLRun.py
@@ -9,7 +9,7 @@ if is_supported_f2py_platform():
 else:
     logger.error('F2Py functionality not currently available on your platform.')
 
-from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode
+from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, WorkspaceGroupProperty
 from mantid.kernel import StringListValidator, Direction
 from mantid.simpleapi import *
 from mantid import config, logger
@@ -94,6 +94,16 @@ class QLRun(PythonAlgorithm):
 
         self.declareProperty(name='Save', defaultValue=False, doc='Switch Save result to nxs file Off/On')
 
+        self.declareProperty(WorkspaceGroupProperty('OutputWorkspaceFit', '', direction=Direction.Output),
+                             doc='The name of the fit output workspaces')
+
+        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspaceProb', '', optional=PropertyMode.Optional,
+                             direction=Direction.Output),
+                             doc='The name of the probability output workspaces')
+
+        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspaceResult', '', direction=Direction.Output),
+                             doc='The name of the result output workspaces')
+
 
     def validateInputs(self):
         self._get_properties()
@@ -313,7 +323,7 @@ class QLRun(PythonAlgorithm):
             yProb = yPr0
             yProb = np.append(yProb,yPr1)
             yProb = np.append(yProb,yPr2)
-            CreateWorkspace(OutputWorkspace=probWS, DataX=xProb, DataY=yProb, DataE=eProb,\
+            probWs = CreateWorkspace(OutputWorkspace=probWS, DataX=xProb, DataY=yProb, DataE=eProb,\
                 Nspec=3, UnitX='MomentumTransfer')
             outWS = C2Fw(self._samWS[:-4],fname)
             if self._Plot != 'None':
@@ -339,6 +349,11 @@ class QLRun(PythonAlgorithm):
             logger.information('Output fit file created : ' + fit_path)
             logger.information('Output paramter file created : ' + out_path)
 
+        self.setProperty('OutputworkspaceFit', fitWS)
+        self.setProperty('OutputWorkspaceResult', outWS)
+        if self._program == 'QL':
+            self.setProperty('OutputWorkspaceProb', probWS)
+
 
 if is_supported_f2py_platform():
     # Register algorithm with Mantid
diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/Quasi.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/Quasi.h
index 51f240b0f68..5aed373ac62 100644
--- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/Quasi.h
+++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/Quasi.h
@@ -44,6 +44,8 @@ private:
   int m_previewSpec;
   /// The ui form
   Ui::Quasi m_uiForm;
+  /// alg
+  Mantid::API::IAlgorithm_sptr m_QuasiAlg;
 };
 } // namespace CustomInterfaces
 } // namespace MantidQt
diff --git a/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp b/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp
index a0000d49334..ca37a7164ae 100644
--- a/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp
+++ b/MantidQt/CustomInterfaces/src/Indirect/Quasi.cpp
@@ -186,6 +186,9 @@ void Quasi::run() {
   runAlg->setProperty("SampleWorkspace", sampleName);
   runAlg->setProperty("ResolutionWorkspace", resName);
   runAlg->setProperty("ResNormWorkspace", resNormFile);
+  runAlg->setProperty("OutputWorkspaceFit", "fit");
+  runAlg->setProperty("OutputWorkspaceProb", "prob");
+  runAlg->setProperty("OutputWorkspaceResult", "result");
   runAlg->setProperty("MinRange", eMin);
   runAlg->setProperty("MaxRange", eMax);
   runAlg->setProperty("SampleBins", sampleBins);
@@ -199,6 +202,7 @@ void Quasi::run() {
   runAlg->setProperty("Save", save);
   runAlg->setProperty("Plot", plot);
 
+  m_QuasiAlg = runAlg;
   m_batchAlgoRunner->addAlgorithm(runAlg);
   connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this,
           SLOT(algorithmComplete(bool)));
-- 
GitLab