From 585b67afb1b31a7fdf028fd73a812f2d252f1e50 Mon Sep 17 00:00:00 2001 From: Pranav Bahuguna Date: Wed, 8 Feb 2017 16:01:22 +0000 Subject: [PATCH 1/6] Re #18755 Converted ConvFit --- .../CustomInterfaces/src/Indirect/ConvFit.cpp | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp index 840e0e01b301..3bbbd4d61bf7 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp @@ -7,12 +7,10 @@ #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/FunctionDomain1D.h" #include "MantidAPI/FunctionFactory.h" -#include "MantidAPI/TextAxis.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidGeometry/Instrument.h" #include -#include #include #include @@ -1108,27 +1106,19 @@ void ConvFit::plotGuess() { m_cfInputWS->binIndexOf(m_dblManager->value(m_properties["EndX"])); const size_t nData = binIndexHigh - binIndexLow; - std::vector inputXData(nData); - const Mantid::MantidVec &XValues = m_cfInputWS->readX(0); + std::vector dataX; + const auto xPoints = m_cfInputWS->points(0); const bool isHistogram = m_cfInputWS->isHistogramData(); - for (size_t i = 0; i < nData; i++) { - if (isHistogram) { - inputXData[i] = - 0.5 * (XValues[binIndexLow + i] + XValues[binIndexLow + i + 1]); - } else { - inputXData[i] = XValues[binIndexLow + i]; - } - } + std::copy(&xPoints[binIndexLow], &xPoints[binIndexLow + nData], + dataX.begin()); - FunctionDomain1DVector domain(inputXData); + QVector dataY; + FunctionDomain1DVector domain(dataX); FunctionValues outputData(domain); function->function(domain, outputData); - QVector dataX, dataY; - for (size_t i = 0; i < nData; i++) { - dataX.append(inputXData[i]); dataY.append(outputData.getCalculated(i)); } @@ -1139,7 +1129,7 @@ void ConvFit::plotGuess() { createWsAlg->setLogging(false); createWsAlg->setProperty("OutputWorkspace", "__GuessAnon"); createWsAlg->setProperty("NSpec", 1); - createWsAlg->setProperty("DataX", dataX.toStdVector()); + createWsAlg->setProperty("DataX", dataX); createWsAlg->setProperty("DataY", dataY.toStdVector()); createWsAlg->execute(); MatrixWorkspace_sptr guessWs = createWsAlg->getProperty("OutputWorkspace"); From 664bb061f35ddbd2aa725c381a22363d72014a81 Mon Sep 17 00:00:00 2001 From: Pranav Bahuguna Date: Wed, 8 Feb 2017 16:10:14 +0000 Subject: [PATCH 2/6] Re #18755 Converted CorrectionsTab --- .../CustomInterfaces/src/Indirect/CorrectionsTab.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/MantidQt/CustomInterfaces/src/Indirect/CorrectionsTab.cpp b/MantidQt/CustomInterfaces/src/Indirect/CorrectionsTab.cpp index 3411cdad54bb..c6657423e088 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/CorrectionsTab.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/CorrectionsTab.cpp @@ -1,12 +1,7 @@ #include "MantidQtCustomInterfaces/Indirect/CorrectionsTab.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/AnalysisDataService.h" -#include "boost/shared_ptr.hpp" -#include -#include #include -#include using namespace Mantid::API; @@ -52,8 +47,8 @@ bool CorrectionsTab::checkWorkspaceBinningMatches( MatrixWorkspace_const_sptr left, MatrixWorkspace_const_sptr right) { if (left && right) // check the workspaces actually point to something first { - auto leftX = left->readX(0); - auto rightX = right->readX(0); + const auto leftX = left->x(0); + const auto rightX = right->x(0); return std::equal(leftX.begin(), leftX.end(), rightX.begin()); } else { throw std::runtime_error("CorrectionsTab: One of the operands is an " From 8b8186ba10f5f86357021aeaa6ee941e519d045f Mon Sep 17 00:00:00 2001 From: Pranav Bahuguna Date: Wed, 8 Feb 2017 16:36:03 +0000 Subject: [PATCH 3/6] Re #18755 Converted IDRT, IS, Iqt --- .../src/Indirect/IndirectDataReductionTab.cpp | 2 +- .../CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp | 7 ++----- MantidQt/CustomInterfaces/src/Indirect/Iqt.cpp | 9 ++------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp b/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp index 65494a6020f4..fd6c52936a1a 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp @@ -216,7 +216,7 @@ std::map IndirectDataReductionTab::getRangesFromInstrument( convUnitsAlg->execute(); MatrixWorkspace_sptr tofWs = convUnitsAlg->getProperty("OutputWorkspace"); - std::vector tofData = tofWs->readX(0); + const auto tofData = tofWs->x(0); ranges["peak-start-tof"] = tofData[0]; ranges["peak-end-tof"] = tofData[2]; ranges["back-start-tof"] = tofData[3]; diff --git a/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp b/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp index e229ed001e99..c72b350cfb7c 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp @@ -3,9 +3,6 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidKernel/Logger.h" -#include "MantidQtCustomInterfaces/UserInputValidator.h" - -#include namespace { Mantid::Kernel::Logger g_log("IndirectSymmetrise"); @@ -423,8 +420,8 @@ void IndirectSymmetrise::previewAlgDone(bool error) { int positiveIndex = propsTable->getColumn("PositiveXMinIndex")->cell(0); // Get the Y values for each XCut and the difference between them - double negativeY = sampleWS->dataY(0)[negativeIndex]; - double positiveY = sampleWS->dataY(0)[positiveIndex]; + double negativeY = sampleWS->y(0)[negativeIndex]; + double positiveY = sampleWS->y(0)[positiveIndex]; double deltaY = fabs(negativeY - positiveY); // Show values in property tree diff --git a/MantidQt/CustomInterfaces/src/Indirect/Iqt.cpp b/MantidQt/CustomInterfaces/src/Indirect/Iqt.cpp index 0380970ee5e0..db86c0354449 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/Iqt.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/Iqt.cpp @@ -5,12 +5,7 @@ #include "MantidGeometry/Instrument.h" #include "MantidQtMantidWidgets/RangeSelector.h" -#include - #include -#include - -#include namespace { Mantid::Kernel::Logger g_log("Iqt"); @@ -154,7 +149,7 @@ void Iqt::PlotTiled() { // Find x value where y > 1 in 0th spectra const auto tiledPlotWsName = outWs->getName() + "_tiled"; - const auto y_data = outWs->dataY(0); + const auto y_data = outWs->y(0); const auto y_data_length = y_data.size(); auto crop_index = y_data.size(); for (size_t i = 0; i < y_data_length; i++) { @@ -163,7 +158,7 @@ void Iqt::PlotTiled() { break; } } - const auto crop_value = outWs->dataX(0)[crop_index]; + const auto crop_value = outWs->x(0)[crop_index]; // Clone workspace before cropping to keep in ADS IAlgorithm_sptr clone = AlgorithmManager::Instance().create("CloneWorkspace"); From dabdd349666abbee3a51e1c9a3ad9af7b2e5d2c1 Mon Sep 17 00:00:00 2001 From: Pranav Bahuguna Date: Wed, 8 Feb 2017 16:52:11 +0000 Subject: [PATCH 4/6] Re #18755 Converted IqtFit + readjusted ConvFit --- .../CustomInterfaces/src/Indirect/ConvFit.cpp | 15 ++++--- .../CustomInterfaces/src/Indirect/IqtFit.cpp | 39 +++++++------------ 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp index 3bbbd4d61bf7..abf340739d67 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp @@ -1106,20 +1106,19 @@ void ConvFit::plotGuess() { m_cfInputWS->binIndexOf(m_dblManager->value(m_properties["EndX"])); const size_t nData = binIndexHigh - binIndexLow; - std::vector dataX; - const auto xPoints = m_cfInputWS->points(0); - const bool isHistogram = m_cfInputWS->isHistogramData(); - + const auto &xPoints = m_cfInputWS->points(0); + + std::vector dataX(nData); std::copy(&xPoints[binIndexLow], &xPoints[binIndexLow + nData], dataX.begin()); - QVector dataY; FunctionDomain1DVector domain(dataX); FunctionValues outputData(domain); function->function(domain, outputData); - + + std::vector dataY(nData); for (size_t i = 0; i < nData; i++) { - dataY.append(outputData.getCalculated(i)); + dataY[i] = outputData.getCalculated(i); } IAlgorithm_sptr createWsAlg = @@ -1130,7 +1129,7 @@ void ConvFit::plotGuess() { createWsAlg->setProperty("OutputWorkspace", "__GuessAnon"); createWsAlg->setProperty("NSpec", 1); createWsAlg->setProperty("DataX", dataX); - createWsAlg->setProperty("DataY", dataY.toStdVector()); + createWsAlg->setProperty("DataY", dataY); createWsAlg->execute(); MatrixWorkspace_sptr guessWs = createWsAlg->getProperty("OutputWorkspace"); diff --git a/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp b/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp index 89bfc97a61aa..3237eb67b14c 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp @@ -9,9 +9,7 @@ #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/WorkspaceGroup.h" -#include #include -#include #include #include @@ -616,8 +614,8 @@ void IqtFit::setDefaultParameters(const QString &name) { double background = m_dblManager->value(m_properties["BackgroundA0"]); // intensity is always 1-background m_dblManager->setValue(m_properties[name + ".Intensity"], 1.0 - background); - auto x = m_iqtFInputWS->readX(0); - auto y = m_iqtFInputWS->readY(0); + auto x = m_iqtFInputWS->x(0); + auto y = m_iqtFInputWS->y(0); double tau = 0; if (x.size() > 4) { @@ -944,31 +942,20 @@ void IqtFit::plotGuess(QtProperty *) { m_iqtFRangeManager->value(m_properties["EndX"])); const size_t nData = binIndxHigh - binIndxLow; - std::vector inputXData(nData); + const auto &xPoints = m_iqtFInputWS->points(0); + + std::vector dataX(nData); + std::copy(&xPoints[binIndxLow], &xPoints[binIndxLow + nData], dataX.begin()); - const Mantid::MantidVec &XValues = m_iqtFInputWS->readX(0); - - const bool isHistogram = m_iqtFInputWS->isHistogramData(); - - for (size_t i = 0; i < nData; i++) { - if (isHistogram) - inputXData[i] = - 0.5 * (XValues[binIndxLow + i] + XValues[binIndxLow + i + 1]); - else - inputXData[i] = XValues[binIndxLow + i]; - } - - FunctionDomain1DVector domain(inputXData); + FunctionDomain1DVector domain(dataX); FunctionValues outputData(domain); function->function(domain, outputData); - - QVector dataX; - QVector dataY; - + + std::vector dataY(nData); for (size_t i = 0; i < nData; i++) { - dataX.append(inputXData[i]); - dataY.append(outputData.getCalculated(i)); + dataY[i] = outputData.getCalculated(i); } + IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("CreateWorkspace"); createWsAlg->initialize(); @@ -976,8 +963,8 @@ void IqtFit::plotGuess(QtProperty *) { createWsAlg->setLogging(false); createWsAlg->setProperty("OutputWorkspace", "__GuessAnon"); createWsAlg->setProperty("NSpec", 1); - createWsAlg->setProperty("DataX", dataX.toStdVector()); - createWsAlg->setProperty("DataY", dataY.toStdVector()); + createWsAlg->setProperty("DataX", dataX); + createWsAlg->setProperty("DataY", dataY); createWsAlg->execute(); MatrixWorkspace_sptr guessWs = createWsAlg->getProperty("OutputWorkspace"); From b7358fcaa5cd090bec13caf0054fea713b50fdcc Mon Sep 17 00:00:00 2001 From: Pranav Bahuguna Date: Wed, 8 Feb 2017 17:28:58 +0000 Subject: [PATCH 5/6] Re #18755 Converted remaining files --- .../CustomInterfaces/src/Indirect/ISISCalibration.cpp | 4 ++-- .../CustomInterfaces/src/Indirect/ISISDiagnostics.cpp | 2 +- .../src/Indirect/ISISEnergyTransfer.cpp | 10 ++++------ MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp b/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp index cb842494b402..2fb8acde42f5 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ISISCalibration.cpp @@ -411,7 +411,7 @@ void ISISCalibration::calPlotRaw() { MatrixWorkspace_sptr input = boost::dynamic_pointer_cast( AnalysisDataService::Instance().retrieve(wsname.toStdString())); - const Mantid::MantidVec &dataX = input->readX(0); + const auto &dataX = input->x(0); QPair range(dataX.front(), dataX.back()); m_uiForm.ppCalibration->clear(); @@ -491,7 +491,7 @@ void ISISCalibration::calPlotEnergy() { return; } - const Mantid::MantidVec &dataX = energyWs->readX(0); + const auto &dataX = energyWs->x(0); QPair range(dataX.front(), dataX.back()); auto resBackground = m_uiForm.ppResolution->getRangeSelector("ResBackground"); diff --git a/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp b/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp index 0cc586448874..6295b5956acd 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ISISDiagnostics.cpp @@ -311,7 +311,7 @@ void ISISDiagnostics::handleNewFile() { Mantid::API::AnalysisDataService::Instance().retrieve( wsname.toStdString())); - const Mantid::MantidVec &dataX = input->readX(0); + const auto &dataX = input->x(0); QPair range(dataX.front(), dataX.back()); int previewSpec = static_cast(m_dblManager->value(m_properties["PreviewSpec"])) - diff --git a/MantidQt/CustomInterfaces/src/Indirect/ISISEnergyTransfer.cpp b/MantidQt/CustomInterfaces/src/Indirect/ISISEnergyTransfer.cpp index c426cb03763e..c4894ba1b849 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ISISEnergyTransfer.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ISISEnergyTransfer.cpp @@ -2,11 +2,9 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" -#include "MantidGeometry/IDTypes.h" #include "MantidQtCustomInterfaces/UserInputValidator.h" #include -#include using namespace Mantid::API; using MantidQt::API::BatchAlgorithmRunner; @@ -168,8 +166,8 @@ bool ISISEnergyTransfer::validate() { if (m_uiForm.ckBackgroundRemoval->isChecked()) { MatrixWorkspace_sptr tempWs = AnalysisDataService::Instance().retrieveWS(name); - const double minBack = tempWs->readX(0)[0]; - const double maxBack = tempWs->readX(0)[tempWs->blocksize()]; + const double minBack = tempWs->x(0)[0]; + const double maxBack = tempWs->x(0)[tempWs->blocksize()]; if (m_uiForm.spBackgroundStart->value() < minBack) { uiv.addErrorMessage("The Start of Background Removal is less than the " @@ -557,8 +555,8 @@ void ISISEnergyTransfer::plotRaw() { if (m_uiForm.ckBackgroundRemoval->isChecked()) { MatrixWorkspace_sptr tempWs = AnalysisDataService::Instance().retrieveWS(name); - const double minBack = tempWs->readX(0)[0]; - const double maxBack = tempWs->readX(0)[tempWs->blocksize()]; + const double minBack = tempWs->x(0)[0]; + const double maxBack = tempWs->x(0)[tempWs->blocksize()]; if (startBack < minBack) { emit showMessageBox("The Start of Background Removal is less than the " diff --git a/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp b/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp index a73ec35c9a5e..d91c198cdb71 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp @@ -289,12 +289,12 @@ void ResNorm::previewSpecChanged(int value) { fitWsName); MatrixWorkspace_sptr fit = WorkspaceFactory::Instance().create(fitWs, 1); - fit->setX(0, fitWs->refX(1)); - fit->dataY(0) = fitWs->readY(1); - fit->dataE(0) = fitWs->readE(1); + fit->setSharedX(0, fit->sharedX(1)); + fit->setSharedY(0, fit->sharedY(1)); + fit->setSharedE(0, fit->sharedE(1)); for (size_t i = 0; i < fit->blocksize(); i++) - fit->dataY(0)[i] /= scaleFactors->cell(m_previewSpec); + fit->mutableY(0)[i] /= scaleFactors->cell(m_previewSpec); m_uiForm.ppPlot->addSpectrum("Fit", fit, 0, Qt::red); } From 2300488c24f76b6413575fa8152091da1de57856 Mon Sep 17 00:00:00 2001 From: Pranav Bahuguna Date: Wed, 8 Feb 2017 17:39:09 +0000 Subject: [PATCH 6/6] Re #18755 Clang formatting fix --- MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp | 4 ++-- MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp index abf340739d67..f38043ab3f30 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ConvFit.cpp @@ -1107,7 +1107,7 @@ void ConvFit::plotGuess() { const size_t nData = binIndexHigh - binIndexLow; const auto &xPoints = m_cfInputWS->points(0); - + std::vector dataX(nData); std::copy(&xPoints[binIndexLow], &xPoints[binIndexLow + nData], dataX.begin()); @@ -1115,7 +1115,7 @@ void ConvFit::plotGuess() { FunctionDomain1DVector domain(dataX); FunctionValues outputData(domain); function->function(domain, outputData); - + std::vector dataY(nData); for (size_t i = 0; i < nData; i++) { dataY[i] = outputData.getCalculated(i); diff --git a/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp b/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp index 3237eb67b14c..ebb15944ddbf 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IqtFit.cpp @@ -943,14 +943,14 @@ void IqtFit::plotGuess(QtProperty *) { const size_t nData = binIndxHigh - binIndxLow; const auto &xPoints = m_iqtFInputWS->points(0); - + std::vector dataX(nData); std::copy(&xPoints[binIndxLow], &xPoints[binIndxLow + nData], dataX.begin()); FunctionDomain1DVector domain(dataX); FunctionValues outputData(domain); function->function(domain, outputData); - + std::vector dataY(nData); for (size_t i = 0; i < nData; i++) { dataY[i] = outputData.getCalculated(i);