diff --git a/Framework/Algorithms/src/AddPeak.cpp b/Framework/Algorithms/src/AddPeak.cpp index ab5c8bbb745bbc1bb8ae5c201c6eda2746be6505..4c19e64b2828ba3be45a24867d25b54b4afdd1fa 100644 --- a/Framework/Algorithms/src/AddPeak.cpp +++ b/Framework/Algorithms/src/AddPeak.cpp @@ -1,6 +1,6 @@ #include "MantidAlgorithms/AddPeak.h" #include "MantidAPI/Axis.h" -#include "MantidAPI/IPeaksWorkspace.h" +#include "MantidDataObjects/PeaksWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidGeometry/Instrument/DetectorInfo.h" @@ -20,11 +20,13 @@ DECLARE_ALGORITHM(AddPeak) using namespace Mantid::Kernel; using namespace Mantid::API; +using Mantid::DataObjects::PeaksWorkspace; +using Mantid::DataObjects::PeaksWorkspace_sptr; /** Initialize the algorithm's properties. */ void AddPeak::init() { - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "PeaksWorkspace", "", Direction::InOut), "A peaks workspace."); declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>( @@ -39,7 +41,7 @@ void AddPeak::init() { /** Execute the algorithm. */ void AddPeak::exec() { - IPeaksWorkspace_sptr peaksWS = getProperty("PeaksWorkspace"); + PeaksWorkspace_sptr peaksWS = getProperty("PeaksWorkspace"); MatrixWorkspace_sptr runWS = getProperty("RunWorkspace"); const int detID = getProperty("DetectorID"); diff --git a/Framework/Crystal/inc/MantidCrystal/CountReflections.h b/Framework/Crystal/inc/MantidCrystal/CountReflections.h index b06c2af7705e0951ff1c7e818c88bb251b910be9..c156ccf0d6edfcc57e82f9c1682f4a50de98434a 100644 --- a/Framework/Crystal/inc/MantidCrystal/CountReflections.h +++ b/Framework/Crystal/inc/MantidCrystal/CountReflections.h @@ -51,7 +51,7 @@ private: void init() override; void exec() override; - API::IPeaksWorkspace_sptr getPeaksWorkspace( + DataObjects::PeaksWorkspace_sptr getPeaksWorkspace( const DataObjects::PeaksWorkspace_sptr &templateWorkspace, const PeakStatisticsTools::UniqueReflectionCollection &reflections, const Geometry::PointGroup_sptr &pointGroup) const; diff --git a/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h index 78034d3109244f23511beed431183d1406ff1d62..07714ccf7b74639765aa269ced5e5d417d5a09b9 100644 --- a/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h @@ -49,8 +49,6 @@ public: private: void init() override; void exec() override; - Mantid::DataObjects::PeaksWorkspace_sptr tryFetchOutputWorkspace() const; - Mantid::DataObjects::PeaksWorkspace_sptr tryFetchInputWorkspace() const; }; } // namespace Crystal diff --git a/Framework/Crystal/src/CountReflections.cpp b/Framework/Crystal/src/CountReflections.cpp index a65b6e4369e3e8392d5c5fbcba389d1f345961ac..6a28c3143952c6e5704447eb986aa5369b832d8c 100644 --- a/Framework/Crystal/src/CountReflections.cpp +++ b/Framework/Crystal/src/CountReflections.cpp @@ -90,7 +90,7 @@ void CountReflections::init() { "Fraction of reflections with more than one observation."); declareProperty( - Kernel::make_unique<WorkspaceProperty<IPeaksWorkspace>>( + Kernel::make_unique<WorkspaceProperty<PeaksWorkspace>>( "MissingReflectionsWorkspace", "", Direction::Output, PropertyMode::Optional), "Reflections in specified d-range that are missing in input workspace."); @@ -148,7 +148,7 @@ void CountReflections::exec() { setProperty("MultiplyObserved", multiplyObservedReflections / observedUniqueReflectionsD); - IPeaksWorkspace_sptr outputWorkspace = + PeaksWorkspace_sptr outputWorkspace = getPeaksWorkspace(inputPeaksWorkspace, reflections, pointGroup); if (outputWorkspace) { @@ -171,7 +171,7 @@ void CountReflections::exec() { * @param pointGroup :: Point group to expand unique reflections. * @return :: PeaksWorkspace with missing reflections. */ -IPeaksWorkspace_sptr CountReflections::getPeaksWorkspace( +PeaksWorkspace_sptr CountReflections::getPeaksWorkspace( const PeaksWorkspace_sptr &templateWorkspace, const PeakStatisticsTools::UniqueReflectionCollection &reflections, const PointGroup_sptr &pointGroup) const { @@ -179,10 +179,10 @@ IPeaksWorkspace_sptr CountReflections::getPeaksWorkspace( getPropertyValue("MissingReflectionsWorkspace"); if (outputWorkspaceName.empty()) { - return IPeaksWorkspace_sptr(); + return PeaksWorkspace_sptr(); } - IPeaksWorkspace_sptr rawOutputPeaksWorkspace = + PeaksWorkspace_sptr rawOutputPeaksWorkspace = getProperty("MissingReflectionsWorkspace"); PeaksWorkspace_sptr outputPeaksWorkspace = @@ -210,7 +210,7 @@ IPeaksWorkspace_sptr CountReflections::getPeaksWorkspace( outputPeaksWorkspace->getPeaks().swap(peaks); - return boost::static_pointer_cast<IPeaksWorkspace>(outputPeaksWorkspace); + return outputPeaksWorkspace; } } // namespace Crystal diff --git a/Framework/Crystal/src/FilterPeaks.cpp b/Framework/Crystal/src/FilterPeaks.cpp index 4cdce774f1eed10fc8da171d85f9286b17287956..38c27c490eac19e9e5608f5663e4e55134526187 100644 --- a/Framework/Crystal/src/FilterPeaks.cpp +++ b/Framework/Crystal/src/FilterPeaks.cpp @@ -54,7 +54,7 @@ void FilterPeaks::init() { declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "InputWorkspace", "", Direction::Input), "The input workspace"); - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "OutputWorkspace", "", Direction::Output), "The filtered workspace"); @@ -78,8 +78,9 @@ void FilterPeaks::init() { */ void FilterPeaks::exec() { PeaksWorkspace_const_sptr inputWS = getProperty("InputWorkspace"); + PeaksWorkspace_sptr filteredWS = boost::dynamic_pointer_cast<PeaksWorkspace>( + WorkspaceFactory::Instance().createPeaks()); - IPeaksWorkspace_sptr filteredWS = WorkspaceFactory::Instance().createPeaks(); // Copy over ExperimentInfo from input workspace filteredWS->copyExperimentInfoFrom(inputWS.get()); diff --git a/Framework/Crystal/src/FindClusterFaces.cpp b/Framework/Crystal/src/FindClusterFaces.cpp index 0cfe98c93e987aae2285d0edbaebcb7bd71f3d8d..0d0721dfe9dea8091304ffdeede58488873e393c 100644 --- a/Framework/Crystal/src/FindClusterFaces.cpp +++ b/Framework/Crystal/src/FindClusterFaces.cpp @@ -2,10 +2,10 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/IMDIterator.h" -#include "MantidAPI/IPeaksWorkspace.h" #include "MantidAPI/IMDHistoWorkspace.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/PeaksWorkspace.h" #include "MantidGeometry/Crystal/IPeak.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/EnabledWhenProperty.h" @@ -16,6 +16,8 @@ using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace Mantid::API; +using Mantid::DataObjects::PeaksWorkspace; +using Mantid::DataObjects::PeaksWorkspace_sptr; namespace { using namespace Mantid::Crystal; @@ -199,7 +201,7 @@ processing. void executeFiltered(IMDIterator *mdIterator, ClusterFaces &localClusterFaces, Progress &progress, IMDHistoWorkspace_sptr &clusterImage, const std::vector<size_t> &imageShape, - IPeaksWorkspace_sptr &filterWorkspace, + PeaksWorkspace_sptr &filterWorkspace, const OptionalLabelPeakIndexMap &optionalAllowedLabels) { const int emptyLabelId = 0; PeakClusterProjection projection(clusterImage); @@ -268,7 +270,7 @@ void FindClusterFaces::init() { "An input image workspace consisting of cluster ids."); declareProperty( - make_unique<WorkspaceProperty<IPeaksWorkspace>>( + make_unique<WorkspaceProperty<PeaksWorkspace>>( "FilterWorkspace", "", Direction::Input, PropertyMode::Optional), "Optional filtering peaks workspace. Used to restrict face finding to " "clusters in image which correspond to peaks in the workspace."); @@ -308,7 +310,7 @@ void FindClusterFaces::exec() { } // Get the peaks workspace - IPeaksWorkspace_sptr filterWorkspace = this->getProperty("FilterWorkspace"); + PeaksWorkspace_sptr filterWorkspace = this->getProperty("FilterWorkspace"); // Use the peaks workspace to filter to labels of interest OptionalLabelPeakIndexMap optionalAllowedLabels = createOptionalLabelFilter( diff --git a/Framework/Crystal/src/IntegratePeaksHybrid.cpp b/Framework/Crystal/src/IntegratePeaksHybrid.cpp index f66285382f33382c9867c40459757bdfedbaa8be..3fa4e53449907a30284f9d64973a00cc5ecb7b10 100644 --- a/Framework/Crystal/src/IntegratePeaksHybrid.cpp +++ b/Framework/Crystal/src/IntegratePeaksHybrid.cpp @@ -103,7 +103,7 @@ void IntegratePeaksHybrid::init() { declareProperty(make_unique<WorkspaceProperty<IMDEventWorkspace>>( "InputWorkspace", "", Direction::Input), "Input md workspace."); - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "PeaksWorkspace", "", Direction::Input), "A PeaksWorkspace containing the peaks to integrate."); @@ -129,7 +129,7 @@ void IntegratePeaksHybrid::init() { "BackgroundOuterRadius", 0.0, compositeValidator, Direction::Input), "Background outer radius estimate. Choose liberal value."); - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "OutputWorkspace", "", Direction::Output), "An output integrated peaks workspace."); @@ -149,8 +149,8 @@ const std::string IntegratePeaksHybrid::summary() const { */ void IntegratePeaksHybrid::exec() { IMDEventWorkspace_sptr mdWS = getProperty("InputWorkspace"); - IPeaksWorkspace_sptr inPeakWS = getProperty("PeaksWorkspace"); - IPeaksWorkspace_sptr peakWS = getProperty("OutputWorkspace"); + PeaksWorkspace_sptr inPeakWS = getProperty("PeaksWorkspace"); + PeaksWorkspace_sptr peakWS = getProperty("OutputWorkspace"); const int numBins = getProperty("NumberOfBins"); const double peakOuterRadius = getProperty("BackgroundOuterRadius"); const double halfPeakOuterRadius = peakOuterRadius / 2; diff --git a/Framework/Crystal/src/IntegratePeaksUsingClusters.cpp b/Framework/Crystal/src/IntegratePeaksUsingClusters.cpp index 6bd9dc4fcf0cb3085ce1af3dfcc2235a5b841e74..326b216ddcffd03d9b05be9cfa19871d2bb2383f 100644 --- a/Framework/Crystal/src/IntegratePeaksUsingClusters.cpp +++ b/Framework/Crystal/src/IntegratePeaksUsingClusters.cpp @@ -49,7 +49,7 @@ void IntegratePeaksUsingClusters::init() { declareProperty(make_unique<WorkspaceProperty<IMDHistoWorkspace>>( "InputWorkspace", "", Direction::Input), "Input md workspace."); - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "PeaksWorkspace", "", Direction::Input), "A PeaksWorkspace containing the peaks to integrate."); @@ -74,7 +74,7 @@ void IntegratePeaksUsingClusters::init() { "Normalization to use with Threshold. Defaults to " "VolumeNormalization to account for different binning."); - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "OutputWorkspace", "", Direction::Output), "An output integrated peaks workspace."); declareProperty(make_unique<WorkspaceProperty<IMDHistoWorkspace>>( @@ -105,8 +105,8 @@ MDNormalization IntegratePeaksUsingClusters::getNormalization() { */ void IntegratePeaksUsingClusters::exec() { IMDHistoWorkspace_sptr mdWS = getProperty("InputWorkspace"); - IPeaksWorkspace_sptr inPeakWS = getProperty("PeaksWorkspace"); - IPeaksWorkspace_sptr peakWS = getProperty("OutputWorkspace"); + PeaksWorkspace_sptr inPeakWS = getProperty("PeaksWorkspace"); + PeaksWorkspace_sptr peakWS = getProperty("OutputWorkspace"); if (peakWS != inPeakWS) { peakWS = inPeakWS->clone(); } diff --git a/Framework/Crystal/src/PeaksIntersection.cpp b/Framework/Crystal/src/PeaksIntersection.cpp index 24149b55eecd1970628b91891c5f11d7cbf1bb3f..4952a4851c3e63af3d820ff4c517a6f0903d430a 100644 --- a/Framework/Crystal/src/PeaksIntersection.cpp +++ b/Framework/Crystal/src/PeaksIntersection.cpp @@ -1,5 +1,5 @@ #include "MantidKernel/ListValidator.h" -#include "MantidAPI/IPeaksWorkspace.h" +#include "MantidDataObjects/PeaksWorkspace.h" #include "MantidGeometry/Crystal/IPeak.h" #include "MantidAPI/TableRow.h" #include "MantidCrystal/PeaksIntersection.h" @@ -10,6 +10,8 @@ using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid::Kernel; +using Mantid::DataObjects::PeaksWorkspace; +using Mantid::DataObjects::PeaksWorkspace_sptr; namespace Mantid { namespace Crystal { @@ -25,7 +27,7 @@ std::string PeaksIntersection::hklFrame() { return "HKL"; } /** Initialize the algorithm's properties. */ void PeaksIntersection::initBaseProperties() { - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "InputWorkspace", "", Direction::Input), "An input peaks workspace."); @@ -66,7 +68,7 @@ the surfaces. */ void PeaksIntersection::executePeaksIntersection(const bool checkPeakExtents) { const std::string coordinateFrame = this->getPropertyValue("CoordinateFrame"); - IPeaksWorkspace_sptr ws = this->getProperty("InputWorkspace"); + PeaksWorkspace_sptr ws = this->getProperty("InputWorkspace"); m_peakRadius = this->getProperty("PeakRadius"); diff --git a/Framework/Crystal/src/PredictFractionalPeaks.cpp b/Framework/Crystal/src/PredictFractionalPeaks.cpp index 1bf1b8f4caa55f21a2dcd12ef999bf0796089c0d..75f6af586ebe643d0f854018ca93d5ebaa499284 100644 --- a/Framework/Crystal/src/PredictFractionalPeaks.cpp +++ b/Framework/Crystal/src/PredictFractionalPeaks.cpp @@ -29,14 +29,14 @@ DECLARE_ALGORITHM(PredictFractionalPeaks) /// Initialise the properties void PredictFractionalPeaks::init() { declareProperty( - make_unique<WorkspaceProperty<IPeaksWorkspace>>("Peaks", "", - Direction::Input), + make_unique<WorkspaceProperty<PeaksWorkspace>>("Peaks", "", + Direction::Input), "Workspace of Peaks with orientation matrix that indexed the peaks and " "instrument loaded"); declareProperty( - make_unique<WorkspaceProperty<IPeaksWorkspace>>("FracPeaks", "", - Direction::Output), + make_unique<WorkspaceProperty<PeaksWorkspace>>("FracPeaks", "", + Direction::Output), "Workspace of Peaks with peaks with fractional h,k, and/or l values"); declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double>>( string("HOffset"), "-0.5,0.0,0.5"), @@ -95,11 +95,10 @@ void PredictFractionalPeaks::init() { /// Run the algorithm void PredictFractionalPeaks::exec() { - IPeaksWorkspace_sptr ipeaks = getProperty("Peaks"); - auto Peaks = boost::dynamic_pointer_cast<PeaksWorkspace>(ipeaks); + PeaksWorkspace_sptr Peaks = getProperty("Peaks"); if (!Peaks) throw std::invalid_argument( - "Input workspace is not a PeaksWorkspace. Type=" + ipeaks->id()); + "Input workspace is not a PeaksWorkspace. Type=" + Peaks->id()); vector<double> hOffsets = getProperty("HOffset"); vector<double> kOffsets = getProperty("KOffset"); @@ -124,8 +123,8 @@ void PredictFractionalPeaks::exec() { Geometry::Instrument_const_sptr Instr = Peaks->getInstrument(); - boost::shared_ptr<IPeaksWorkspace> OutPeaks = - WorkspaceFactory::Instance().createPeaks(); + auto OutPeaks = boost::dynamic_pointer_cast<IPeaksWorkspace>( + WorkspaceFactory::Instance().createPeaks()); OutPeaks->setInstrument(Instr); V3D hkl; diff --git a/Framework/Crystal/src/SortPeaksWorkspace.cpp b/Framework/Crystal/src/SortPeaksWorkspace.cpp index e6c0a470905036266999cff3b6e5a871f5b62e5c..ad1c6d8b22e4527c02417c22a416537e6e24b1e3 100644 --- a/Framework/Crystal/src/SortPeaksWorkspace.cpp +++ b/Framework/Crystal/src/SortPeaksWorkspace.cpp @@ -31,10 +31,10 @@ const std::string SortPeaksWorkspace::category() const { /** Initialize the algorithm's properties. */ void SortPeaksWorkspace::init() { - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "InputWorkspace", "", Direction::Input), "An input workspace."); - declareProperty(make_unique<WorkspaceProperty<IPeaksWorkspace>>( + declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>( "OutputWorkspace", "", Direction::Output), "An output workspace."); @@ -46,36 +46,14 @@ void SortPeaksWorkspace::init() { "Sort the OutputWorkspace by the target column in a Ascending fashion."); } -PeaksWorkspace_sptr SortPeaksWorkspace::tryFetchOutputWorkspace() const { - IPeaksWorkspace_sptr temp = getProperty("OutputWorkspace"); - PeaksWorkspace_sptr outputWS; - if (temp != nullptr) { - outputWS = boost::dynamic_pointer_cast<PeaksWorkspace>(temp); - if (outputWS == nullptr) { - throw std::invalid_argument("OutputWorkspace is not a PeaksWorkspace."); - } - } - return outputWS; -} - -PeaksWorkspace_sptr SortPeaksWorkspace::tryFetchInputWorkspace() const { - IPeaksWorkspace_sptr temp = getProperty("InputWorkspace"); - PeaksWorkspace_sptr inputWS = - boost::dynamic_pointer_cast<PeaksWorkspace>(temp); - if (inputWS == nullptr) { - throw std::invalid_argument("InputWorkspace is not a PeaksWorkspace."); - } - return inputWS; -} - //---------------------------------------------------------------------------------------------- /** Execute the algorithm. */ void SortPeaksWorkspace::exec() { const std::string columnToSortBy = getProperty("ColumnNameToSortBy"); const bool sortAscending = getProperty("SortAscending"); - PeaksWorkspace_sptr inputWS = tryFetchInputWorkspace(); - PeaksWorkspace_sptr outputWS = tryFetchOutputWorkspace(); + PeaksWorkspace_sptr inputWS = getProperty("InputWorkspace"); + PeaksWorkspace_sptr outputWS = getProperty("OutputWorkspace"); try { // Try to get the column. This will throw if the column does not exist. diff --git a/Framework/Crystal/test/ClusterIntegrationBaseTest.h b/Framework/Crystal/test/ClusterIntegrationBaseTest.h index 56d0fe03679e84f778f9cf847ebf0296094b8b0d..d4accb8e70a99d3b6afc774b64edf81446add221 100644 --- a/Framework/Crystal/test/ClusterIntegrationBaseTest.h +++ b/Framework/Crystal/test/ClusterIntegrationBaseTest.h @@ -29,10 +29,10 @@ using namespace Mantid::Geometry; // Helper typedef using MDHistoPeaksWSTuple = - boost::tuple<IMDHistoWorkspace_sptr, IPeaksWorkspace_sptr>; + boost::tuple<IMDHistoWorkspace_sptr, PeaksWorkspace_sptr>; // Helper typedef using MDEventPeaksWSTuple = - boost::tuple<IMDEventWorkspace_sptr, IPeaksWorkspace_sptr>; + boost::tuple<IMDEventWorkspace_sptr, PeaksWorkspace_sptr>; class ClusterIntegrationBaseTest { protected: @@ -102,7 +102,7 @@ protected: coordsAlg->execute(); // --- Make a fake PeaksWorkspace --- - IPeaksWorkspace_sptr peakWS(new PeaksWorkspace()); + PeaksWorkspace_sptr peakWS(new PeaksWorkspace()); peakWS->setInstrument(inst); // --- Set speical coordinates on fake PeaksWorkspace -- diff --git a/Framework/Crystal/test/IntegratePeaksHybridTest.h b/Framework/Crystal/test/IntegratePeaksHybridTest.h index 97c2a4a92e98da68b93cf5255d36eb0075ca4ae3..eaee855a435077236839622bb9ffadf9a7a17a99 100644 --- a/Framework/Crystal/test/IntegratePeaksHybridTest.h +++ b/Framework/Crystal/test/IntegratePeaksHybridTest.h @@ -19,8 +19,7 @@ using namespace Mantid::DataObjects; using namespace Mantid::API; namespace { -using AlgorithmOutputs = - boost::tuple<WorkspaceGroup_sptr, IPeaksWorkspace_sptr>; +using AlgorithmOutputs = boost::tuple<WorkspaceGroup_sptr, PeaksWorkspace_sptr>; // Execute the clustering integration algorithm AlgorithmOutputs execute_integration(const MDEventPeaksWSTuple &inputWorkspaces, @@ -41,7 +40,7 @@ AlgorithmOutputs execute_integration(const MDEventPeaksWSTuple &inputWorkspaces, alg.setPropertyValue("OutputWorkspaces", "out_ws_md"); alg.execute(); // ------- Get the integrated results - IPeaksWorkspace_sptr outPeaksWS = alg.getProperty("OutputWorkspace"); + PeaksWorkspace_sptr outPeaksWS = alg.getProperty("OutputWorkspace"); WorkspaceGroup_sptr outClustersWS = alg.getProperty("OutputWorkspaces"); return AlgorithmOutputs(outClustersWS, outPeaksWS); } @@ -162,7 +161,7 @@ public: execute_integration(inputWorkspaces, backgroundOuterRadius, nBins); // ------- Get the integrated results WorkspaceGroup_sptr outClustersWorkspaces = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); TSM_ASSERT_EQUALS("Expect one output image", 1, outClustersWorkspaces->size()); @@ -220,9 +219,9 @@ public: AlgorithmOutputs integratedWorkspaces3 = execute_integration(inputWorkspaces, peakRadius * 3.5, nBins); - IPeaksWorkspace_sptr outPeaksWS1 = integratedWorkspaces1.get<1>(); - IPeaksWorkspace_sptr outPeaksWS2 = integratedWorkspaces2.get<1>(); - IPeaksWorkspace_sptr outPeaksWS3 = integratedWorkspaces3.get<1>(); + PeaksWorkspace_sptr outPeaksWS1 = integratedWorkspaces1.get<1>(); + PeaksWorkspace_sptr outPeaksWS2 = integratedWorkspaces2.get<1>(); + PeaksWorkspace_sptr outPeaksWS3 = integratedWorkspaces3.get<1>(); TSM_ASSERT( "Conservative intensities should lead to lower integrated values.", @@ -249,7 +248,7 @@ public: execute_integration(inputWorkspaces, backgroundOuterRadius, nBins); // ------- Get the integrated results WorkspaceGroup_sptr outClustersWorkspaces = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); TSM_ASSERT_EQUALS("Expect two output images", 2, outClustersWorkspaces->size()); @@ -326,7 +325,7 @@ public: execute_integration(inputWorkspaces, backgroundOuterRadius, nBins); // ------- Get the integrated results WorkspaceGroup_sptr outClustersWorkspaces = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); TSM_ASSERT_EQUALS("Expect two output images", 2, outClustersWorkspaces->size()); diff --git a/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h b/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h index 1999f8ba3b5f94b69f727799ea3638909a6cf95b..8b9006e71535f181a03cd65faaf34ee48fa9516b 100644 --- a/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h +++ b/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h @@ -29,7 +29,7 @@ execute_integration(const MDHistoPeaksWSTuple &inputWorkspaces, alg.setPropertyValue("OutputWorkspaceMD", "out_ws_md"); alg.execute(); // ------- Get the integrated results - IPeaksWorkspace_sptr outPeaksWS = alg.getProperty("OutputWorkspace"); + PeaksWorkspace_sptr outPeaksWS = alg.getProperty("OutputWorkspace"); IMDHistoWorkspace_sptr outClustersWS = alg.getProperty("OutputWorkspaceMD"); return MDHistoPeaksWSTuple(outClustersWS, outPeaksWS); } @@ -119,7 +119,7 @@ public: execute_integration(inputWorkspaces, threshold); // ------- Get the integrated results IMDHistoWorkspace_sptr outClustersWS = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); std::unordered_set<Mantid::signal_t> labelIds; for (size_t i = 0; i < outClustersWS->getNPoints(); ++i) { @@ -149,7 +149,7 @@ public: execute_integration(inputWorkspaces, threshold); // ------- Get the integrated results IMDHistoWorkspace_sptr outClustersWS = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); // ------- Check the results. // Basic checks @@ -190,7 +190,7 @@ public: execute_integration(inputWorkspaces, threshold); // ------- Get the integrated results IMDHistoWorkspace_sptr outClustersWS = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); // ------- Check the results. // Basic checks @@ -245,7 +245,7 @@ public: execute_integration(inputWorkspaces, threshold); // ------- Get the integrated results IMDHistoWorkspace_sptr outClustersWS = integratedWorkspaces.get<0>(); - IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); + PeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); // ------- Check the results. // Basic checks diff --git a/Framework/Crystal/test/PredictFractionalPeaksTest.h b/Framework/Crystal/test/PredictFractionalPeaksTest.h index 67bde5aef220ff2263c64c184d01da7d52c9e123..a0e45adce0f88a62b13043a48e860614d9827879 100644 --- a/Framework/Crystal/test/PredictFractionalPeaksTest.h +++ b/Framework/Crystal/test/PredictFractionalPeaksTest.h @@ -77,7 +77,7 @@ public: TS_ASSERT(alg.execute()); TS_ASSERT(alg.isExecuted()); alg.setPropertyValue("FracPeaks", "FracPeaks"); - IPeaksWorkspace_sptr FracPeaks = alg.getProperty("FracPeaks"); + PeaksWorkspace_sptr FracPeaks = alg.getProperty("FracPeaks"); TS_ASSERT_EQUALS(FracPeaks->getNumberPeaks(), 117); diff --git a/Framework/Crystal/test/SortPeaksWorkspaceTest.h b/Framework/Crystal/test/SortPeaksWorkspaceTest.h index e5c1ad9b4daa159ca175bafe7b4deec2c963e2ff..65824d934701dd0b4f74e6660e40a7265ab69f3f 100644 --- a/Framework/Crystal/test/SortPeaksWorkspaceTest.h +++ b/Framework/Crystal/test/SortPeaksWorkspaceTest.h @@ -194,9 +194,7 @@ public: TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT(alg.isExecuted()); - IPeaksWorkspace_sptr temp = alg.getProperty("OutputWorkspace"); - PeaksWorkspace_sptr outWS = - boost::dynamic_pointer_cast<PeaksWorkspace>(temp); + PeaksWorkspace_sptr outWS = alg.getProperty("OutputWorkspace"); TSM_ASSERT_EQUALS("Sorting should have happened in place. Output and input " "workspaces should be the same.", diff --git a/Framework/MDAlgorithms/src/CentroidPeaksMD2.cpp b/Framework/MDAlgorithms/src/CentroidPeaksMD2.cpp index 30d5377ec3d098d7b7a0937501df4aa0a3f60968..ba0bd41854826980170b1634385576057faff19e 100644 --- a/Framework/MDAlgorithms/src/CentroidPeaksMD2.cpp +++ b/Framework/MDAlgorithms/src/CentroidPeaksMD2.cpp @@ -64,6 +64,7 @@ void CentroidPeaksMD2::integrate(typename MDEventWorkspace<MDE, nd>::sptr ws) { /// Output peaks workspace, create if needed Mantid::DataObjects::PeaksWorkspace_sptr peakWS = getProperty("OutputWorkspace"); + if (peakWS != inPeakWS) peakWS = inPeakWS->clone(); diff --git a/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt b/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt index c62dff44d9f4bfff8a37f70c17122a61324f4f97..d07d831a7c3edc8b4c208557dcf86f8dd0b53070 100644 --- a/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt +++ b/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt @@ -21,6 +21,7 @@ set ( EXPORT_FILES src/Exports/MDEventWorkspace.cpp src/Exports/MDHistoWorkspace.cpp src/Exports/PeaksWorkspace.cpp + src/Exports/PeaksWorkspaceProperty.cpp src/Exports/TableWorkspace.cpp src/Exports/SplittersWorkspace.cpp src/Exports/WorkspaceSingleValue.cpp diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/PeaksWorkspaceProperty.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/PeaksWorkspaceProperty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7de867a940062fe1296870b97c1d161ff09c6d9d --- /dev/null +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/PeaksWorkspaceProperty.cpp @@ -0,0 +1,13 @@ +#include "MantidPythonInterface/api/WorkspacePropertyExporter.h" +#include "MantidPythonInterface/kernel/GetPointer.h" +#include "MantidDataObjects/PeaksWorkspace.h" + +using Mantid::DataObjects::PeaksWorkspace; +using Mantid::API::WorkspaceProperty; // NOLINT + +GET_POINTER_SPECIALIZATION(WorkspaceProperty<PeaksWorkspace>) + +void export_IPeaksWorkspaceProperty() { + using Mantid::PythonInterface::WorkspacePropertyExporter; + WorkspacePropertyExporter<PeaksWorkspace>::define("PeaksWorkspaceProperty"); +} diff --git a/Framework/PythonInterface/mantid/simpleapi.py b/Framework/PythonInterface/mantid/simpleapi.py index 6feb7c860b4a31cfb424aeac4657e7f8bfd1a45c..a89b92b78316495724c302493b1a0d8672132f28 100644 --- a/Framework/PythonInterface/mantid/simpleapi.py +++ b/Framework/PythonInterface/mantid/simpleapi.py @@ -936,7 +936,7 @@ def _gather_returns(func_name, lhs, algm_obj, ignore_regex=None, inout=False): value_str = prop.valueAsStr retvals[name] = _api.AnalysisDataService[value_str] except KeyError: - if not prop.isOptional() and prop.direction == _kernel.Direction.InOut: + if not (hasattr(prop, 'isOptional') and prop.isOptional()) and prop.direction == _kernel.Direction.InOut: raise RuntimeError("Mandatory InOut workspace property '%s' on " "algorithm '%s' has not been set correctly. " % (name, algm_obj.name())) elif _is_function_property(prop): diff --git a/qt/paraview_ext/VatesAPI/src/ConcretePeaksPresenterVsi.cpp b/qt/paraview_ext/VatesAPI/src/ConcretePeaksPresenterVsi.cpp index d42265700cc6166c819560c77b00bc292d5ada53..f3956f6ac1bfecd14ad29145fd078ed7d70b77e3 100644 --- a/qt/paraview_ext/VatesAPI/src/ConcretePeaksPresenterVsi.cpp +++ b/qt/paraview_ext/VatesAPI/src/ConcretePeaksPresenterVsi.cpp @@ -3,6 +3,7 @@ #include "MantidAPI/IPeaksWorkspace.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidDataObjects/NoShape.h" +#include "MantidDataObjects/PeaksWorkspace.h" #include "MantidDataObjects/PeakShapeSpherical.h" #include "MantidDataObjects/PeakShapeEllipsoid.h" #include "MantidKernel/SpecialCoordinateSystem.h" @@ -10,6 +11,9 @@ #include "MantidGeometry/Crystal/PeakShape.h" namespace Mantid { namespace VATES { + +using Mantid::DataObjects::PeaksWorkspace; + /** * Constructor * @param peaksWorkspace The peaks workspace. @@ -46,7 +50,8 @@ std::vector<bool> ConcretePeaksPresenterVsi::getViewablePeaks() const { if (this->m_peaksWorkspace->getNumberPeaks() >= 1) { double effectiveRadius = 1e-2; std::string viewable = m_viewableRegion->toExtentsAsString(); - Mantid::API::IPeaksWorkspace_sptr peaksWS = m_peaksWorkspace; + auto peaksWS = + boost::dynamic_pointer_cast<PeaksWorkspace>(m_peaksWorkspace); Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("PeaksInRegion"); @@ -158,9 +163,7 @@ double ConcretePeaksPresenterVsi::getMaxRadius( */ void ConcretePeaksPresenterVsi::sortPeaksWorkspace( const std::string &byColumnName, const bool ascending) { - Mantid::API::IPeaksWorkspace_sptr peaksWS = - boost::const_pointer_cast<Mantid::API::IPeaksWorkspace>( - this->m_peaksWorkspace); + auto peaksWS = boost::dynamic_pointer_cast<PeaksWorkspace>(m_peaksWorkspace); // Sort the Peaks in-place. Mantid::API::IAlgorithm_sptr alg =