diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h index 6ec99813345874f90ebcfe5d3f91ee85d5af963e..92a21eea451a0f1c2d211b01782f5a6c138fd997 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ConvFit.h @@ -25,7 +25,6 @@ private slots: void typeSelection(int index); void bgTypeSelection(int index); void newDataLoaded(const QString wsName); - void extendResolutionWorkspace(); void updatePlot(); void plotGuess(); void singleFit(); @@ -44,6 +43,7 @@ private slots: void showTieCheckbox(QString); void singleFitComplete(bool error); void fitFunctionSelected(const QString &); + void extensionComplete(bool error); void algorithmComplete(bool error); @@ -64,7 +64,7 @@ private: void updatePlotOptions(); QString convertFuncToShort(const QString &); QString convertBackToShort(const std::string &original); - + void extendResolutionWorkspace(); Ui::ConvFit m_uiForm; QtStringPropertyManager *m_stringManager; QtTreePropertyBrowser *m_cfTree; diff --git a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp index 0443ddd7a40a931b02b24181fb6f3b6aae876163..cd1e8e733b1930aecf2371ba557781d6e7078501 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp @@ -187,11 +187,6 @@ void ConvFit::setup() { connect(m_uiForm.dsSampleInput, SIGNAL(dataReady(const QString &)), this, SLOT(newDataLoaded(const QString &))); - connect(m_uiForm.dsSampleInput, SIGNAL(dataReady(const QString &)), this, - SLOT(extendResolutionWorkspace())); - connect(m_uiForm.dsResInput, SIGNAL(dataReady(const QString &)), this, - SLOT(extendResolutionWorkspace())); - connect(m_uiForm.spSpectraMin, SIGNAL(valueChanged(int)), this, SLOT(specMinChanged(int))); connect(m_uiForm.spSpectraMax, SIGNAL(valueChanged(int)), this, @@ -223,11 +218,57 @@ void ConvFit::setup() { * algorithm */ void ConvFit::run() { + if (m_cfInputWS == NULL) { g_log.error("No workspace loaded"); return; } + extendResolutionWorkspace(); +} + +/** +* Create a resolution workspace with the same number of histograms as in the +* sample. +* +* Needed to allow DiffSphere and DiffRotDiscreteCircle fit functions to work as +* they need +* to have the WorkspaceIndex attribute set. +*/ +void ConvFit::extendResolutionWorkspace() { + if (m_cfInputWS && m_uiForm.dsResInput->isValid()) { + const QString resWsName = m_uiForm.dsResInput->getCurrentDataName(); + API::BatchAlgorithmRunner::AlgorithmRuntimeProps appendProps; + appendProps["InputWorkspace1"] = "__ConvFit_Resolution"; + + size_t numHist = m_cfInputWS->getNumberHistograms(); + for (size_t i = 0; i < numHist; i++) { + IAlgorithm_sptr appendAlg = + AlgorithmManager::Instance().create("AppendSpectra"); + appendAlg->initialize(); + appendAlg->setProperty("InputWorkspace2", resWsName.toStdString()); + appendAlg->setProperty("OutputWorkspace", "__ConvFit_Resolution"); + + if (i == 0) { + appendAlg->setProperty("InputWorkspace1", resWsName.toStdString()); + m_batchAlgoRunner->addAlgorithm(appendAlg); + } else { + m_batchAlgoRunner->addAlgorithm(appendAlg, appendProps); + } + } + connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, + SLOT(extensionComplete(bool))); + m_batchAlgoRunner->executeBatchAsync(); + } +} + +void ConvFit::extensionComplete(bool error) { + disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, + SLOT(extensionComplete(bool))); + if (error) + return; + + // Run Convolution Fit Sequetial algorithm QString fitType = fitTypeString(); QString bgType = backgroundString(); @@ -483,40 +524,6 @@ void ConvFit::newDataLoaded(const QString wsName) { updatePlot(); } -/** -* Create a resolution workspace with the same number of histograms as in the -* sample. -* -* Needed to allow DiffSphere and DiffRotDiscreteCircle fit functions to work as -* they need -* to have the WorkspaceIndex attribute set. -*/ -void ConvFit::extendResolutionWorkspace() { - if (m_cfInputWS && m_uiForm.dsResInput->isValid()) { - const QString resWsName = m_uiForm.dsResInput->getCurrentDataName(); - API::BatchAlgorithmRunner::AlgorithmRuntimeProps appendProps; - appendProps["InputWorkspace1"] = "__ConvFit_Resolution"; - - size_t numHist = m_cfInputWS->getNumberHistograms(); - for (size_t i = 0; i < numHist; i++) { - IAlgorithm_sptr appendAlg = - AlgorithmManager::Instance().create("AppendSpectra"); - appendAlg->initialize(); - appendAlg->setProperty("InputWorkspace2", resWsName.toStdString()); - appendAlg->setProperty("OutputWorkspace", "__ConvFit_Resolution"); - - if (i == 0) { - appendAlg->setProperty("InputWorkspace1", resWsName.toStdString()); - m_batchAlgoRunner->addAlgorithm(appendAlg); - } else { - m_batchAlgoRunner->addAlgorithm(appendAlg, appendProps); - } - } - - m_batchAlgoRunner->executeBatchAsync(); - } -} - namespace { //////////////////////////// // Anon Helper functions. // @@ -1017,8 +1024,8 @@ void ConvFit::updatePlot() { m_uiForm.ppPlot->getRangeSelector("ConvFitRange") ->setRange(range.first, range.second); m_uiForm.ckPlotGuess->setChecked(plotGuess); - m_dblManager->setValue(m_properties["StartX"], range.first); - m_dblManager->setValue(m_properties["EndX"], range.second); + m_dblManager->setValue(m_properties["StartX"], range.first); + m_dblManager->setValue(m_properties["EndX"], range.second); } catch (std::invalid_argument &exc) { showMessageBox(exc.what()); }