diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/ConvolutionFitSequential.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/ConvolutionFitSequential.cpp index d0516739772d2130f1d7d9aa0e4dce6abfaaf4cd..9c6f7456f7f6ea88d98784b77b6101bf1d1f4402 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/ConvolutionFitSequential.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/ConvolutionFitSequential.cpp @@ -187,12 +187,14 @@ void ConvolutionFitSequential::exec() { const std::string tempFitWsName = "__convfit_fit_ws"; auto tempFitWs = convertInputToElasticQ(inputWs, tempFitWsName); - // Fit all spectra in workspace + Progress plotPeakStringProg(this, 0.0, 1.0, specMax); + // Construct plotpeak string std::string plotPeakInput = ""; for (int i = 0; i < specMax + 1; i++) { std::string nextWs = tempFitWsName + ",i"; nextWs += boost::lexical_cast<std::string>(i); plotPeakInput += nextWs + ";"; + plotPeakStringProg.report(i); } // passWSIndex @@ -267,8 +269,7 @@ void ConvolutionFitSequential::exec() { } // Run ProcessIndirectFitParameters - auto pifp = - createChildAlgorithm("ProcessIndirectFitParameters"); + auto pifp = createChildAlgorithm("ProcessIndirectFitParameters"); pifp->setProperty("InputWorkspace", outputWs); pifp->setProperty("ColumnX", "axis-1"); pifp->setProperty("XAxisUnit", "MomentumTransfer"); @@ -304,6 +305,7 @@ void ConvolutionFitSequential::exec() { logAdder->setProperty("LogName", it->first); logAdder->setProperty("LogText", it->second); logAdder->setProperty("LogType", "String"); + logAdder->executeAsChildAlg(); } // Add Numeric Logs diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h index 924be3c8d2b4f10c6461e61059bdaf8ae5eef802..963410f7b9f3685ec035b90a7bb57e7b68b45020 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h @@ -44,6 +44,7 @@ private slots: void showTieCheckbox(QString); void singleFitComplete(bool error); void fitFunctionSelected(const QString &); + void algorithmComplete(bool error); private: diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp index 073b62313e387725b17c13d675259b4a8d767c7e..5be7521f1d1a15fd936aea1d3dcb7228bc0e1bd9 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp @@ -214,7 +214,8 @@ void ConvFit::setup() { } /** - * Converts data into a python script which prodcues the output workspace + * Handles the initial set up and running of the ConvolutionFitSequential + * algorithm */ void ConvFit::run() { if (m_cfInputWS == NULL) { @@ -240,12 +241,12 @@ void ConvFit::run() { std::string specMax = m_uiForm.spSpectraMax->text().toStdString(); int maxIterations = static_cast<int>(m_dblManager->value(m_properties["MaxIterations"])); - QString temperature = m_uiForm.leTempCorrection->text(); - std::string plot = m_uiForm.cbPlotType->currentText().toStdString(); - const bool save = m_uiForm.ckSave->isChecked(); // Run ConvolutionFitSequential Algorithm - auto cfs = AlgorithmManager::Instance().create("ConvolutionFitSequential"); + IAlgorithm_sptr cfs = + AlgorithmManager::Instance().create("ConvolutionFitSequential"); + cfs->initialize(); + cfs->setProperty("InputWorkspace", m_cfInputWS->getName()); cfs->setProperty("Function", function); cfs->setProperty("BackgroundType", @@ -258,14 +259,28 @@ void ConvFit::run() { cfs->setProperty("Minimizer", minimizerString("$outputname_$wsindex").toStdString()); cfs->setProperty("MaxIterations", maxIterations); - cfs->execute(); + m_batchAlgoRunner->addAlgorithm(cfs); + connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, + SLOT(algorithmComplete(bool))); + m_batchAlgoRunner->executeBatchAsync(); +} +/** + * Handles completion of the ConvolutionFitSequential algorithm. + * + * @param error True if the algorithm was stopped due to error, false otherwise + */ +void ConvFit::algorithmComplete(bool error) { + disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, + SLOT(algorithmComplete(bool))); + QString temperature = m_uiForm.leTempCorrection->text(); double temp = 0.0; if (temperature.toStdString().compare("") != 0) { temp = temperature.toDouble(); } - std::string baseWsName = cfs->getProperty("OutputWorkspace"); + + /*std::string baseWsName = cfs->getProperty("OutputWorkspace"); auto pos = baseWsName.rfind("_"); baseWsName = baseWsName.substr(0, pos + 1); @@ -277,6 +292,9 @@ void ConvFit::run() { WorkspaceGroup_sptr groupWs = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(groupName); + std::string specMin = m_uiForm.spSpectraMin->text().toStdString(); + std::string specMax = m_uiForm.spSpectraMax->text().toStdString(); + if (temp != 0.0) { const int maxSpec = boost::lexical_cast<int>(specMax) + 1; auto addSample = AlgorithmManager::Instance().create("AddSampleLog"); @@ -289,7 +307,7 @@ void ConvFit::run() { addSample->setProperty("LogName", "temperature_correction"); addSample->setProperty("LogText", "True"); addSample->setProperty("LogType", "String"); - addSample->execute(); + m_batchAlgoRunner->addAlgorithm(addSample); for (int i = 0; i < maxSpec; i++) { addSample->setProperty("Workspace", groupWs); addSample->setProperty("LogName", "temperature_value"); @@ -304,6 +322,9 @@ void ConvFit::run() { } } + std::string plot = m_uiForm.cbPlotType->currentText().toStdString(); + const bool save = m_uiForm.ckSave->isChecked(); + if (save) { QString saveDir = QString::fromStdString( Mantid::Kernel::ConfigService::Instance().getString( @@ -327,8 +348,7 @@ void ConvFit::run() { IndirectTab::plotSpectrum(QString::fromStdString(resultWs->getName()), specNumber, specNumber); } - } - m_batchAlgoRunner->executeBatchAsync(); + }*/ updatePlot(); }